Skip to content

Commit

Permalink
Revert "make indexBy more type sensitive"
Browse files Browse the repository at this point in the history
This reverts commit a911be7.
  • Loading branch information
Colby Rabideau committed Dec 4, 2017
1 parent 8647ed2 commit 44ef420
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/__tests__/__snapshots__/indexBy-test.js.snap
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`transmute/indexBy indexes a List 1`] = `
Immutable.Map {
Immutable.OrderedMap {
"123": Immutable.Map {
"id": "123",
},
Expand All @@ -23,7 +23,7 @@ Immutable.Map {
`;

exports[`transmute/indexBy indexes an Array 1`] = `
Object {
Immutable.OrderedMap {
"123": Immutable.Map {
"id": "123",
},
Expand All @@ -34,7 +34,7 @@ Object {
`;

exports[`transmute/indexBy indexes an Object 1`] = `
Object {
Immutable.OrderedMap {
"123": Object {
"id": "123",
},
Expand Down
8 changes: 4 additions & 4 deletions src/indexBy.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import _keyedEquivalent from './internal/_keyedEquivalent';
import _reduce from './internal/_reduce';
import _set from './internal/_set';
import curry from './curry';
import { Iterable, Map, OrderedMap } from 'immutable';

function indexBy(keyMapper, subject) {
return _reduce(
_keyedEquivalent(subject),
(acc, v, k) => _set(keyMapper(v, k, subject), v, acc),
Iterable.isOrdered(subject) || !Iterable.isIterable(subject)
? OrderedMap()
: Map(),
(acc, v, k) => acc.set(keyMapper(v, k, subject), v),
subject
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/internal/_keyedEquivalent.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Collection, Iterable, Map, Seq } from 'immutable';
import { Collection, Map, Seq } from 'immutable';
import { keyedEquivalent } from './TransmuteCollection';

const makeObject = () => ({});
Expand Down

0 comments on commit 44ef420

Please sign in to comment.