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