immutable 5.0.0-beta.2 → 5.0.0-beta.3

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