Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9ab3dca

Browse files
committed
Change the type of set container depending on the type of key.
1 parent 751082f commit 9ab3dca

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/functional/updateIn.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import isDataStructure from '../utils/isDataStructure';
1111
import quoteString from '../utils/quoteString';
1212
import { NOT_SET } from '../TrieUtils';
1313
import { emptyMap } from '../Map';
14+
import { emptyList } from '../List';
1415
import { get } from './get';
1516
import { remove } from './remove';
1617
import { set } from './set';
@@ -66,10 +67,18 @@ function updateInDeeply(
6667
return nextUpdated === nextExisting
6768
? existing
6869
: nextUpdated === NOT_SET
69-
? remove(existing, key)
70-
: set(
71-
wasNotSet ? (inImmutable ? emptyMap() : {}) : existing,
72-
key,
73-
nextUpdated
74-
);
70+
? remove(existing, key)
71+
: set(
72+
wasNotSet
73+
? inImmutable
74+
? typeof key === 'number'
75+
? emptyList()
76+
: emptyMap()
77+
: typeof key === 'number'
78+
? []
79+
: {}
80+
: existing,
81+
key,
82+
nextUpdated
83+
);
7584
}

0 commit comments

Comments
 (0)