immutable 4.3.3 → 5.0.0-beta.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/README.md +3 -3
- package/dist/es/Collection.js +74 -0
- package/dist/es/CollectionImpl.js +781 -0
- package/dist/es/Hash.js +259 -0
- package/dist/es/Immutable.js +73 -0
- package/dist/es/Iterator.js +105 -0
- package/dist/es/List.js +691 -0
- package/dist/es/Map.js +832 -0
- package/dist/es/Math.js +44 -0
- package/dist/es/Operations.js +952 -0
- package/dist/es/OrderedMap.js +194 -0
- package/dist/es/OrderedSet.js +90 -0
- package/dist/es/PairSorting.js +29 -0
- package/dist/es/Range.js +167 -0
- package/dist/es/Record.js +290 -0
- package/dist/es/Repeat.js +129 -0
- package/dist/es/Seq.js +396 -0
- package/dist/es/Set.js +277 -0
- package/dist/es/Stack.js +259 -0
- package/dist/es/TrieUtils.js +115 -0
- package/dist/es/fromJS.js +73 -0
- package/dist/es/functional/get.js +37 -0
- package/dist/es/functional/getIn.js +40 -0
- package/dist/es/functional/has.js +34 -0
- package/dist/es/functional/hasIn.js +31 -0
- package/dist/es/functional/merge.js +136 -0
- package/dist/es/functional/remove.js +55 -0
- package/dist/es/functional/removeIn.js +31 -0
- package/dist/es/functional/set.js +51 -0
- package/dist/es/functional/setIn.js +31 -0
- package/dist/es/functional/update.js +30 -0
- package/dist/es/functional/updateIn.js +93 -0
- package/dist/es/is.js +107 -0
- package/dist/es/methods/asImmutable.js +28 -0
- package/dist/es/methods/asMutable.js +30 -0
- package/dist/es/methods/deleteIn.js +30 -0
- package/dist/es/methods/getIn.js +30 -0
- package/dist/es/methods/hasIn.js +30 -0
- package/dist/es/methods/merge.js +78 -0
- package/dist/es/methods/mergeDeep.js +40 -0
- package/dist/es/methods/mergeDeepIn.js +36 -0
- package/dist/es/methods/mergeIn.js +35 -0
- package/dist/es/methods/setIn.js +30 -0
- package/dist/es/methods/toObject.js +35 -0
- package/dist/es/methods/update.js +32 -0
- package/dist/es/methods/updateIn.js +30 -0
- package/dist/es/methods/wasAltered.js +28 -0
- package/dist/es/methods/withMutations.js +30 -0
- package/dist/es/package.json.js +26 -0
- package/dist/es/predicates/isAssociative.js +31 -0
- package/dist/es/predicates/isCollection.js +30 -0
- package/dist/es/predicates/isImmutable.js +31 -0
- package/dist/es/predicates/isIndexed.js +30 -0
- package/dist/es/predicates/isKeyed.js +30 -0
- package/dist/es/predicates/isList.js +30 -0
- package/dist/es/predicates/isMap.js +30 -0
- package/dist/es/predicates/isOrdered.js +30 -0
- package/dist/es/predicates/isOrderedMap.js +31 -0
- package/dist/es/predicates/isOrderedSet.js +31 -0
- package/dist/es/predicates/isRecord.js +30 -0
- package/dist/es/predicates/isSeq.js +30 -0
- package/dist/es/predicates/isSet.js +30 -0
- package/dist/es/predicates/isStack.js +30 -0
- package/dist/es/predicates/isValueObject.js +32 -0
- package/dist/es/toJS.js +53 -0
- package/dist/es/utils/arrCopy.js +34 -0
- package/dist/es/utils/assertNotInfinite.js +33 -0
- package/dist/es/utils/coerceKeyPath.js +39 -0
- package/dist/es/utils/deepEqual.js +98 -0
- package/dist/es/utils/hasOwnProperty.js +26 -0
- package/dist/es/utils/invariant.js +28 -0
- package/dist/es/utils/isArrayLike.js +43 -0
- package/dist/es/utils/isDataStructure.js +38 -0
- package/dist/es/utils/isPlainObj.js +51 -0
- package/dist/es/utils/mixin.js +34 -0
- package/dist/es/utils/quoteString.js +32 -0
- package/dist/es/utils/shallowCopy.js +40 -0
- package/dist/immutable.d.ts +131 -14
- package/dist/immutable.js +1 -59
- package/dist/immutable.min.js +32 -32
- package/package.json +5 -3
- package/dist/immutable.es.js +0 -5965
|
@@ -0,0 +1,290 @@
|
|
|
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 { toJS } from './toJS.js';
|
|
25
|
+
import { KeyedCollection } from './Collection.js';
|
|
26
|
+
import { keyedSeqFromValue } from './Seq.js';
|
|
27
|
+
import { List } from './List.js';
|
|
28
|
+
import { ITERATE_ENTRIES, ITERATOR_SYMBOL } from './Iterator.js';
|
|
29
|
+
import { isRecord, IS_RECORD_SYMBOL } from './predicates/isRecord.js';
|
|
30
|
+
import { CollectionPrototype } from './CollectionImpl.js';
|
|
31
|
+
import { DELETE } from './TrieUtils.js';
|
|
32
|
+
import { getIn } from './methods/getIn.js';
|
|
33
|
+
import { setIn } from './methods/setIn.js';
|
|
34
|
+
import { deleteIn } from './methods/deleteIn.js';
|
|
35
|
+
import { update } from './methods/update.js';
|
|
36
|
+
import { updateIn } from './methods/updateIn.js';
|
|
37
|
+
import { merge, mergeWith } from './methods/merge.js';
|
|
38
|
+
import { mergeDeep, mergeDeepWith } from './methods/mergeDeep.js';
|
|
39
|
+
import { mergeIn } from './methods/mergeIn.js';
|
|
40
|
+
import { mergeDeepIn } from './methods/mergeDeepIn.js';
|
|
41
|
+
import { withMutations } from './methods/withMutations.js';
|
|
42
|
+
import { asMutable } from './methods/asMutable.js';
|
|
43
|
+
import { asImmutable } from './methods/asImmutable.js';
|
|
44
|
+
import invariant from './utils/invariant.js';
|
|
45
|
+
import quoteString from './utils/quoteString.js';
|
|
46
|
+
import { isImmutable } from './predicates/isImmutable.js';
|
|
47
|
+
|
|
48
|
+
function throwOnInvalidDefaultValues(defaultValues) {
|
|
49
|
+
if (isRecord(defaultValues)) {
|
|
50
|
+
throw new Error(
|
|
51
|
+
'Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.'
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (isImmutable(defaultValues)) {
|
|
56
|
+
throw new Error(
|
|
57
|
+
'Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.'
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (defaultValues === null || typeof defaultValues !== 'object') {
|
|
62
|
+
throw new Error(
|
|
63
|
+
'Can not call `Record` with a non-object as default values. Use a plain javascript object instead.'
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
var Record = function Record(defaultValues, name) {
|
|
69
|
+
var hasInitialized;
|
|
70
|
+
|
|
71
|
+
throwOnInvalidDefaultValues(defaultValues);
|
|
72
|
+
|
|
73
|
+
var RecordType = function Record(values) {
|
|
74
|
+
var this$1$1 = this;
|
|
75
|
+
|
|
76
|
+
if (values instanceof RecordType) {
|
|
77
|
+
return values;
|
|
78
|
+
}
|
|
79
|
+
if (!(this instanceof RecordType)) {
|
|
80
|
+
return new RecordType(values);
|
|
81
|
+
}
|
|
82
|
+
if (!hasInitialized) {
|
|
83
|
+
hasInitialized = true;
|
|
84
|
+
var keys = Object.keys(defaultValues);
|
|
85
|
+
var indices = (RecordTypePrototype._indices = {});
|
|
86
|
+
// Deprecated: left to attempt not to break any external code which
|
|
87
|
+
// relies on a ._name property existing on record instances.
|
|
88
|
+
// Use Record.getDescriptiveName() instead
|
|
89
|
+
RecordTypePrototype._name = name;
|
|
90
|
+
RecordTypePrototype._keys = keys;
|
|
91
|
+
RecordTypePrototype._defaultValues = defaultValues;
|
|
92
|
+
for (var i = 0; i < keys.length; i++) {
|
|
93
|
+
var propName = keys[i];
|
|
94
|
+
indices[propName] = i;
|
|
95
|
+
if (RecordTypePrototype[propName]) {
|
|
96
|
+
/* eslint-disable no-console */
|
|
97
|
+
typeof console === 'object' &&
|
|
98
|
+
console.warn &&
|
|
99
|
+
console.warn(
|
|
100
|
+
'Cannot define ' +
|
|
101
|
+
recordName(this) +
|
|
102
|
+
' with property "' +
|
|
103
|
+
propName +
|
|
104
|
+
'" since that property name is part of the Record API.'
|
|
105
|
+
);
|
|
106
|
+
/* eslint-enable no-console */
|
|
107
|
+
} else {
|
|
108
|
+
setProp(RecordTypePrototype, propName);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
this.__ownerID = undefined;
|
|
113
|
+
this._values = List().withMutations(function (l) {
|
|
114
|
+
l.setSize(this$1$1._keys.length);
|
|
115
|
+
KeyedCollection(values).forEach(function (v, k) {
|
|
116
|
+
l.set(this$1$1._indices[k], v === this$1$1._defaultValues[k] ? undefined : v);
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
return this;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
var RecordTypePrototype = (RecordType.prototype =
|
|
123
|
+
Object.create(RecordPrototype));
|
|
124
|
+
RecordTypePrototype.constructor = RecordType;
|
|
125
|
+
|
|
126
|
+
if (name) {
|
|
127
|
+
RecordType.displayName = name;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return RecordType;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
Record.prototype.toString = function toString () {
|
|
134
|
+
var str = recordName(this) + ' { ';
|
|
135
|
+
var keys = this._keys;
|
|
136
|
+
var k;
|
|
137
|
+
for (var i = 0, l = keys.length; i !== l; i++) {
|
|
138
|
+
k = keys[i];
|
|
139
|
+
str += (i ? ', ' : '') + k + ': ' + quoteString(this.get(k));
|
|
140
|
+
}
|
|
141
|
+
return str + ' }';
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
Record.prototype.equals = function equals (other) {
|
|
145
|
+
return (
|
|
146
|
+
this === other ||
|
|
147
|
+
(isRecord(other) && recordSeq(this).equals(recordSeq(other)))
|
|
148
|
+
);
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
Record.prototype.hashCode = function hashCode () {
|
|
152
|
+
return recordSeq(this).hashCode();
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
// @pragma Access
|
|
156
|
+
|
|
157
|
+
Record.prototype.has = function has (k) {
|
|
158
|
+
return this._indices.hasOwnProperty(k);
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
Record.prototype.get = function get (k, notSetValue) {
|
|
162
|
+
if (!this.has(k)) {
|
|
163
|
+
return notSetValue;
|
|
164
|
+
}
|
|
165
|
+
var index = this._indices[k];
|
|
166
|
+
var value = this._values.get(index);
|
|
167
|
+
return value === undefined ? this._defaultValues[k] : value;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
// @pragma Modification
|
|
171
|
+
|
|
172
|
+
Record.prototype.set = function set (k, v) {
|
|
173
|
+
if (this.has(k)) {
|
|
174
|
+
var newValues = this._values.set(
|
|
175
|
+
this._indices[k],
|
|
176
|
+
v === this._defaultValues[k] ? undefined : v
|
|
177
|
+
);
|
|
178
|
+
if (newValues !== this._values && !this.__ownerID) {
|
|
179
|
+
return makeRecord(this, newValues);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return this;
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
Record.prototype.remove = function remove (k) {
|
|
186
|
+
return this.set(k);
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
Record.prototype.clear = function clear () {
|
|
190
|
+
var newValues = this._values.clear().setSize(this._keys.length);
|
|
191
|
+
|
|
192
|
+
return this.__ownerID ? this : makeRecord(this, newValues);
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
Record.prototype.wasAltered = function wasAltered () {
|
|
196
|
+
return this._values.wasAltered();
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
Record.prototype.toSeq = function toSeq () {
|
|
200
|
+
return recordSeq(this);
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
Record.prototype.toJS = function toJS$1 () {
|
|
204
|
+
return toJS(this);
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
Record.prototype.entries = function entries () {
|
|
208
|
+
return this.__iterator(ITERATE_ENTRIES);
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
Record.prototype.__iterator = function __iterator (type, reverse) {
|
|
212
|
+
return recordSeq(this).__iterator(type, reverse);
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
Record.prototype.__iterate = function __iterate (fn, reverse) {
|
|
216
|
+
return recordSeq(this).__iterate(fn, reverse);
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
Record.prototype.__ensureOwner = function __ensureOwner (ownerID) {
|
|
220
|
+
if (ownerID === this.__ownerID) {
|
|
221
|
+
return this;
|
|
222
|
+
}
|
|
223
|
+
var newValues = this._values.__ensureOwner(ownerID);
|
|
224
|
+
if (!ownerID) {
|
|
225
|
+
this.__ownerID = ownerID;
|
|
226
|
+
this._values = newValues;
|
|
227
|
+
return this;
|
|
228
|
+
}
|
|
229
|
+
return makeRecord(this, newValues, ownerID);
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
Record.isRecord = isRecord;
|
|
233
|
+
Record.getDescriptiveName = recordName;
|
|
234
|
+
var RecordPrototype = Record.prototype;
|
|
235
|
+
RecordPrototype[IS_RECORD_SYMBOL] = true;
|
|
236
|
+
RecordPrototype[DELETE] = RecordPrototype.remove;
|
|
237
|
+
RecordPrototype.deleteIn = RecordPrototype.removeIn = deleteIn;
|
|
238
|
+
RecordPrototype.getIn = getIn;
|
|
239
|
+
RecordPrototype.hasIn = CollectionPrototype.hasIn;
|
|
240
|
+
RecordPrototype.merge = merge;
|
|
241
|
+
RecordPrototype.mergeWith = mergeWith;
|
|
242
|
+
RecordPrototype.mergeIn = mergeIn;
|
|
243
|
+
RecordPrototype.mergeDeep = mergeDeep;
|
|
244
|
+
RecordPrototype.mergeDeepWith = mergeDeepWith;
|
|
245
|
+
RecordPrototype.mergeDeepIn = mergeDeepIn;
|
|
246
|
+
RecordPrototype.setIn = setIn;
|
|
247
|
+
RecordPrototype.update = update;
|
|
248
|
+
RecordPrototype.updateIn = updateIn;
|
|
249
|
+
RecordPrototype.withMutations = withMutations;
|
|
250
|
+
RecordPrototype.asMutable = asMutable;
|
|
251
|
+
RecordPrototype.asImmutable = asImmutable;
|
|
252
|
+
RecordPrototype[ITERATOR_SYMBOL] = RecordPrototype.entries;
|
|
253
|
+
RecordPrototype.toJSON = RecordPrototype.toObject =
|
|
254
|
+
CollectionPrototype.toObject;
|
|
255
|
+
RecordPrototype.inspect = RecordPrototype.toSource = function () {
|
|
256
|
+
return this.toString();
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
function makeRecord(likeRecord, values, ownerID) {
|
|
260
|
+
var record = Object.create(Object.getPrototypeOf(likeRecord));
|
|
261
|
+
record._values = values;
|
|
262
|
+
record.__ownerID = ownerID;
|
|
263
|
+
return record;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
function recordName(record) {
|
|
267
|
+
return record.constructor.displayName || record.constructor.name || 'Record';
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function recordSeq(record) {
|
|
271
|
+
return keyedSeqFromValue(record._keys.map(function (k) { return [k, record.get(k)]; }));
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function setProp(prototype, name) {
|
|
275
|
+
try {
|
|
276
|
+
Object.defineProperty(prototype, name, {
|
|
277
|
+
get: function () {
|
|
278
|
+
return this.get(name);
|
|
279
|
+
},
|
|
280
|
+
set: function (value) {
|
|
281
|
+
invariant(this.__ownerID, 'Cannot set on an immutable record.');
|
|
282
|
+
this.set(name, value);
|
|
283
|
+
},
|
|
284
|
+
});
|
|
285
|
+
} catch (error) {
|
|
286
|
+
// Object.defineProperty failed. Probably IE8.
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
export { Record };
|
|
@@ -0,0 +1,129 @@
|
|
|
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 { wholeSlice, resolveEnd, resolveBegin } from './TrieUtils.js';
|
|
25
|
+
import { IndexedSeq } from './Seq.js';
|
|
26
|
+
import { is } from './is.js';
|
|
27
|
+
import { Iterator, iteratorDone, iteratorValue } from './Iterator.js';
|
|
28
|
+
import deepEqual from './utils/deepEqual.js';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Returns a lazy Seq of `value` repeated `times` times. When `times` is
|
|
32
|
+
* undefined, returns an infinite sequence of `value`.
|
|
33
|
+
*/
|
|
34
|
+
var Repeat = /*@__PURE__*/(function (IndexedSeq) {
|
|
35
|
+
function Repeat(value, times) {
|
|
36
|
+
if (!(this instanceof Repeat)) {
|
|
37
|
+
return new Repeat(value, times);
|
|
38
|
+
}
|
|
39
|
+
this._value = value;
|
|
40
|
+
this.size = times === undefined ? Infinity : Math.max(0, times);
|
|
41
|
+
if (this.size === 0) {
|
|
42
|
+
if (EMPTY_REPEAT) {
|
|
43
|
+
return EMPTY_REPEAT;
|
|
44
|
+
}
|
|
45
|
+
EMPTY_REPEAT = this;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if ( IndexedSeq ) Repeat.__proto__ = IndexedSeq;
|
|
50
|
+
Repeat.prototype = Object.create( IndexedSeq && IndexedSeq.prototype );
|
|
51
|
+
Repeat.prototype.constructor = Repeat;
|
|
52
|
+
|
|
53
|
+
Repeat.prototype.toString = function toString () {
|
|
54
|
+
if (this.size === 0) {
|
|
55
|
+
return 'Repeat []';
|
|
56
|
+
}
|
|
57
|
+
return 'Repeat [ ' + this._value + ' ' + this.size + ' times ]';
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
Repeat.prototype.get = function get (index, notSetValue) {
|
|
61
|
+
return this.has(index) ? this._value : notSetValue;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
Repeat.prototype.includes = function includes (searchValue) {
|
|
65
|
+
return is(this._value, searchValue);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
Repeat.prototype.slice = function slice (begin, end) {
|
|
69
|
+
var size = this.size;
|
|
70
|
+
return wholeSlice(begin, end, size)
|
|
71
|
+
? this
|
|
72
|
+
: new Repeat(
|
|
73
|
+
this._value,
|
|
74
|
+
resolveEnd(end, size) - resolveBegin(begin, size)
|
|
75
|
+
);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
Repeat.prototype.reverse = function reverse () {
|
|
79
|
+
return this;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
Repeat.prototype.indexOf = function indexOf (searchValue) {
|
|
83
|
+
if (is(this._value, searchValue)) {
|
|
84
|
+
return 0;
|
|
85
|
+
}
|
|
86
|
+
return -1;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
Repeat.prototype.lastIndexOf = function lastIndexOf (searchValue) {
|
|
90
|
+
if (is(this._value, searchValue)) {
|
|
91
|
+
return this.size;
|
|
92
|
+
}
|
|
93
|
+
return -1;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
Repeat.prototype.__iterate = function __iterate (fn, reverse) {
|
|
97
|
+
var size = this.size;
|
|
98
|
+
var i = 0;
|
|
99
|
+
while (i !== size) {
|
|
100
|
+
if (fn(this._value, reverse ? size - ++i : i++, this) === false) {
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return i;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
Repeat.prototype.__iterator = function __iterator (type, reverse) {
|
|
108
|
+
var this$1$1 = this;
|
|
109
|
+
|
|
110
|
+
var size = this.size;
|
|
111
|
+
var i = 0;
|
|
112
|
+
return new Iterator(function () { return i === size
|
|
113
|
+
? iteratorDone()
|
|
114
|
+
: iteratorValue(type, reverse ? size - ++i : i++, this$1$1._value); }
|
|
115
|
+
);
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
Repeat.prototype.equals = function equals (other) {
|
|
119
|
+
return other instanceof Repeat
|
|
120
|
+
? is(this._value, other._value)
|
|
121
|
+
: deepEqual(other);
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
return Repeat;
|
|
125
|
+
}(IndexedSeq));
|
|
126
|
+
|
|
127
|
+
var EMPTY_REPEAT;
|
|
128
|
+
|
|
129
|
+
export { Repeat };
|