Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9ab3dca

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

File tree

1 file changed

+15
-6
lines changed
Filter options

1 file changed

+15
-6
lines changed

‎src/functional/updateIn.js

Copy file name to clipboardExpand all lines: src/functional/updateIn.js
+15-6Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.