immutable 5.0.0-rc.2 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/immutable.es.js +5930 -0
- package/dist/immutable.js +1 -1
- package/dist/immutable.js.flow +3 -3
- package/dist/immutable.min.js +1 -1
- package/package.json +1 -1
- package/dist/es/Collection.js +0 -79
- package/dist/es/CollectionImpl.js +0 -776
- package/dist/es/Hash.js +0 -260
- package/dist/es/Immutable.js +0 -73
- package/dist/es/Iterator.js +0 -106
- package/dist/es/List.js +0 -696
- package/dist/es/Map.js +0 -820
- package/dist/es/Math.js +0 -45
- package/dist/es/Operations.js +0 -953
- package/dist/es/OrderedMap.js +0 -196
- package/dist/es/OrderedSet.js +0 -92
- package/dist/es/PairSorting.js +0 -30
- package/dist/es/Range.js +0 -178
- package/dist/es/Record.js +0 -292
- package/dist/es/Repeat.js +0 -133
- package/dist/es/Seq.js +0 -401
- package/dist/es/Set.js +0 -279
- package/dist/es/Stack.js +0 -261
- package/dist/es/TrieUtils.js +0 -117
- package/dist/es/fromJS.js +0 -74
- package/dist/es/functional/get.js +0 -38
- package/dist/es/functional/getIn.js +0 -41
- package/dist/es/functional/has.js +0 -35
- package/dist/es/functional/hasIn.js +0 -32
- package/dist/es/functional/merge.js +0 -137
- package/dist/es/functional/remove.js +0 -56
- package/dist/es/functional/removeIn.js +0 -32
- package/dist/es/functional/set.js +0 -52
- package/dist/es/functional/setIn.js +0 -32
- package/dist/es/functional/update.js +0 -31
- package/dist/es/functional/updateIn.js +0 -94
- package/dist/es/is.js +0 -108
- package/dist/es/methods/asImmutable.js +0 -29
- package/dist/es/methods/asMutable.js +0 -31
- package/dist/es/methods/deleteIn.js +0 -31
- package/dist/es/methods/getIn.js +0 -31
- package/dist/es/methods/hasIn.js +0 -31
- package/dist/es/methods/merge.js +0 -79
- package/dist/es/methods/mergeDeep.js +0 -41
- package/dist/es/methods/mergeDeepIn.js +0 -37
- package/dist/es/methods/mergeIn.js +0 -36
- package/dist/es/methods/setIn.js +0 -31
- package/dist/es/methods/toObject.js +0 -36
- package/dist/es/methods/update.js +0 -33
- package/dist/es/methods/updateIn.js +0 -31
- package/dist/es/methods/wasAltered.js +0 -29
- package/dist/es/methods/withMutations.js +0 -31
- package/dist/es/package.json.js +0 -27
- package/dist/es/predicates/isAssociative.js +0 -32
- package/dist/es/predicates/isCollection.js +0 -32
- package/dist/es/predicates/isImmutable.js +0 -32
- package/dist/es/predicates/isIndexed.js +0 -31
- package/dist/es/predicates/isKeyed.js +0 -31
- package/dist/es/predicates/isList.js +0 -31
- package/dist/es/predicates/isMap.js +0 -31
- package/dist/es/predicates/isOrdered.js +0 -31
- package/dist/es/predicates/isOrderedMap.js +0 -32
- package/dist/es/predicates/isOrderedSet.js +0 -32
- package/dist/es/predicates/isRecord.js +0 -31
- package/dist/es/predicates/isSeq.js +0 -31
- package/dist/es/predicates/isSet.js +0 -31
- package/dist/es/predicates/isStack.js +0 -31
- package/dist/es/predicates/isValueObject.js +0 -33
- package/dist/es/toJS.js +0 -54
- package/dist/es/utils/arrCopy.js +0 -36
- package/dist/es/utils/assertNotInfinite.js +0 -34
- package/dist/es/utils/coerceKeyPath.js +0 -40
- package/dist/es/utils/deepEqual.js +0 -99
- package/dist/es/utils/hasOwnProperty.js +0 -27
- package/dist/es/utils/invariant.js +0 -29
- package/dist/es/utils/isArrayLike.js +0 -44
- package/dist/es/utils/isDataStructure.js +0 -39
- package/dist/es/utils/isPlainObj.js +0 -52
- package/dist/es/utils/mixin.js +0 -38
- package/dist/es/utils/quoteString.js +0 -36
- package/dist/es/utils/shallowCopy.js +0 -41
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* MIT License
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) 2014-present, Lee Byron and other contributors.
|
|
6
|
-
*
|
|
7
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
* in the Software without restriction, including without limitation the rights
|
|
10
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
* furnished to do so, subject to the following conditions:
|
|
13
|
-
*
|
|
14
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
* copies or substantial portions of the Software.
|
|
16
|
-
*
|
|
17
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
* SOFTWARE.
|
|
24
|
-
*/
|
|
25
|
-
import { isImmutable } from '../predicates/isImmutable.js';
|
|
26
|
-
import { isIndexed } from '../predicates/isIndexed.js';
|
|
27
|
-
import { isKeyed } from '../predicates/isKeyed.js';
|
|
28
|
-
import { IndexedCollection, KeyedCollection } from '../Collection.js';
|
|
29
|
-
import { Seq } from '../Seq.js';
|
|
30
|
-
import hasOwnProperty from '../utils/hasOwnProperty.js';
|
|
31
|
-
import isDataStructure from '../utils/isDataStructure.js';
|
|
32
|
-
import shallowCopy from '../utils/shallowCopy.js';
|
|
33
|
-
|
|
34
|
-
function merge(collection) {
|
|
35
|
-
var sources = [], len = arguments.length - 1;
|
|
36
|
-
while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ];
|
|
37
|
-
|
|
38
|
-
return mergeWithSources(collection, sources);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function mergeWith(merger, collection) {
|
|
42
|
-
var sources = [], len = arguments.length - 2;
|
|
43
|
-
while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ];
|
|
44
|
-
|
|
45
|
-
return mergeWithSources(collection, sources, merger);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function mergeDeep(collection) {
|
|
49
|
-
var sources = [], len = arguments.length - 1;
|
|
50
|
-
while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ];
|
|
51
|
-
|
|
52
|
-
return mergeDeepWithSources(collection, sources);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function mergeDeepWith(merger, collection) {
|
|
56
|
-
var sources = [], len = arguments.length - 2;
|
|
57
|
-
while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ];
|
|
58
|
-
|
|
59
|
-
return mergeDeepWithSources(collection, sources, merger);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function mergeDeepWithSources(collection, sources, merger) {
|
|
63
|
-
return mergeWithSources(collection, sources, deepMergerWith(merger));
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function mergeWithSources(collection, sources, merger) {
|
|
67
|
-
if (!isDataStructure(collection)) {
|
|
68
|
-
throw new TypeError(
|
|
69
|
-
'Cannot merge into non-data-structure value: ' + collection
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
if (isImmutable(collection)) {
|
|
73
|
-
return typeof merger === 'function' && collection.mergeWith
|
|
74
|
-
? collection.mergeWith.apply(collection, [ merger ].concat( sources ))
|
|
75
|
-
: collection.merge
|
|
76
|
-
? collection.merge.apply(collection, sources)
|
|
77
|
-
: collection.concat.apply(collection, sources);
|
|
78
|
-
}
|
|
79
|
-
var isArray = Array.isArray(collection);
|
|
80
|
-
var merged = collection;
|
|
81
|
-
var Collection = isArray ? IndexedCollection : KeyedCollection;
|
|
82
|
-
var mergeItem = isArray
|
|
83
|
-
? function (value) {
|
|
84
|
-
// Copy on write
|
|
85
|
-
if (merged === collection) {
|
|
86
|
-
merged = shallowCopy(merged);
|
|
87
|
-
}
|
|
88
|
-
merged.push(value);
|
|
89
|
-
}
|
|
90
|
-
: function (value, key) {
|
|
91
|
-
var hasVal = hasOwnProperty.call(merged, key);
|
|
92
|
-
var nextVal =
|
|
93
|
-
hasVal && merger ? merger(merged[key], value, key) : value;
|
|
94
|
-
if (!hasVal || nextVal !== merged[key]) {
|
|
95
|
-
// Copy on write
|
|
96
|
-
if (merged === collection) {
|
|
97
|
-
merged = shallowCopy(merged);
|
|
98
|
-
}
|
|
99
|
-
merged[key] = nextVal;
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
for (var i = 0; i < sources.length; i++) {
|
|
103
|
-
Collection(sources[i]).forEach(mergeItem);
|
|
104
|
-
}
|
|
105
|
-
return merged;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
function deepMergerWith(merger) {
|
|
109
|
-
function deepMerger(oldValue, newValue, key) {
|
|
110
|
-
return isDataStructure(oldValue) &&
|
|
111
|
-
isDataStructure(newValue) &&
|
|
112
|
-
areMergeable(oldValue, newValue)
|
|
113
|
-
? mergeWithSources(oldValue, [newValue], deepMerger)
|
|
114
|
-
: merger
|
|
115
|
-
? merger(oldValue, newValue, key)
|
|
116
|
-
: newValue;
|
|
117
|
-
}
|
|
118
|
-
return deepMerger;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* It's unclear what the desired behavior is for merging two collections that
|
|
123
|
-
* fall into separate categories between keyed, indexed, or set-like, so we only
|
|
124
|
-
* consider them mergeable if they fall into the same category.
|
|
125
|
-
*/
|
|
126
|
-
function areMergeable(oldDataStructure, newDataStructure) {
|
|
127
|
-
var oldSeq = Seq(oldDataStructure);
|
|
128
|
-
var newSeq = Seq(newDataStructure);
|
|
129
|
-
// This logic assumes that a sequence can only fall into one of the three
|
|
130
|
-
// categories mentioned above (since there's no `isSetLike()` method).
|
|
131
|
-
return (
|
|
132
|
-
isIndexed(oldSeq) === isIndexed(newSeq) &&
|
|
133
|
-
isKeyed(oldSeq) === isKeyed(newSeq)
|
|
134
|
-
);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
export { merge, mergeDeep, mergeDeepWith, mergeDeepWithSources, mergeWith, mergeWithSources };
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* MIT License
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) 2014-present, Lee Byron and other contributors.
|
|
6
|
-
*
|
|
7
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
* in the Software without restriction, including without limitation the rights
|
|
10
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
* furnished to do so, subject to the following conditions:
|
|
13
|
-
*
|
|
14
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
* copies or substantial portions of the Software.
|
|
16
|
-
*
|
|
17
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
* SOFTWARE.
|
|
24
|
-
*/
|
|
25
|
-
import { isImmutable } from '../predicates/isImmutable.js';
|
|
26
|
-
import hasOwnProperty from '../utils/hasOwnProperty.js';
|
|
27
|
-
import isDataStructure from '../utils/isDataStructure.js';
|
|
28
|
-
import shallowCopy from '../utils/shallowCopy.js';
|
|
29
|
-
|
|
30
|
-
function remove(collection, key) {
|
|
31
|
-
if (!isDataStructure(collection)) {
|
|
32
|
-
throw new TypeError(
|
|
33
|
-
'Cannot update non-data-structure value: ' + collection
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
if (isImmutable(collection)) {
|
|
37
|
-
if (!collection.remove) {
|
|
38
|
-
throw new TypeError(
|
|
39
|
-
'Cannot update immutable value without .remove() method: ' + collection
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
return collection.remove(key);
|
|
43
|
-
}
|
|
44
|
-
if (!hasOwnProperty.call(collection, key)) {
|
|
45
|
-
return collection;
|
|
46
|
-
}
|
|
47
|
-
var collectionCopy = shallowCopy(collection);
|
|
48
|
-
if (Array.isArray(collectionCopy)) {
|
|
49
|
-
collectionCopy.splice(key, 1);
|
|
50
|
-
} else {
|
|
51
|
-
delete collectionCopy[key];
|
|
52
|
-
}
|
|
53
|
-
return collectionCopy;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export { remove };
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* MIT License
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) 2014-present, Lee Byron and other contributors.
|
|
6
|
-
*
|
|
7
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
* in the Software without restriction, including without limitation the rights
|
|
10
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
* furnished to do so, subject to the following conditions:
|
|
13
|
-
*
|
|
14
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
* copies or substantial portions of the Software.
|
|
16
|
-
*
|
|
17
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
* SOFTWARE.
|
|
24
|
-
*/
|
|
25
|
-
import { updateIn } from './updateIn.js';
|
|
26
|
-
import { NOT_SET } from '../TrieUtils.js';
|
|
27
|
-
|
|
28
|
-
function removeIn(collection, keyPath) {
|
|
29
|
-
return updateIn(collection, keyPath, function () { return NOT_SET; });
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export { removeIn };
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* MIT License
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) 2014-present, Lee Byron and other contributors.
|
|
6
|
-
*
|
|
7
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
* in the Software without restriction, including without limitation the rights
|
|
10
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
* furnished to do so, subject to the following conditions:
|
|
13
|
-
*
|
|
14
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
* copies or substantial portions of the Software.
|
|
16
|
-
*
|
|
17
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
* SOFTWARE.
|
|
24
|
-
*/
|
|
25
|
-
import { isImmutable } from '../predicates/isImmutable.js';
|
|
26
|
-
import hasOwnProperty from '../utils/hasOwnProperty.js';
|
|
27
|
-
import isDataStructure from '../utils/isDataStructure.js';
|
|
28
|
-
import shallowCopy from '../utils/shallowCopy.js';
|
|
29
|
-
|
|
30
|
-
function set(collection, key, value) {
|
|
31
|
-
if (!isDataStructure(collection)) {
|
|
32
|
-
throw new TypeError(
|
|
33
|
-
'Cannot update non-data-structure value: ' + collection
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
if (isImmutable(collection)) {
|
|
37
|
-
if (!collection.set) {
|
|
38
|
-
throw new TypeError(
|
|
39
|
-
'Cannot update immutable value without .set() method: ' + collection
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
return collection.set(key, value);
|
|
43
|
-
}
|
|
44
|
-
if (hasOwnProperty.call(collection, key) && value === collection[key]) {
|
|
45
|
-
return collection;
|
|
46
|
-
}
|
|
47
|
-
var collectionCopy = shallowCopy(collection);
|
|
48
|
-
collectionCopy[key] = value;
|
|
49
|
-
return collectionCopy;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export { set };
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* MIT License
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) 2014-present, Lee Byron and other contributors.
|
|
6
|
-
*
|
|
7
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
* in the Software without restriction, including without limitation the rights
|
|
10
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
* furnished to do so, subject to the following conditions:
|
|
13
|
-
*
|
|
14
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
* copies or substantial portions of the Software.
|
|
16
|
-
*
|
|
17
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
* SOFTWARE.
|
|
24
|
-
*/
|
|
25
|
-
import { updateIn } from './updateIn.js';
|
|
26
|
-
import { NOT_SET } from '../TrieUtils.js';
|
|
27
|
-
|
|
28
|
-
function setIn(collection, keyPath, value) {
|
|
29
|
-
return updateIn(collection, keyPath, NOT_SET, function () { return value; });
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export { setIn };
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* MIT License
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) 2014-present, Lee Byron and other contributors.
|
|
6
|
-
*
|
|
7
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
* in the Software without restriction, including without limitation the rights
|
|
10
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
* furnished to do so, subject to the following conditions:
|
|
13
|
-
*
|
|
14
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
* copies or substantial portions of the Software.
|
|
16
|
-
*
|
|
17
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
* SOFTWARE.
|
|
24
|
-
*/
|
|
25
|
-
import { updateIn } from './updateIn.js';
|
|
26
|
-
|
|
27
|
-
function update(collection, key, notSetValue, updater) {
|
|
28
|
-
return updateIn(collection, [key], notSetValue, updater);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export { update };
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* MIT License
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) 2014-present, Lee Byron and other contributors.
|
|
6
|
-
*
|
|
7
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
* in the Software without restriction, including without limitation the rights
|
|
10
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
* furnished to do so, subject to the following conditions:
|
|
13
|
-
*
|
|
14
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
* copies or substantial portions of the Software.
|
|
16
|
-
*
|
|
17
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
* SOFTWARE.
|
|
24
|
-
*/
|
|
25
|
-
import { isImmutable } from '../predicates/isImmutable.js';
|
|
26
|
-
import coerceKeyPath from '../utils/coerceKeyPath.js';
|
|
27
|
-
import isDataStructure from '../utils/isDataStructure.js';
|
|
28
|
-
import quoteString from '../utils/quoteString.js';
|
|
29
|
-
import { NOT_SET } from '../TrieUtils.js';
|
|
30
|
-
import { emptyMap } from '../Map.js';
|
|
31
|
-
import { get } from './get.js';
|
|
32
|
-
import { remove } from './remove.js';
|
|
33
|
-
import { set } from './set.js';
|
|
34
|
-
|
|
35
|
-
function updateIn(collection, keyPath, notSetValue, updater) {
|
|
36
|
-
if (!updater) {
|
|
37
|
-
updater = notSetValue;
|
|
38
|
-
notSetValue = undefined;
|
|
39
|
-
}
|
|
40
|
-
var updatedValue = updateInDeeply(
|
|
41
|
-
isImmutable(collection),
|
|
42
|
-
collection,
|
|
43
|
-
coerceKeyPath(keyPath),
|
|
44
|
-
0,
|
|
45
|
-
notSetValue,
|
|
46
|
-
updater
|
|
47
|
-
);
|
|
48
|
-
return updatedValue === NOT_SET ? notSetValue : updatedValue;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function updateInDeeply(
|
|
52
|
-
inImmutable,
|
|
53
|
-
existing,
|
|
54
|
-
keyPath,
|
|
55
|
-
i,
|
|
56
|
-
notSetValue,
|
|
57
|
-
updater
|
|
58
|
-
) {
|
|
59
|
-
var wasNotSet = existing === NOT_SET;
|
|
60
|
-
if (i === keyPath.length) {
|
|
61
|
-
var existingValue = wasNotSet ? notSetValue : existing;
|
|
62
|
-
var newValue = updater(existingValue);
|
|
63
|
-
return newValue === existingValue ? existing : newValue;
|
|
64
|
-
}
|
|
65
|
-
if (!wasNotSet && !isDataStructure(existing)) {
|
|
66
|
-
throw new TypeError(
|
|
67
|
-
'Cannot update within non-data-structure value in path [' +
|
|
68
|
-
keyPath.slice(0, i).map(quoteString) +
|
|
69
|
-
']: ' +
|
|
70
|
-
existing
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
var key = keyPath[i];
|
|
74
|
-
var nextExisting = wasNotSet ? NOT_SET : get(existing, key, NOT_SET);
|
|
75
|
-
var nextUpdated = updateInDeeply(
|
|
76
|
-
nextExisting === NOT_SET ? inImmutable : isImmutable(nextExisting),
|
|
77
|
-
nextExisting,
|
|
78
|
-
keyPath,
|
|
79
|
-
i + 1,
|
|
80
|
-
notSetValue,
|
|
81
|
-
updater
|
|
82
|
-
);
|
|
83
|
-
return nextUpdated === nextExisting
|
|
84
|
-
? existing
|
|
85
|
-
: nextUpdated === NOT_SET
|
|
86
|
-
? remove(existing, key)
|
|
87
|
-
: set(
|
|
88
|
-
wasNotSet ? (inImmutable ? emptyMap() : {}) : existing,
|
|
89
|
-
key,
|
|
90
|
-
nextUpdated
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export { updateIn };
|
package/dist/es/is.js
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* MIT License
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) 2014-present, Lee Byron and other contributors.
|
|
6
|
-
*
|
|
7
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
* in the Software without restriction, including without limitation the rights
|
|
10
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
* furnished to do so, subject to the following conditions:
|
|
13
|
-
*
|
|
14
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
* copies or substantial portions of the Software.
|
|
16
|
-
*
|
|
17
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
* SOFTWARE.
|
|
24
|
-
*/
|
|
25
|
-
import { isValueObject } from './predicates/isValueObject.js';
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* An extension of the "same-value" algorithm as [described for use by ES6 Map
|
|
29
|
-
* and Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Key_equality)
|
|
30
|
-
*
|
|
31
|
-
* NaN is considered the same as NaN, however -0 and 0 are considered the same
|
|
32
|
-
* value, which is different from the algorithm described by
|
|
33
|
-
* [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
|
|
34
|
-
*
|
|
35
|
-
* This is extended further to allow Objects to describe the values they
|
|
36
|
-
* represent, by way of `valueOf` or `equals` (and `hashCode`).
|
|
37
|
-
*
|
|
38
|
-
* Note: because of this extension, the key equality of Immutable.Map and the
|
|
39
|
-
* value equality of Immutable.Set will differ from ES6 Map and Set.
|
|
40
|
-
*
|
|
41
|
-
* ### Defining custom values
|
|
42
|
-
*
|
|
43
|
-
* The easiest way to describe the value an object represents is by implementing
|
|
44
|
-
* `valueOf`. For example, `Date` represents a value by returning a unix
|
|
45
|
-
* timestamp for `valueOf`:
|
|
46
|
-
*
|
|
47
|
-
* var date1 = new Date(1234567890000); // Fri Feb 13 2009 ...
|
|
48
|
-
* var date2 = new Date(1234567890000);
|
|
49
|
-
* date1.valueOf(); // 1234567890000
|
|
50
|
-
* assert( date1 !== date2 );
|
|
51
|
-
* assert( Immutable.is( date1, date2 ) );
|
|
52
|
-
*
|
|
53
|
-
* Note: overriding `valueOf` may have other implications if you use this object
|
|
54
|
-
* where JavaScript expects a primitive, such as implicit string coercion.
|
|
55
|
-
*
|
|
56
|
-
* For more complex types, especially collections, implementing `valueOf` may
|
|
57
|
-
* not be performant. An alternative is to implement `equals` and `hashCode`.
|
|
58
|
-
*
|
|
59
|
-
* `equals` takes another object, presumably of similar type, and returns true
|
|
60
|
-
* if it is equal. Equality is symmetrical, so the same result should be
|
|
61
|
-
* returned if this and the argument are flipped.
|
|
62
|
-
*
|
|
63
|
-
* assert( a.equals(b) === b.equals(a) );
|
|
64
|
-
*
|
|
65
|
-
* `hashCode` returns a 32bit integer number representing the object which will
|
|
66
|
-
* be used to determine how to store the value object in a Map or Set. You must
|
|
67
|
-
* provide both or neither methods, one must not exist without the other.
|
|
68
|
-
*
|
|
69
|
-
* Also, an important relationship between these methods must be upheld: if two
|
|
70
|
-
* values are equal, they *must* return the same hashCode. If the values are not
|
|
71
|
-
* equal, they might have the same hashCode; this is called a hash collision,
|
|
72
|
-
* and while undesirable for performance reasons, it is acceptable.
|
|
73
|
-
*
|
|
74
|
-
* if (a.equals(b)) {
|
|
75
|
-
* assert( a.hashCode() === b.hashCode() );
|
|
76
|
-
* }
|
|
77
|
-
*
|
|
78
|
-
* All Immutable collections are Value Objects: they implement `equals()`
|
|
79
|
-
* and `hashCode()`.
|
|
80
|
-
*/
|
|
81
|
-
function is(valueA, valueB) {
|
|
82
|
-
if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
|
|
83
|
-
return true;
|
|
84
|
-
}
|
|
85
|
-
if (!valueA || !valueB) {
|
|
86
|
-
return false;
|
|
87
|
-
}
|
|
88
|
-
if (
|
|
89
|
-
typeof valueA.valueOf === 'function' &&
|
|
90
|
-
typeof valueB.valueOf === 'function'
|
|
91
|
-
) {
|
|
92
|
-
valueA = valueA.valueOf();
|
|
93
|
-
valueB = valueB.valueOf();
|
|
94
|
-
if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
|
|
95
|
-
return true;
|
|
96
|
-
}
|
|
97
|
-
if (!valueA || !valueB) {
|
|
98
|
-
return false;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return !!(
|
|
102
|
-
isValueObject(valueA) &&
|
|
103
|
-
isValueObject(valueB) &&
|
|
104
|
-
valueA.equals(valueB)
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export { is };
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* MIT License
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) 2014-present, Lee Byron and other contributors.
|
|
6
|
-
*
|
|
7
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
* in the Software without restriction, including without limitation the rights
|
|
10
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
* furnished to do so, subject to the following conditions:
|
|
13
|
-
*
|
|
14
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
* copies or substantial portions of the Software.
|
|
16
|
-
*
|
|
17
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
* SOFTWARE.
|
|
24
|
-
*/
|
|
25
|
-
function asImmutable() {
|
|
26
|
-
return this.__ensureOwner();
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export { asImmutable };
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* MIT License
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) 2014-present, Lee Byron and other contributors.
|
|
6
|
-
*
|
|
7
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
* in the Software without restriction, including without limitation the rights
|
|
10
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
* furnished to do so, subject to the following conditions:
|
|
13
|
-
*
|
|
14
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
* copies or substantial portions of the Software.
|
|
16
|
-
*
|
|
17
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
* SOFTWARE.
|
|
24
|
-
*/
|
|
25
|
-
import { OwnerID } from '../TrieUtils.js';
|
|
26
|
-
|
|
27
|
-
function asMutable() {
|
|
28
|
-
return this.__ownerID ? this : this.__ensureOwner(new OwnerID());
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export { asMutable };
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* MIT License
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) 2014-present, Lee Byron and other contributors.
|
|
6
|
-
*
|
|
7
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
* in the Software without restriction, including without limitation the rights
|
|
10
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
* furnished to do so, subject to the following conditions:
|
|
13
|
-
*
|
|
14
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
* copies or substantial portions of the Software.
|
|
16
|
-
*
|
|
17
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
* SOFTWARE.
|
|
24
|
-
*/
|
|
25
|
-
import { removeIn } from '../functional/removeIn.js';
|
|
26
|
-
|
|
27
|
-
function deleteIn(keyPath) {
|
|
28
|
-
return removeIn(this, keyPath);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export { deleteIn };
|
package/dist/es/methods/getIn.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* MIT License
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) 2014-present, Lee Byron and other contributors.
|
|
6
|
-
*
|
|
7
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
* in the Software without restriction, including without limitation the rights
|
|
10
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
* furnished to do so, subject to the following conditions:
|
|
13
|
-
*
|
|
14
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
* copies or substantial portions of the Software.
|
|
16
|
-
*
|
|
17
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
* SOFTWARE.
|
|
24
|
-
*/
|
|
25
|
-
import { getIn as getIn$1 } from '../functional/getIn.js';
|
|
26
|
-
|
|
27
|
-
function getIn(searchKeyPath, notSetValue) {
|
|
28
|
-
return getIn$1(this, searchKeyPath, notSetValue);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export { getIn };
|