immutable 5.0.0-beta.1 → 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 +29 -134
  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
package/dist/es/Stack.js DELETED
@@ -1,259 +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 { wrapIndex, wholeSlice, resolveBegin, resolveEnd } from './TrieUtils.js';
25
- import { IndexedCollection } from './Collection.js';
26
- import { ArraySeq } from './Seq.js';
27
- import { Iterator, iteratorValue, iteratorDone } from './Iterator.js';
28
- import { isStack, IS_STACK_SYMBOL } from './predicates/isStack.js';
29
- import assertNotInfinite from './utils/assertNotInfinite.js';
30
- import { asImmutable } from './methods/asImmutable.js';
31
- import { asMutable } from './methods/asMutable.js';
32
- import { wasAltered } from './methods/wasAltered.js';
33
- import { withMutations } from './methods/withMutations.js';
34
-
35
- var Stack = /*@__PURE__*/(function (IndexedCollection) {
36
- function Stack(value) {
37
- return value === undefined || value === null
38
- ? emptyStack()
39
- : isStack(value)
40
- ? value
41
- : emptyStack().pushAll(value);
42
- }
43
-
44
- if ( IndexedCollection ) Stack.__proto__ = IndexedCollection;
45
- Stack.prototype = Object.create( IndexedCollection && IndexedCollection.prototype );
46
- Stack.prototype.constructor = Stack;
47
-
48
- Stack.of = function of (/*...values*/) {
49
- return this(arguments);
50
- };
51
-
52
- Stack.prototype.toString = function toString () {
53
- return this.__toString('Stack [', ']');
54
- };
55
-
56
- // @pragma Access
57
-
58
- Stack.prototype.get = function get (index, notSetValue) {
59
- var head = this._head;
60
- index = wrapIndex(this, index);
61
- while (head && index--) {
62
- head = head.next;
63
- }
64
- return head ? head.value : notSetValue;
65
- };
66
-
67
- Stack.prototype.peek = function peek () {
68
- return this._head && this._head.value;
69
- };
70
-
71
- // @pragma Modification
72
-
73
- Stack.prototype.push = function push (/*...values*/) {
74
- var arguments$1 = arguments;
75
-
76
- if (arguments.length === 0) {
77
- return this;
78
- }
79
- var newSize = this.size + arguments.length;
80
- var head = this._head;
81
- for (var ii = arguments.length - 1; ii >= 0; ii--) {
82
- head = {
83
- value: arguments$1[ii],
84
- next: head,
85
- };
86
- }
87
- if (this.__ownerID) {
88
- this.size = newSize;
89
- this._head = head;
90
- this.__hash = undefined;
91
- this.__altered = true;
92
- return this;
93
- }
94
- return makeStack(newSize, head);
95
- };
96
-
97
- Stack.prototype.pushAll = function pushAll (iter) {
98
- iter = IndexedCollection(iter);
99
- if (iter.size === 0) {
100
- return this;
101
- }
102
- if (this.size === 0 && isStack(iter)) {
103
- return iter;
104
- }
105
- assertNotInfinite(iter.size);
106
- var newSize = this.size;
107
- var head = this._head;
108
- iter.__iterate(function (value) {
109
- newSize++;
110
- head = {
111
- value: value,
112
- next: head,
113
- };
114
- }, /* reverse */ true);
115
- if (this.__ownerID) {
116
- this.size = newSize;
117
- this._head = head;
118
- this.__hash = undefined;
119
- this.__altered = true;
120
- return this;
121
- }
122
- return makeStack(newSize, head);
123
- };
124
-
125
- Stack.prototype.pop = function pop () {
126
- return this.slice(1);
127
- };
128
-
129
- Stack.prototype.clear = function clear () {
130
- if (this.size === 0) {
131
- return this;
132
- }
133
- if (this.__ownerID) {
134
- this.size = 0;
135
- this._head = undefined;
136
- this.__hash = undefined;
137
- this.__altered = true;
138
- return this;
139
- }
140
- return emptyStack();
141
- };
142
-
143
- Stack.prototype.slice = function slice (begin, end) {
144
- if (wholeSlice(begin, end, this.size)) {
145
- return this;
146
- }
147
- var resolvedBegin = resolveBegin(begin, this.size);
148
- var resolvedEnd = resolveEnd(end, this.size);
149
- if (resolvedEnd !== this.size) {
150
- // super.slice(begin, end);
151
- return IndexedCollection.prototype.slice.call(this, begin, end);
152
- }
153
- var newSize = this.size - resolvedBegin;
154
- var head = this._head;
155
- while (resolvedBegin--) {
156
- head = head.next;
157
- }
158
- if (this.__ownerID) {
159
- this.size = newSize;
160
- this._head = head;
161
- this.__hash = undefined;
162
- this.__altered = true;
163
- return this;
164
- }
165
- return makeStack(newSize, head);
166
- };
167
-
168
- // @pragma Mutability
169
-
170
- Stack.prototype.__ensureOwner = function __ensureOwner (ownerID) {
171
- if (ownerID === this.__ownerID) {
172
- return this;
173
- }
174
- if (!ownerID) {
175
- if (this.size === 0) {
176
- return emptyStack();
177
- }
178
- this.__ownerID = ownerID;
179
- this.__altered = false;
180
- return this;
181
- }
182
- return makeStack(this.size, this._head, ownerID, this.__hash);
183
- };
184
-
185
- // @pragma Iteration
186
-
187
- Stack.prototype.__iterate = function __iterate (fn, reverse) {
188
- var this$1$1 = this;
189
-
190
- if (reverse) {
191
- return new ArraySeq(this.toArray()).__iterate(
192
- function (v, k) { return fn(v, k, this$1$1); },
193
- reverse
194
- );
195
- }
196
- var iterations = 0;
197
- var node = this._head;
198
- while (node) {
199
- if (fn(node.value, iterations++, this) === false) {
200
- break;
201
- }
202
- node = node.next;
203
- }
204
- return iterations;
205
- };
206
-
207
- Stack.prototype.__iterator = function __iterator (type, reverse) {
208
- if (reverse) {
209
- return new ArraySeq(this.toArray()).__iterator(type, reverse);
210
- }
211
- var iterations = 0;
212
- var node = this._head;
213
- return new Iterator(function () {
214
- if (node) {
215
- var value = node.value;
216
- node = node.next;
217
- return iteratorValue(type, iterations++, value);
218
- }
219
- return iteratorDone();
220
- });
221
- };
222
-
223
- return Stack;
224
- }(IndexedCollection));
225
-
226
- Stack.isStack = isStack;
227
-
228
- var StackPrototype = Stack.prototype;
229
- StackPrototype[IS_STACK_SYMBOL] = true;
230
- StackPrototype.shift = StackPrototype.pop;
231
- StackPrototype.unshift = StackPrototype.push;
232
- StackPrototype.unshiftAll = StackPrototype.pushAll;
233
- StackPrototype.withMutations = withMutations;
234
- StackPrototype.wasAltered = wasAltered;
235
- StackPrototype.asImmutable = asImmutable;
236
- StackPrototype['@@transducer/init'] = StackPrototype.asMutable = asMutable;
237
- StackPrototype['@@transducer/step'] = function (result, arr) {
238
- return result.unshift(arr);
239
- };
240
- StackPrototype['@@transducer/result'] = function (obj) {
241
- return obj.asImmutable();
242
- };
243
-
244
- function makeStack(size, head, ownerID, hash) {
245
- var map = Object.create(StackPrototype);
246
- map.size = size;
247
- map._head = head;
248
- map.__ownerID = ownerID;
249
- map.__hash = hash;
250
- map.__altered = false;
251
- return map;
252
- }
253
-
254
- var EMPTY_STACK;
255
- function emptyStack() {
256
- return EMPTY_STACK || (EMPTY_STACK = makeStack(0));
257
- }
258
-
259
- export { Stack };
@@ -1,115 +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
- var DELETE = 'delete';
25
-
26
- // Constants describing the size of trie nodes.
27
- var SHIFT = 5; // Resulted in best performance after ______?
28
- var SIZE = 1 << SHIFT;
29
- var MASK = SIZE - 1;
30
-
31
- // A consistent shared value representing "not set" which equals nothing other
32
- // than itself, and nothing that could be provided externally.
33
- var NOT_SET = {};
34
-
35
- // Boolean references, Rough equivalent of `bool &`.
36
- function MakeRef() {
37
- return { value: false };
38
- }
39
-
40
- function SetRef(ref) {
41
- if (ref) {
42
- ref.value = true;
43
- }
44
- }
45
-
46
- // A function which returns a value representing an "owner" for transient writes
47
- // to tries. The return value will only ever equal itself, and will not equal
48
- // the return of any subsequent call of this function.
49
- function OwnerID() {}
50
-
51
- function ensureSize(iter) {
52
- if (iter.size === undefined) {
53
- iter.size = iter.__iterate(returnTrue);
54
- }
55
- return iter.size;
56
- }
57
-
58
- function wrapIndex(iter, index) {
59
- // This implements "is array index" which the ECMAString spec defines as:
60
- //
61
- // A String property name P is an array index if and only if
62
- // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal
63
- // to 2^32−1.
64
- //
65
- // http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects
66
- if (typeof index !== 'number') {
67
- var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32
68
- if ('' + uint32Index !== index || uint32Index === 4294967295) {
69
- return NaN;
70
- }
71
- index = uint32Index;
72
- }
73
- return index < 0 ? ensureSize(iter) + index : index;
74
- }
75
-
76
- function returnTrue() {
77
- return true;
78
- }
79
-
80
- function wholeSlice(begin, end, size) {
81
- return (
82
- ((begin === 0 && !isNeg(begin)) ||
83
- (size !== undefined && begin <= -size)) &&
84
- (end === undefined || (size !== undefined && end >= size))
85
- );
86
- }
87
-
88
- function resolveBegin(begin, size) {
89
- return resolveIndex(begin, size, 0);
90
- }
91
-
92
- function resolveEnd(end, size) {
93
- return resolveIndex(end, size, size);
94
- }
95
-
96
- function resolveIndex(index, size, defaultIndex) {
97
- // Sanitize indices using this shorthand for ToInt32(argument)
98
- // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
99
- return index === undefined
100
- ? defaultIndex
101
- : isNeg(index)
102
- ? size === Infinity
103
- ? size
104
- : Math.max(0, size + index) | 0
105
- : size === undefined || size === index
106
- ? index
107
- : Math.min(size, index) | 0;
108
- }
109
-
110
- function isNeg(value) {
111
- // Account for -0 which is negative, but not less than 0.
112
- return value < 0 || (value === 0 && 1 / value === -Infinity);
113
- }
114
-
115
- export { DELETE, MASK, MakeRef, NOT_SET, OwnerID, SHIFT, SIZE, SetRef, ensureSize, resolveBegin, resolveEnd, returnTrue, wholeSlice, wrapIndex };
package/dist/es/fromJS.js DELETED
@@ -1,73 +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 { Seq } from './Seq.js';
25
- import { hasIterator } from './Iterator.js';
26
- import { isImmutable } from './predicates/isImmutable.js';
27
- import { isIndexed } from './predicates/isIndexed.js';
28
- import { isKeyed } from './predicates/isKeyed.js';
29
- import isArrayLike from './utils/isArrayLike.js';
30
- import isPlainObject from './utils/isPlainObj.js';
31
-
32
- function fromJS(value, converter) {
33
- return fromJSWith(
34
- [],
35
- converter || defaultConverter,
36
- value,
37
- '',
38
- converter && converter.length > 2 ? [] : undefined,
39
- { '': value }
40
- );
41
- }
42
-
43
- function fromJSWith(stack, converter, value, key, keyPath, parentValue) {
44
- if (
45
- typeof value !== 'string' &&
46
- !isImmutable(value) &&
47
- (isArrayLike(value) || hasIterator(value) || isPlainObject(value))
48
- ) {
49
- if (~stack.indexOf(value)) {
50
- throw new TypeError('Cannot convert circular structure to Immutable');
51
- }
52
- stack.push(value);
53
- keyPath && key !== '' && keyPath.push(key);
54
- var converted = converter.call(
55
- parentValue,
56
- key,
57
- Seq(value).map(function (v, k) { return fromJSWith(stack, converter, v, k, keyPath, value); }
58
- ),
59
- keyPath && keyPath.slice()
60
- );
61
- stack.pop();
62
- keyPath && keyPath.pop();
63
- return converted;
64
- }
65
- return value;
66
- }
67
-
68
- function defaultConverter(k, v) {
69
- // Effectively the opposite of "Collection.toSeq()"
70
- return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet();
71
- }
72
-
73
- export { fromJS };
@@ -1,37 +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 { has } from './has.js';
26
-
27
- function get(collection, key, notSetValue) {
28
- return isImmutable(collection)
29
- ? collection.get(key, notSetValue)
30
- : !has(collection, key)
31
- ? notSetValue
32
- : typeof collection.get === 'function'
33
- ? collection.get(key)
34
- : collection[key];
35
- }
36
-
37
- export { get };
@@ -1,40 +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 coerceKeyPath from '../utils/coerceKeyPath.js';
25
- import { NOT_SET } from '../TrieUtils.js';
26
- import { get } from './get.js';
27
-
28
- function getIn(collection, searchKeyPath, notSetValue) {
29
- var keyPath = coerceKeyPath(searchKeyPath);
30
- var i = 0;
31
- while (i !== keyPath.length) {
32
- collection = get(collection, keyPath[i++], NOT_SET);
33
- if (collection === NOT_SET) {
34
- return notSetValue;
35
- }
36
- }
37
- return collection;
38
- }
39
-
40
- export { getIn };
@@ -1,34 +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
-
28
- function has(collection, key) {
29
- return isImmutable(collection)
30
- ? collection.has(key)
31
- : isDataStructure(collection) && hasOwnProperty.call(collection, key);
32
- }
33
-
34
- export { has };
@@ -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 { getIn } from './getIn.js';
25
- import { NOT_SET } from '../TrieUtils.js';
26
-
27
- function hasIn(collection, keyPath) {
28
- return getIn(collection, keyPath, NOT_SET) !== NOT_SET;
29
- }
30
-
31
- export { hasIn };