immutable 4.0.0-rc.8 → 4.0.0-rc.9
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 +1 -1
- package/dist/immutable-nonambient.d.ts +464 -466
- package/dist/immutable.d.ts +464 -466
- package/dist/immutable.es.js +1 -1
- package/dist/immutable.js +1 -1
- package/dist/immutable.js.flow +49 -39
- package/dist/immutable.min.js +1 -1
- package/package.json +1 -1
|
@@ -99,287 +99,6 @@
|
|
|
99
99
|
|
|
100
100
|
|
|
101
101
|
|
|
102
|
-
/**
|
|
103
|
-
* Deeply converts plain JS objects and arrays to Immutable Maps and Lists.
|
|
104
|
-
*
|
|
105
|
-
* If a `reviver` is optionally provided, it will be called with every
|
|
106
|
-
* collection as a Seq (beginning with the most nested collections
|
|
107
|
-
* and proceeding to the top-level collection itself), along with the key
|
|
108
|
-
* refering to each collection and the parent JS object provided as `this`.
|
|
109
|
-
* For the top level, object, the key will be `""`. This `reviver` is expected
|
|
110
|
-
* to return a new Immutable Collection, allowing for custom conversions from
|
|
111
|
-
* deep JS objects. Finally, a `path` is provided which is the sequence of
|
|
112
|
-
* keys to this value from the starting value.
|
|
113
|
-
*
|
|
114
|
-
* `reviver` acts similarly to the [same parameter in `JSON.parse`][1].
|
|
115
|
-
*
|
|
116
|
-
* If `reviver` is not provided, the default behavior will convert Objects
|
|
117
|
-
* into Maps and Arrays into Lists like so:
|
|
118
|
-
*
|
|
119
|
-
* <!-- runkit:activate -->
|
|
120
|
-
* ```js
|
|
121
|
-
* const { fromJS, isKeyed } = require('immutable@4.0.0-rc.8')
|
|
122
|
-
* function (key, value) {
|
|
123
|
-
* return isKeyed(value) ? value.Map() : value.toList()
|
|
124
|
-
* }
|
|
125
|
-
* ```
|
|
126
|
-
*
|
|
127
|
-
* `fromJS` is conservative in its conversion. It will only convert
|
|
128
|
-
* arrays which pass `Array.isArray` to Lists, and only raw objects (no custom
|
|
129
|
-
* prototype) to Map.
|
|
130
|
-
*
|
|
131
|
-
* Accordingly, this example converts native JS data to OrderedMap and List:
|
|
132
|
-
*
|
|
133
|
-
* <!-- runkit:activate -->
|
|
134
|
-
* ```js
|
|
135
|
-
* const { fromJS, isKeyed } = require('immutable@4.0.0-rc.8')
|
|
136
|
-
* fromJS({ a: {b: [10, 20, 30]}, c: 40}, function (key, value, path) {
|
|
137
|
-
* console.log(key, value, path)
|
|
138
|
-
* return isKeyed(value) ? value.toOrderedMap() : value.toList()
|
|
139
|
-
* })
|
|
140
|
-
*
|
|
141
|
-
* > "b", [ 10, 20, 30 ], [ "a", "b" ]
|
|
142
|
-
* > "a", {b: [10, 20, 30]}, [ "a" ]
|
|
143
|
-
* > "", {a: {b: [10, 20, 30]}, c: 40}, []
|
|
144
|
-
* ```
|
|
145
|
-
*
|
|
146
|
-
* Keep in mind, when using JS objects to construct Immutable Maps, that
|
|
147
|
-
* JavaScript Object properties are always strings, even if written in a
|
|
148
|
-
* quote-less shorthand, while Immutable Maps accept keys of any type.
|
|
149
|
-
*
|
|
150
|
-
* <!-- runkit:activate -->
|
|
151
|
-
* ```js
|
|
152
|
-
* const { Map } = require('immutable@4.0.0-rc.8')
|
|
153
|
-
* let obj = { 1: "one" };
|
|
154
|
-
* Object.keys(obj); // [ "1" ]
|
|
155
|
-
* assert.equal(obj["1"], obj[1]); // "one" === "one"
|
|
156
|
-
*
|
|
157
|
-
* let map = Map(obj);
|
|
158
|
-
* assert.notEqual(map.get("1"), map.get(1)); // "one" !== undefined
|
|
159
|
-
* ```
|
|
160
|
-
*
|
|
161
|
-
* Property access for JavaScript Objects first converts the key to a string,
|
|
162
|
-
* but since Immutable Map keys can be of any type the argument to `get()` is
|
|
163
|
-
* not altered.
|
|
164
|
-
*
|
|
165
|
-
* [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Example.3A_Using_the_reviver_parameter
|
|
166
|
-
* "Using the reviver parameter"
|
|
167
|
-
*/
|
|
168
|
-
export function fromJS(
|
|
169
|
-
jsValue: any,
|
|
170
|
-
reviver?: (
|
|
171
|
-
key: string | number,
|
|
172
|
-
sequence: Collection.Keyed<string, any> | Collection.Indexed<any>,
|
|
173
|
-
path?: Array<string | number>
|
|
174
|
-
) => any
|
|
175
|
-
): any;
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Value equality check with semantics similar to `Object.is`, but treats
|
|
180
|
-
* Immutable `Collection`s as values, equal if the second `Collection` includes
|
|
181
|
-
* equivalent values.
|
|
182
|
-
*
|
|
183
|
-
* It's used throughout Immutable when checking for equality, including `Map`
|
|
184
|
-
* key equality and `Set` membership.
|
|
185
|
-
*
|
|
186
|
-
* <!-- runkit:activate -->
|
|
187
|
-
* ```js
|
|
188
|
-
* const { Map, is } = require('immutable@4.0.0-rc.8')
|
|
189
|
-
* const map1 = Map({ a: 1, b: 1, c: 1 })
|
|
190
|
-
* const map2 = Map({ a: 1, b: 1, c: 1 })
|
|
191
|
-
* assert.equal(map1 !== map2, true)
|
|
192
|
-
* assert.equal(Object.is(map1, map2), false)
|
|
193
|
-
* assert.equal(is(map1, map2), true)
|
|
194
|
-
* ```
|
|
195
|
-
*
|
|
196
|
-
* `is()` compares primitive types like strings and numbers, Immutable.js
|
|
197
|
-
* collections like `Map` and `List`, but also any custom object which
|
|
198
|
-
* implements `ValueObject` by providing `equals()` and `hashCode()` methods.
|
|
199
|
-
*
|
|
200
|
-
* Note: Unlike `Object.is`, `Immutable.is` assumes `0` and `-0` are the same
|
|
201
|
-
* value, matching the behavior of ES6 Map key equality.
|
|
202
|
-
*/
|
|
203
|
-
export function is(first: any, second: any): boolean;
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* The `hash()` function is an important part of how Immutable determines if
|
|
208
|
-
* two values are equivalent and is used to determine how to store those
|
|
209
|
-
* values. Provided with any value, `hash()` will return a 31-bit integer.
|
|
210
|
-
*
|
|
211
|
-
* When designing Objects which may be equal, it's important than when a
|
|
212
|
-
* `.equals()` method returns true, that both values `.hashCode()` method
|
|
213
|
-
* return the same value. `hash()` may be used to produce those values.
|
|
214
|
-
*
|
|
215
|
-
* For non-Immutable Objects that do not provide a `.hashCode()` functions
|
|
216
|
-
* (including plain Objects, plain Arrays, Date objects, etc), a unique hash
|
|
217
|
-
* value will be created for each *instance*. That is, the create hash
|
|
218
|
-
* represents referential equality, and not value equality for Objects. This
|
|
219
|
-
* ensures that if that Object is mutated over time that its hash code will
|
|
220
|
-
* remain consistent, allowing Objects to be used as keys and values in
|
|
221
|
-
* Immutable.js collections.
|
|
222
|
-
*
|
|
223
|
-
* Note that `hash()` attempts to balance between speed and avoiding
|
|
224
|
-
* collisions, however it makes no attempt to produce secure hashes.
|
|
225
|
-
*
|
|
226
|
-
* *New in Version 4.0*
|
|
227
|
-
*/
|
|
228
|
-
export function hash(value: any): number;
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* True if `maybeImmutable` is an Immutable Collection or Record.
|
|
232
|
-
*
|
|
233
|
-
* Note: Still returns true even if the collections is within a `withMutations()`.
|
|
234
|
-
*
|
|
235
|
-
* <!-- runkit:activate -->
|
|
236
|
-
* ```js
|
|
237
|
-
* const { isImmutable, Map, List, Stack } = require('immutable@4.0.0-rc.8');
|
|
238
|
-
* isImmutable([]); // false
|
|
239
|
-
* isImmutable({}); // false
|
|
240
|
-
* isImmutable(Map()); // true
|
|
241
|
-
* isImmutable(List()); // true
|
|
242
|
-
* isImmutable(Stack()); // true
|
|
243
|
-
* isImmutable(Map().asMutable()); // true
|
|
244
|
-
* ```
|
|
245
|
-
*/
|
|
246
|
-
export function isImmutable(maybeImmutable: any): maybeImmutable is Collection<any, any>;
|
|
247
|
-
|
|
248
|
-
/**
|
|
249
|
-
* True if `maybeCollection` is a Collection, or any of its subclasses.
|
|
250
|
-
*
|
|
251
|
-
* <!-- runkit:activate -->
|
|
252
|
-
* ```js
|
|
253
|
-
* const { isCollection, Map, List, Stack } = require('immutable@4.0.0-rc.8');
|
|
254
|
-
* isCollection([]); // false
|
|
255
|
-
* isCollection({}); // false
|
|
256
|
-
* isCollection(Map()); // true
|
|
257
|
-
* isCollection(List()); // true
|
|
258
|
-
* isCollection(Stack()); // true
|
|
259
|
-
* ```
|
|
260
|
-
*/
|
|
261
|
-
export function isCollection(maybeCollection: any): maybeCollection is Collection<any, any>;
|
|
262
|
-
|
|
263
|
-
/**
|
|
264
|
-
* True if `maybeKeyed` is a Collection.Keyed, or any of its subclasses.
|
|
265
|
-
*
|
|
266
|
-
* <!-- runkit:activate -->
|
|
267
|
-
* ```js
|
|
268
|
-
* const { isKeyed, Map, List, Stack } = require('immutable@4.0.0-rc.8');
|
|
269
|
-
* isKeyed([]); // false
|
|
270
|
-
* isKeyed({}); // false
|
|
271
|
-
* isKeyed(Map()); // true
|
|
272
|
-
* isKeyed(List()); // false
|
|
273
|
-
* isKeyed(Stack()); // false
|
|
274
|
-
* ```
|
|
275
|
-
*/
|
|
276
|
-
export function isKeyed(maybeKeyed: any): maybeKeyed is Collection.Keyed<any, any>;
|
|
277
|
-
|
|
278
|
-
/**
|
|
279
|
-
* True if `maybeIndexed` is a Collection.Indexed, or any of its subclasses.
|
|
280
|
-
*
|
|
281
|
-
* <!-- runkit:activate -->
|
|
282
|
-
* ```js
|
|
283
|
-
* const { isIndexed, Map, List, Stack, Set } = require('immutable@4.0.0-rc.8');
|
|
284
|
-
* isIndexed([]); // false
|
|
285
|
-
* isIndexed({}); // false
|
|
286
|
-
* isIndexed(Map()); // false
|
|
287
|
-
* isIndexed(List()); // true
|
|
288
|
-
* isIndexed(Stack()); // true
|
|
289
|
-
* isIndexed(Set()); // false
|
|
290
|
-
* ```
|
|
291
|
-
*/
|
|
292
|
-
export function isIndexed(maybeIndexed: any): maybeIndexed is Collection.Indexed<any>;
|
|
293
|
-
|
|
294
|
-
/**
|
|
295
|
-
* True if `maybeAssociative` is either a Keyed or Indexed Collection.
|
|
296
|
-
*
|
|
297
|
-
* <!-- runkit:activate -->
|
|
298
|
-
* ```js
|
|
299
|
-
* const { isAssociative, Map, List, Stack, Set } = require('immutable@4.0.0-rc.8');
|
|
300
|
-
* isAssociative([]); // false
|
|
301
|
-
* isAssociative({}); // false
|
|
302
|
-
* isAssociative(Map()); // true
|
|
303
|
-
* isAssociative(List()); // true
|
|
304
|
-
* isAssociative(Stack()); // true
|
|
305
|
-
* isAssociative(Set()); // false
|
|
306
|
-
* ```
|
|
307
|
-
*/
|
|
308
|
-
export function isAssociative(maybeAssociative: any): maybeAssociative is Collection.Keyed<any, any> | Collection.Indexed<any>;
|
|
309
|
-
|
|
310
|
-
/**
|
|
311
|
-
* True if `maybeOrdered` is a Collection where iteration order is well
|
|
312
|
-
* defined. True for Collection.Indexed as well as OrderedMap and OrderedSet.
|
|
313
|
-
*
|
|
314
|
-
* <!-- runkit:activate -->
|
|
315
|
-
* ```js
|
|
316
|
-
* const { isOrdered, Map, OrderedMap, List, Set } = require('immutable@4.0.0-rc.8');
|
|
317
|
-
* isOrdered([]); // false
|
|
318
|
-
* isOrdered({}); // false
|
|
319
|
-
* isOrdered(Map()); // false
|
|
320
|
-
* isOrdered(OrderedMap()); // true
|
|
321
|
-
* isOrdered(List()); // true
|
|
322
|
-
* isOrdered(Set()); // false
|
|
323
|
-
* ```
|
|
324
|
-
*/
|
|
325
|
-
export function isOrdered(maybeOrdered: any): boolean;
|
|
326
|
-
|
|
327
|
-
/**
|
|
328
|
-
* True if `maybeValue` is a JavaScript Object which has *both* `equals()`
|
|
329
|
-
* and `hashCode()` methods.
|
|
330
|
-
*
|
|
331
|
-
* Any two instances of *value objects* can be compared for value equality with
|
|
332
|
-
* `Immutable.is()` and can be used as keys in a `Map` or members in a `Set`.
|
|
333
|
-
*/
|
|
334
|
-
export function isValueObject(maybeValue: any): maybeValue is ValueObject;
|
|
335
|
-
|
|
336
|
-
/**
|
|
337
|
-
* The interface to fulfill to qualify as a Value Object.
|
|
338
|
-
*/
|
|
339
|
-
export interface ValueObject {
|
|
340
|
-
/**
|
|
341
|
-
* True if this and the other Collection have value equality, as defined
|
|
342
|
-
* by `Immutable.is()`.
|
|
343
|
-
*
|
|
344
|
-
* Note: This is equivalent to `Immutable.is(this, other)`, but provided to
|
|
345
|
-
* allow for chained expressions.
|
|
346
|
-
*/
|
|
347
|
-
equals(other: any): boolean;
|
|
348
|
-
|
|
349
|
-
/**
|
|
350
|
-
* Computes and returns the hashed identity for this Collection.
|
|
351
|
-
*
|
|
352
|
-
* The `hashCode` of a Collection is used to determine potential equality,
|
|
353
|
-
* and is used when adding this to a `Set` or as a key in a `Map`, enabling
|
|
354
|
-
* lookup via a different instance.
|
|
355
|
-
*
|
|
356
|
-
* <!-- runkit:activate -->
|
|
357
|
-
* ```js
|
|
358
|
-
* const { List, Set } = require('immutable@4.0.0-rc.8');
|
|
359
|
-
* const a = List([ 1, 2, 3 ]);
|
|
360
|
-
* const b = List([ 1, 2, 3 ]);
|
|
361
|
-
* assert.notStrictEqual(a, b); // different instances
|
|
362
|
-
* const set = Set([ a ]);
|
|
363
|
-
* assert.equal(set.has(b), true);
|
|
364
|
-
* ```
|
|
365
|
-
*
|
|
366
|
-
* Note: hashCode() MUST return a Uint32 number. The easiest way to
|
|
367
|
-
* guarantee this is to return `myHash | 0` from a custom implementation.
|
|
368
|
-
*
|
|
369
|
-
* If two values have the same `hashCode`, they are [not guaranteed
|
|
370
|
-
* to be equal][Hash Collision]. If two values have different `hashCode`s,
|
|
371
|
-
* they must not be equal.
|
|
372
|
-
*
|
|
373
|
-
* Note: `hashCode()` is not guaranteed to always be called before
|
|
374
|
-
* `equals()`. Most but not all Immutable.js collections use hash codes to
|
|
375
|
-
* organize their internal data structures, while all Immutable.js
|
|
376
|
-
* collections use equality during lookups.
|
|
377
|
-
*
|
|
378
|
-
* [Hash Collision]: http://en.wikipedia.org/wiki/Collision_(computer_science)
|
|
379
|
-
*/
|
|
380
|
-
hashCode(): number;
|
|
381
|
-
}
|
|
382
|
-
|
|
383
102
|
/**
|
|
384
103
|
* Lists are ordered indexed dense collections, much like a JavaScript
|
|
385
104
|
* Array.
|
|
@@ -401,7 +120,7 @@
|
|
|
401
120
|
*
|
|
402
121
|
* <!-- runkit:activate -->
|
|
403
122
|
* ```js
|
|
404
|
-
* const { List } = require('immutable@4.0.0-rc.
|
|
123
|
+
* const { List } = require('immutable@4.0.0-rc.9');
|
|
405
124
|
* List.isList([]); // false
|
|
406
125
|
* List.isList(List()); // true
|
|
407
126
|
* ```
|
|
@@ -413,7 +132,7 @@
|
|
|
413
132
|
*
|
|
414
133
|
* <!-- runkit:activate -->
|
|
415
134
|
* ```js
|
|
416
|
-
* const { List } = require('immutable@4.0.0-rc.
|
|
135
|
+
* const { List } = require('immutable@4.0.0-rc.9');
|
|
417
136
|
* List.of(1, 2, 3, 4)
|
|
418
137
|
* // List [ 1, 2, 3, 4 ]
|
|
419
138
|
* ```
|
|
@@ -422,7 +141,7 @@
|
|
|
422
141
|
*
|
|
423
142
|
* <!-- runkit:activate -->
|
|
424
143
|
* ```js
|
|
425
|
-
* const { List } = require('immutable@4.0.0-rc.
|
|
144
|
+
* const { List } = require('immutable@4.0.0-rc.9');
|
|
426
145
|
* List.of({x:1}, 2, [3], 4)
|
|
427
146
|
* // List [ { x: 1 }, 2, [ 3 ], 4 ]
|
|
428
147
|
* ```
|
|
@@ -436,7 +155,7 @@
|
|
|
436
155
|
*
|
|
437
156
|
* <!-- runkit:activate -->
|
|
438
157
|
* ```js
|
|
439
|
-
* const { List, Set } = require('immutable@4.0.0-rc.
|
|
158
|
+
* const { List, Set } = require('immutable@4.0.0-rc.9')
|
|
440
159
|
*
|
|
441
160
|
* const emptyList = List()
|
|
442
161
|
* // List []
|
|
@@ -482,7 +201,7 @@
|
|
|
482
201
|
* enough to include the `index`.
|
|
483
202
|
*
|
|
484
203
|
* <!-- runkit:activate
|
|
485
|
-
* { "preamble": "const { List } = require('immutable@4.0.0-rc.
|
|
204
|
+
* { "preamble": "const { List } = require('immutable@4.0.0-rc.9');" }
|
|
486
205
|
* -->
|
|
487
206
|
* ```js
|
|
488
207
|
* const originalList = List([ 0 ]);
|
|
@@ -515,7 +234,7 @@
|
|
|
515
234
|
* Note: `delete` cannot be safely used in IE8
|
|
516
235
|
*
|
|
517
236
|
* <!-- runkit:activate
|
|
518
|
-
* { "preamble": "const { List } = require('immutable@4.0.0-rc.
|
|
237
|
+
* { "preamble": "const { List } = require('immutable@4.0.0-rc.9');" }
|
|
519
238
|
* -->
|
|
520
239
|
* ```js
|
|
521
240
|
* List([ 0, 1, 2, 3, 4 ]).delete(0);
|
|
@@ -539,7 +258,7 @@
|
|
|
539
258
|
* This is synonymous with `list.splice(index, 0, value)`.
|
|
540
259
|
*
|
|
541
260
|
* <!-- runkit:activate
|
|
542
|
-
* { "preamble": "const { List } = require('immutable@4.0.0-rc.
|
|
261
|
+
* { "preamble": "const { List } = require('immutable@4.0.0-rc.9');" }
|
|
543
262
|
* -->
|
|
544
263
|
* ```js
|
|
545
264
|
* List([ 0, 1, 2, 3, 4 ]).insert(6, 5)
|
|
@@ -557,7 +276,7 @@
|
|
|
557
276
|
* Returns a new List with 0 size and no values in constant time.
|
|
558
277
|
*
|
|
559
278
|
* <!-- runkit:activate
|
|
560
|
-
* { "preamble": "const { List } = require('immutable@4.0.0-rc.
|
|
279
|
+
* { "preamble": "const { List } = require('immutable@4.0.0-rc.9');" }
|
|
561
280
|
* -->
|
|
562
281
|
* ```js
|
|
563
282
|
* List([ 1, 2, 3, 4 ]).clear()
|
|
@@ -573,7 +292,7 @@
|
|
|
573
292
|
* List's `size`.
|
|
574
293
|
*
|
|
575
294
|
* <!-- runkit:activate
|
|
576
|
-
* { "preamble": "const { List } = require('immutable@4.0.0-rc.
|
|
295
|
+
* { "preamble": "const { List } = require('immutable@4.0.0-rc.9');" }
|
|
577
296
|
* -->
|
|
578
297
|
* ```js
|
|
579
298
|
* List([ 1, 2, 3, 4 ]).push(5)
|
|
@@ -606,7 +325,7 @@
|
|
|
606
325
|
* values ahead to higher indices.
|
|
607
326
|
*
|
|
608
327
|
* <!-- runkit:activate
|
|
609
|
-
* { "preamble": "const { List } = require('immutable@4.0.0-rc.
|
|
328
|
+
* { "preamble": "const { List } = require('immutable@4.0.0-rc.9');" }
|
|
610
329
|
* -->
|
|
611
330
|
* ```js
|
|
612
331
|
* List([ 2, 3, 4]).unshift(1);
|
|
@@ -626,7 +345,7 @@
|
|
|
626
345
|
* value in this List.
|
|
627
346
|
*
|
|
628
347
|
* <!-- runkit:activate
|
|
629
|
-
* { "preamble": "const { List } = require('immutable@4.0.0-rc.
|
|
348
|
+
* { "preamble": "const { List } = require('immutable@4.0.0-rc.9');" }
|
|
630
349
|
* -->
|
|
631
350
|
* ```js
|
|
632
351
|
* List([ 0, 1, 2, 3, 4 ]).shift();
|
|
@@ -647,7 +366,7 @@
|
|
|
647
366
|
* List. `v.update(-1)` updates the last item in the List.
|
|
648
367
|
*
|
|
649
368
|
* <!-- runkit:activate
|
|
650
|
-
* { "preamble": "const { List } = require('immutable@4.0.0-rc.
|
|
369
|
+
* { "preamble": "const { List } = require('immutable@4.0.0-rc.9');" }
|
|
651
370
|
* -->
|
|
652
371
|
* ```js
|
|
653
372
|
* const list = List([ 'a', 'b', 'c' ])
|
|
@@ -661,7 +380,7 @@
|
|
|
661
380
|
* For example, to sum a List after mapping and filtering:
|
|
662
381
|
*
|
|
663
382
|
* <!-- runkit:activate
|
|
664
|
-
* { "preamble": "const { List } = require('immutable@4.0.0-rc.
|
|
383
|
+
* { "preamble": "const { List } = require('immutable@4.0.0-rc.9');" }
|
|
665
384
|
* -->
|
|
666
385
|
* ```js
|
|
667
386
|
* function sum(collection) {
|
|
@@ -707,7 +426,7 @@
|
|
|
707
426
|
*
|
|
708
427
|
* <!-- runkit:activate -->
|
|
709
428
|
* ```js
|
|
710
|
-
* const { List } = require('immutable@4.0.0-rc.
|
|
429
|
+
* const { List } = require('immutable@4.0.0-rc.9')
|
|
711
430
|
* const list = List([ 0, 1, 2, List([ 3, 4 ])])
|
|
712
431
|
* list.setIn([3, 0], 999);
|
|
713
432
|
* // List [ 0, 1, 2, List [ 999, 4 ] ]
|
|
@@ -719,7 +438,7 @@
|
|
|
719
438
|
*
|
|
720
439
|
* <!-- runkit:activate -->
|
|
721
440
|
* ```js
|
|
722
|
-
* const { List } = require('immutable@4.0.0-rc.
|
|
441
|
+
* const { List } = require('immutable@4.0.0-rc.9')
|
|
723
442
|
* const list = List([ 0, 1, 2, { plain: 'object' }])
|
|
724
443
|
* list.setIn([3, 'plain'], 'value');
|
|
725
444
|
* // List([ 0, 1, 2, { plain: 'value' }])
|
|
@@ -735,7 +454,7 @@
|
|
|
735
454
|
*
|
|
736
455
|
* <!-- runkit:activate -->
|
|
737
456
|
* ```js
|
|
738
|
-
* const { List } = require('immutable@4.0.0-rc.
|
|
457
|
+
* const { List } = require('immutable@4.0.0-rc.9')
|
|
739
458
|
* const list = List([ 0, 1, 2, List([ 3, 4 ])])
|
|
740
459
|
* list.deleteIn([3, 0]);
|
|
741
460
|
* // List [ 0, 1, 2, List [ 4 ] ]
|
|
@@ -747,7 +466,7 @@
|
|
|
747
466
|
*
|
|
748
467
|
* <!-- runkit:activate -->
|
|
749
468
|
* ```js
|
|
750
|
-
* const { List } = require('immutable@4.0.0-rc.
|
|
469
|
+
* const { List } = require('immutable@4.0.0-rc.9')
|
|
751
470
|
* const list = List([ 0, 1, 2, { plain: 'object' }])
|
|
752
471
|
* list.removeIn([3, 'plain']);
|
|
753
472
|
* // List([ 0, 1, 2, {}])
|
|
@@ -831,7 +550,7 @@
|
|
|
831
550
|
* `mapper` function.
|
|
832
551
|
*
|
|
833
552
|
* <!-- runkit:activate
|
|
834
|
-
* { "preamble": "const { List } = require('immutable@4.0.0-rc.
|
|
553
|
+
* { "preamble": "const { List } = require('immutable@4.0.0-rc.9');" }
|
|
835
554
|
* -->
|
|
836
555
|
* ```js
|
|
837
556
|
* List([ 1, 2 ]).map(x => 10 * x)
|
|
@@ -878,7 +597,7 @@
|
|
|
878
597
|
* Like `zipWith`, but using the default `zipper`: creating an `Array`.
|
|
879
598
|
*
|
|
880
599
|
* <!-- runkit:activate
|
|
881
|
-
* { "preamble": "const { List } = require('immutable@4.0.0-rc.
|
|
600
|
+
* { "preamble": "const { List } = require('immutable@4.0.0-rc.9');" }
|
|
882
601
|
* -->
|
|
883
602
|
* ```js
|
|
884
603
|
* const a = List([ 1, 2, 3 ]);
|
|
@@ -897,7 +616,7 @@
|
|
|
897
616
|
* exhausted. Missing values from shorter collections are filled with `undefined`.
|
|
898
617
|
*
|
|
899
618
|
* <!-- runkit:activate
|
|
900
|
-
* { "preamble": "const { List } = require('immutable@4.0.0-rc.
|
|
619
|
+
* { "preamble": "const { List } = require('immutable@4.0.0-rc.9');" }
|
|
901
620
|
* -->
|
|
902
621
|
* ```js
|
|
903
622
|
* const a = List([ 1, 2 ]);
|
|
@@ -918,7 +637,7 @@
|
|
|
918
637
|
* custom `zipper` function.
|
|
919
638
|
*
|
|
920
639
|
* <!-- runkit:activate
|
|
921
|
-
* { "preamble": "const { List } = require('immutable@4.0.0-rc.
|
|
640
|
+
* { "preamble": "const { List } = require('immutable@4.0.0-rc.9');" }
|
|
922
641
|
* -->
|
|
923
642
|
* ```js
|
|
924
643
|
* const a = List([ 1, 2, 3 ]);
|
|
@@ -959,7 +678,7 @@
|
|
|
959
678
|
*
|
|
960
679
|
* <!-- runkit:activate -->
|
|
961
680
|
* ```js
|
|
962
|
-
* const { Map, List } = require('immutable@4.0.0-rc.
|
|
681
|
+
* const { Map, List } = require('immutable@4.0.0-rc.9');
|
|
963
682
|
* Map().set(List([ 1 ]), 'listofone').get(List([ 1 ]));
|
|
964
683
|
* // 'listofone'
|
|
965
684
|
* ```
|
|
@@ -977,7 +696,7 @@
|
|
|
977
696
|
*
|
|
978
697
|
* <!-- runkit:activate -->
|
|
979
698
|
* ```js
|
|
980
|
-
* const { Map } = require('immutable@4.0.0-rc.
|
|
699
|
+
* const { Map } = require('immutable@4.0.0-rc.9')
|
|
981
700
|
* Map.isMap({}) // false
|
|
982
701
|
* Map.isMap(Map()) // true
|
|
983
702
|
* ```
|
|
@@ -989,7 +708,7 @@
|
|
|
989
708
|
*
|
|
990
709
|
* <!-- runkit:activate -->
|
|
991
710
|
* ```js
|
|
992
|
-
* const { Map } = require('immutable@4.0.0-rc.
|
|
711
|
+
* const { Map } = require('immutable@4.0.0-rc.9')
|
|
993
712
|
* Map.of(
|
|
994
713
|
* 'key', 'value',
|
|
995
714
|
* 'numerical value', 3,
|
|
@@ -1011,7 +730,7 @@
|
|
|
1011
730
|
*
|
|
1012
731
|
* <!-- runkit:activate -->
|
|
1013
732
|
* ```js
|
|
1014
|
-
* const { Map } = require('immutable@4.0.0-rc.
|
|
733
|
+
* const { Map } = require('immutable@4.0.0-rc.9')
|
|
1015
734
|
* Map({ key: "value" })
|
|
1016
735
|
* Map([ [ "key", "value" ] ])
|
|
1017
736
|
* ```
|
|
@@ -1021,7 +740,7 @@
|
|
|
1021
740
|
* quote-less shorthand, while Immutable Maps accept keys of any type.
|
|
1022
741
|
*
|
|
1023
742
|
* <!-- runkit:activate
|
|
1024
|
-
* { "preamble": "const { Map } = require('immutable@4.0.0-rc.
|
|
743
|
+
* { "preamble": "const { Map } = require('immutable@4.0.0-rc.9');" }
|
|
1025
744
|
* -->
|
|
1026
745
|
* ```js
|
|
1027
746
|
* let obj = { 1: "one" }
|
|
@@ -1057,7 +776,7 @@
|
|
|
1057
776
|
*
|
|
1058
777
|
* <!-- runkit:activate -->
|
|
1059
778
|
* ```js
|
|
1060
|
-
* const { Map } = require('immutable@4.0.0-rc.
|
|
779
|
+
* const { Map } = require('immutable@4.0.0-rc.9')
|
|
1061
780
|
* const originalMap = Map()
|
|
1062
781
|
* const newerMap = originalMap.set('key', 'value')
|
|
1063
782
|
* const newestMap = newerMap.set('key', 'newer value')
|
|
@@ -1082,7 +801,7 @@
|
|
|
1082
801
|
*
|
|
1083
802
|
* <!-- runkit:activate -->
|
|
1084
803
|
* ```js
|
|
1085
|
-
* const { Map } = require('immutable@4.0.0-rc.
|
|
804
|
+
* const { Map } = require('immutable@4.0.0-rc.9')
|
|
1086
805
|
* const originalMap = Map({
|
|
1087
806
|
* key: 'value',
|
|
1088
807
|
* otherKey: 'other value'
|
|
@@ -1104,7 +823,7 @@
|
|
|
1104
823
|
*
|
|
1105
824
|
* <!-- runkit:activate -->
|
|
1106
825
|
* ```js
|
|
1107
|
-
* const { Map } = require('immutable@4.0.0-rc.
|
|
826
|
+
* const { Map } = require('immutable@4.0.0-rc.9')
|
|
1108
827
|
* const names = Map({ a: "Aaron", b: "Barry", c: "Connor" })
|
|
1109
828
|
* names.deleteAll([ 'a', 'c' ])
|
|
1110
829
|
* // Map { "b": "Barry" }
|
|
@@ -1122,7 +841,7 @@
|
|
|
1122
841
|
*
|
|
1123
842
|
* <!-- runkit:activate -->
|
|
1124
843
|
* ```js
|
|
1125
|
-
* const { Map } = require('immutable@4.0.0-rc.
|
|
844
|
+
* const { Map } = require('immutable@4.0.0-rc.9')
|
|
1126
845
|
* Map({ key: 'value' }).clear()
|
|
1127
846
|
* // Map {}
|
|
1128
847
|
* ```
|
|
@@ -1139,7 +858,7 @@
|
|
|
1139
858
|
*
|
|
1140
859
|
* <!-- runkit:activate -->
|
|
1141
860
|
* ```js
|
|
1142
|
-
* const { Map } = require('immutable@4.0.0-rc.
|
|
861
|
+
* const { Map } = require('immutable@4.0.0-rc.9')
|
|
1143
862
|
* const aMap = Map({ key: 'value' })
|
|
1144
863
|
* const newMap = aMap.update('key', value => value + value)
|
|
1145
864
|
* // Map { "key": "valuevalue" }
|
|
@@ -1150,7 +869,7 @@
|
|
|
1150
869
|
* `update` and `push` can be used together:
|
|
1151
870
|
*
|
|
1152
871
|
* <!-- runkit:activate
|
|
1153
|
-
* { "preamble": "const { Map, List } = require('immutable@4.0.0-rc.
|
|
872
|
+
* { "preamble": "const { Map, List } = require('immutable@4.0.0-rc.9');" }
|
|
1154
873
|
* -->
|
|
1155
874
|
* ```js
|
|
1156
875
|
* const aMap = Map({ nestedList: List([ 1, 2, 3 ]) })
|
|
@@ -1162,7 +881,7 @@
|
|
|
1162
881
|
* function when the value at the key does not exist in the Map.
|
|
1163
882
|
*
|
|
1164
883
|
* <!-- runkit:activate
|
|
1165
|
-
* { "preamble": "const { Map } = require('immutable@4.0.0-rc.
|
|
884
|
+
* { "preamble": "const { Map } = require('immutable@4.0.0-rc.9');" }
|
|
1166
885
|
* -->
|
|
1167
886
|
* ```js
|
|
1168
887
|
* const aMap = Map({ key: 'value' })
|
|
@@ -1175,7 +894,7 @@
|
|
|
1175
894
|
* is provided.
|
|
1176
895
|
*
|
|
1177
896
|
* <!-- runkit:activate
|
|
1178
|
-
* { "preamble": "const { Map } = require('immutable@4.0.0-rc.
|
|
897
|
+
* { "preamble": "const { Map } = require('immutable@4.0.0-rc.9');" }
|
|
1179
898
|
* -->
|
|
1180
899
|
* ```js
|
|
1181
900
|
* const aMap = Map({ apples: 10 })
|
|
@@ -1191,7 +910,7 @@
|
|
|
1191
910
|
* The previous example behaves differently when written with default values:
|
|
1192
911
|
*
|
|
1193
912
|
* <!-- runkit:activate
|
|
1194
|
-
* { "preamble": "const { Map } = require('immutable@4.0.0-rc.
|
|
913
|
+
* { "preamble": "const { Map } = require('immutable@4.0.0-rc.9');" }
|
|
1195
914
|
* -->
|
|
1196
915
|
* ```js
|
|
1197
916
|
* const aMap = Map({ apples: 10 })
|
|
@@ -1203,7 +922,7 @@
|
|
|
1203
922
|
* returned as well.
|
|
1204
923
|
*
|
|
1205
924
|
* <!-- runkit:activate
|
|
1206
|
-
* { "preamble": "const { Map } = require('immutable@4.0.0-rc.
|
|
925
|
+
* { "preamble": "const { Map } = require('immutable@4.0.0-rc.9');" }
|
|
1207
926
|
* -->
|
|
1208
927
|
* ```js
|
|
1209
928
|
* const aMap = Map({ key: 'value' })
|
|
@@ -1217,7 +936,7 @@
|
|
|
1217
936
|
* For example, to sum the values in a Map
|
|
1218
937
|
*
|
|
1219
938
|
* <!-- runkit:activate
|
|
1220
|
-
* { "preamble": "const { Map } = require('immutable@4.0.0-rc.
|
|
939
|
+
* { "preamble": "const { Map } = require('immutable@4.0.0-rc.9');" }
|
|
1221
940
|
* -->
|
|
1222
941
|
* ```js
|
|
1223
942
|
* function sum(collection) {
|
|
@@ -1247,7 +966,7 @@
|
|
|
1247
966
|
*
|
|
1248
967
|
* <!-- runkit:activate -->
|
|
1249
968
|
* ```js
|
|
1250
|
-
* const { Map } = require('immutable@4.0.0-rc.
|
|
969
|
+
* const { Map } = require('immutable@4.0.0-rc.9')
|
|
1251
970
|
* const one = Map({ a: 10, b: 20, c: 30 })
|
|
1252
971
|
* const two = Map({ b: 40, a: 50, d: 60 })
|
|
1253
972
|
* one.merge(two) // Map { "a": 50, "b": 40, "c": 30, "d": 60 }
|
|
@@ -1270,7 +989,7 @@
|
|
|
1270
989
|
*
|
|
1271
990
|
* <!-- runkit:activate -->
|
|
1272
991
|
* ```js
|
|
1273
|
-
* const { Map } = require('immutable@4.0.0-rc.
|
|
992
|
+
* const { Map } = require('immutable@4.0.0-rc.9')
|
|
1274
993
|
* const one = Map({ a: 10, b: 20, c: 30 })
|
|
1275
994
|
* const two = Map({ b: 40, a: 50, d: 60 })
|
|
1276
995
|
* one.mergeWith((oldVal, newVal) => oldVal / newVal, two)
|
|
@@ -1296,7 +1015,7 @@
|
|
|
1296
1015
|
*
|
|
1297
1016
|
* <!-- runkit:activate -->
|
|
1298
1017
|
* ```js
|
|
1299
|
-
* const { Map } = require('immutable@4.0.0-rc.
|
|
1018
|
+
* const { Map } = require('immutable@4.0.0-rc.9')
|
|
1300
1019
|
* const one = Map({ a: Map({ x: 10, y: 10 }), b: Map({ x: 20, y: 50 }) })
|
|
1301
1020
|
* const two = Map({ a: Map({ x: 2 }), b: Map({ y: 5 }), c: Map({ z: 3 }) })
|
|
1302
1021
|
* one.mergeDeep(two)
|
|
@@ -1317,7 +1036,7 @@
|
|
|
1317
1036
|
*
|
|
1318
1037
|
* <!-- runkit:activate -->
|
|
1319
1038
|
* ```js
|
|
1320
|
-
* const { Map } = require('immutable@4.0.0-rc.
|
|
1039
|
+
* const { Map } = require('immutable@4.0.0-rc.9')
|
|
1321
1040
|
* const one = Map({ a: Map({ x: 10, y: 10 }), b: Map({ x: 20, y: 50 }) })
|
|
1322
1041
|
* const two = Map({ a: Map({ x: 2 }), b: Map({ y: 5 }), c: Map({ z: 3 }) })
|
|
1323
1042
|
* one.mergeDeepWith((oldVal, newVal) => oldVal / newVal, two)
|
|
@@ -1344,7 +1063,7 @@
|
|
|
1344
1063
|
*
|
|
1345
1064
|
* <!-- runkit:activate -->
|
|
1346
1065
|
* ```js
|
|
1347
|
-
* const { Map } = require('immutable@4.0.0-rc.
|
|
1066
|
+
* const { Map } = require('immutable@4.0.0-rc.9')
|
|
1348
1067
|
* const originalMap = Map({
|
|
1349
1068
|
* subObject: Map({
|
|
1350
1069
|
* subKey: 'subvalue',
|
|
@@ -1380,7 +1099,7 @@
|
|
|
1380
1099
|
*
|
|
1381
1100
|
* <!-- runkit:activate -->
|
|
1382
1101
|
* ```js
|
|
1383
|
-
* const { Map } = require('immutable@4.0.0-rc.
|
|
1102
|
+
* const { Map } = require('immutable@4.0.0-rc.9')
|
|
1384
1103
|
* const originalMap = Map({
|
|
1385
1104
|
* subObject: {
|
|
1386
1105
|
* subKey: 'subvalue',
|
|
@@ -1427,7 +1146,7 @@
|
|
|
1427
1146
|
*
|
|
1428
1147
|
* <!-- runkit:activate -->
|
|
1429
1148
|
* ```js
|
|
1430
|
-
* const { Map, List } = require('immutable@4.0.0-rc.
|
|
1149
|
+
* const { Map, List } = require('immutable@4.0.0-rc.9')
|
|
1431
1150
|
* const map = Map({ inMap: Map({ inList: List([ 1, 2, 3 ]) }) })
|
|
1432
1151
|
* const newMap = map.updateIn(['inMap', 'inList'], list => list.push(4))
|
|
1433
1152
|
* // Map { "inMap": Map { "inList": List [ 1, 2, 3, 4 ] } }
|
|
@@ -1439,7 +1158,7 @@
|
|
|
1439
1158
|
* provided, otherwise `undefined`.
|
|
1440
1159
|
*
|
|
1441
1160
|
* <!-- runkit:activate
|
|
1442
|
-
* { "preamble": "const { Map } = require('immutable@4.0.0-rc.
|
|
1161
|
+
* { "preamble": "const { Map } = require('immutable@4.0.0-rc.9')" }
|
|
1443
1162
|
* -->
|
|
1444
1163
|
* ```js
|
|
1445
1164
|
* const map = Map({ a: Map({ b: Map({ c: 10 }) }) })
|
|
@@ -1451,7 +1170,7 @@
|
|
|
1451
1170
|
* no change will occur. This is still true if `notSetValue` is provided.
|
|
1452
1171
|
*
|
|
1453
1172
|
* <!-- runkit:activate
|
|
1454
|
-
* { "preamble": "const { Map } = require('immutable@4.0.0-rc.
|
|
1173
|
+
* { "preamble": "const { Map } = require('immutable@4.0.0-rc.9')" }
|
|
1455
1174
|
* -->
|
|
1456
1175
|
* ```js
|
|
1457
1176
|
* const map = Map({ a: Map({ b: Map({ c: 10 }) }) })
|
|
@@ -1467,7 +1186,7 @@
|
|
|
1467
1186
|
* The previous example behaves differently when written with default values:
|
|
1468
1187
|
*
|
|
1469
1188
|
* <!-- runkit:activate
|
|
1470
|
-
* { "preamble": "const { Map } = require('immutable@4.0.0-rc.
|
|
1189
|
+
* { "preamble": "const { Map } = require('immutable@4.0.0-rc.9')" }
|
|
1471
1190
|
* -->
|
|
1472
1191
|
* ```js
|
|
1473
1192
|
* const map = Map({ a: Map({ b: Map({ c: 10 }) }) })
|
|
@@ -1480,7 +1199,7 @@
|
|
|
1480
1199
|
* immutably by creating new copies of those values with the changes applied.
|
|
1481
1200
|
*
|
|
1482
1201
|
* <!-- runkit:activate
|
|
1483
|
-
* { "preamble": "const { Map } = require('immutable@4.0.0-rc.
|
|
1202
|
+
* { "preamble": "const { Map } = require('immutable@4.0.0-rc.9')" }
|
|
1484
1203
|
* -->
|
|
1485
1204
|
* ```js
|
|
1486
1205
|
* const map = Map({ a: { b: { c: 10 } } })
|
|
@@ -1541,7 +1260,7 @@
|
|
|
1541
1260
|
*
|
|
1542
1261
|
* <!-- runkit:activate -->
|
|
1543
1262
|
* ```js
|
|
1544
|
-
* const { Map } = require('immutable@4.0.0-rc.
|
|
1263
|
+
* const { Map } = require('immutable@4.0.0-rc.9')
|
|
1545
1264
|
* const map1 = Map()
|
|
1546
1265
|
* const map2 = map1.withMutations(map => {
|
|
1547
1266
|
* map.set('a', 1).set('b', 2).set('c', 3)
|
|
@@ -1709,7 +1428,7 @@
|
|
|
1709
1428
|
*
|
|
1710
1429
|
* <!-- runkit:activate -->
|
|
1711
1430
|
* ```js
|
|
1712
|
-
* const { OrderedMap } = require('immutable@4.0.0-rc.
|
|
1431
|
+
* const { OrderedMap } = require('immutable@4.0.0-rc.9')
|
|
1713
1432
|
* const one = OrderedMap({ a: 10, b: 20, c: 30 })
|
|
1714
1433
|
* const two = OrderedMap({ b: 40, a: 50, d: 60 })
|
|
1715
1434
|
* one.merge(two) // OrderedMap { "a": 50, "b": 40, "c": 30, "d": 60 }
|
|
@@ -1826,7 +1545,7 @@
|
|
|
1826
1545
|
* a collection of other sets.
|
|
1827
1546
|
*
|
|
1828
1547
|
* ```js
|
|
1829
|
-
* const { Set } = require('immutable@4.0.0-rc.
|
|
1548
|
+
* const { Set } = require('immutable@4.0.0-rc.9')
|
|
1830
1549
|
* const intersected = Set.intersect([
|
|
1831
1550
|
* Set([ 'a', 'b', 'c' ])
|
|
1832
1551
|
* Set([ 'c', 'a', 't' ])
|
|
@@ -1841,7 +1560,7 @@
|
|
|
1841
1560
|
* collection of other sets.
|
|
1842
1561
|
*
|
|
1843
1562
|
* ```js
|
|
1844
|
-
* const { Set } = require('immutable@4.0.0-rc.
|
|
1563
|
+
* const { Set } = require('immutable@4.0.0-rc.9')
|
|
1845
1564
|
* const unioned = Set.union([
|
|
1846
1565
|
* Set([ 'a', 'b', 'c' ])
|
|
1847
1566
|
* Set([ 'c', 'a', 't' ])
|
|
@@ -2412,7 +2131,7 @@
|
|
|
2412
2131
|
* infinity. When `start` is equal to `end`, returns empty range.
|
|
2413
2132
|
*
|
|
2414
2133
|
* ```js
|
|
2415
|
-
* const { Range } = require('immutable@4.0.0-rc.
|
|
2134
|
+
* const { Range } = require('immutable@4.0.0-rc.9')
|
|
2416
2135
|
* Range() // [ 0, 1, 2, 3, ... ]
|
|
2417
2136
|
* Range(10) // [ 10, 11, 12, 13, ... ]
|
|
2418
2137
|
* Range(10, 15) // [ 10, 11, 12, 13, 14 ]
|
|
@@ -2429,7 +2148,7 @@
|
|
|
2429
2148
|
* not defined, returns an infinite `Seq` of `value`.
|
|
2430
2149
|
*
|
|
2431
2150
|
* ```js
|
|
2432
|
-
* const { Repeat } = require('immutable@4.0.0-rc.
|
|
2151
|
+
* const { Repeat } = require('immutable@4.0.0-rc.9')
|
|
2433
2152
|
* Repeat('foo') // [ 'foo', 'foo', 'foo', ... ]
|
|
2434
2153
|
* Repeat('bar', 4) // [ 'bar', 'bar', 'bar', 'bar' ]
|
|
2435
2154
|
* ```
|
|
@@ -2445,7 +2164,7 @@
|
|
|
2445
2164
|
* create Record instances.
|
|
2446
2165
|
*
|
|
2447
2166
|
* ```js
|
|
2448
|
-
* const { Record } = require('immutable@4.0.0-rc.
|
|
2167
|
+
* const { Record } = require('immutable@4.0.0-rc.9')
|
|
2449
2168
|
* const ABRecord = Record({ a: 1, b: 2 })
|
|
2450
2169
|
* const myRecord = new ABRecord({ b: 3 })
|
|
2451
2170
|
* ```
|
|
@@ -2577,7 +2296,7 @@
|
|
|
2577
2296
|
* method. If one was not provided, the string "Record" is returned.
|
|
2578
2297
|
*
|
|
2579
2298
|
* ```js
|
|
2580
|
-
* const { Record } = require('immutable@4.0.0-rc.
|
|
2299
|
+
* const { Record } = require('immutable@4.0.0-rc.9')
|
|
2581
2300
|
* const Person = Record({
|
|
2582
2301
|
* name: null
|
|
2583
2302
|
* }, 'Person')
|
|
@@ -2595,7 +2314,7 @@
|
|
|
2595
2314
|
* type:
|
|
2596
2315
|
*
|
|
2597
2316
|
* <!-- runkit:activate
|
|
2598
|
-
* { "preamble": "const { Record } = require('immutable@4.0.0-rc.
|
|
2317
|
+
* { "preamble": "const { Record } = require('immutable@4.0.0-rc.9')" }
|
|
2599
2318
|
* -->
|
|
2600
2319
|
* ```js
|
|
2601
2320
|
* // makePerson is a Record Factory function
|
|
@@ -2610,7 +2329,7 @@
|
|
|
2610
2329
|
* access on the resulting instances:
|
|
2611
2330
|
*
|
|
2612
2331
|
* <!-- runkit:activate
|
|
2613
|
-
* { "preamble": "const { Record } = require('immutable@4.0.0-rc.
|
|
2332
|
+
* { "preamble": "const { Record } = require('immutable@4.0.0-rc.9');const makePerson = Record({ name: null, favoriteColor: 'unknown' });const alan = makePerson({ name: 'Alan' });" }
|
|
2614
2333
|
* -->
|
|
2615
2334
|
* ```js
|
|
2616
2335
|
* // Use the Record API
|
|
@@ -2792,7 +2511,7 @@
|
|
|
2792
2511
|
* `Seq`'s values are never iterated:
|
|
2793
2512
|
*
|
|
2794
2513
|
* ```js
|
|
2795
|
-
* const { Seq } = require('immutable@4.0.0-rc.
|
|
2514
|
+
* const { Seq } = require('immutable@4.0.0-rc.9')
|
|
2796
2515
|
* const oddSquares = Seq([ 1, 2, 3, 4, 5, 6, 7, 8 ])
|
|
2797
2516
|
* .filter(x => x % 2 !== 0)
|
|
2798
2517
|
* .map(x => x * x)
|
|
@@ -2831,7 +2550,7 @@
|
|
|
2831
2550
|
*
|
|
2832
2551
|
* <!-- runkit:activate -->
|
|
2833
2552
|
* ```js
|
|
2834
|
-
* const { Range } = require('immutable@4.0.0-rc.
|
|
2553
|
+
* const { Range } = require('immutable@4.0.0-rc.9')
|
|
2835
2554
|
* Range(1, Infinity)
|
|
2836
2555
|
* .skip(1000)
|
|
2837
2556
|
* .map(n => -n)
|
|
@@ -2910,7 +2629,7 @@
|
|
|
2910
2629
|
* `mapper` function.
|
|
2911
2630
|
*
|
|
2912
2631
|
* ```js
|
|
2913
|
-
* const { Seq } = require('immutable@4.0.0-rc.
|
|
2632
|
+
* const { Seq } = require('immutable@4.0.0-rc.9')
|
|
2914
2633
|
* Seq.Keyed({ a: 1, b: 2 }).map(x => 10 * x)
|
|
2915
2634
|
* // Seq { "a": 10, "b": 20 }
|
|
2916
2635
|
* ```
|
|
@@ -3022,7 +2741,7 @@
|
|
|
3022
2741
|
* `mapper` function.
|
|
3023
2742
|
*
|
|
3024
2743
|
* ```js
|
|
3025
|
-
* const { Seq } = require('immutable@4.0.0-rc.
|
|
2744
|
+
* const { Seq } = require('immutable@4.0.0-rc.9')
|
|
3026
2745
|
* Seq.Indexed([ 1, 2 ]).map(x => 10 * x)
|
|
3027
2746
|
* // Seq [ 10, 20 ]
|
|
3028
2747
|
* ```
|
|
@@ -3282,7 +3001,7 @@
|
|
|
3282
3001
|
* `mapper` function.
|
|
3283
3002
|
*
|
|
3284
3003
|
* ```js
|
|
3285
|
-
* const { Seq } = require('immutable@4.0.0-rc.
|
|
3004
|
+
* const { Seq } = require('immutable@4.0.0-rc.9')
|
|
3286
3005
|
* Seq([ 1, 2 ]).map(x => 10 * x)
|
|
3287
3006
|
* // Seq [ 10, 20 ]
|
|
3288
3007
|
* ```
|
|
@@ -3300,7 +3019,7 @@
|
|
|
3300
3019
|
* `mapper` function.
|
|
3301
3020
|
*
|
|
3302
3021
|
* ```js
|
|
3303
|
-
* const { Seq } = require('immutable@4.0.0-rc.
|
|
3022
|
+
* const { Seq } = require('immutable@4.0.0-rc.9')
|
|
3304
3023
|
* Seq([ 1, 2 ]).map(x => 10 * x)
|
|
3305
3024
|
* // Seq [ 10, 20 ]
|
|
3306
3025
|
* ```
|
|
@@ -3369,22 +3088,22 @@
|
|
|
3369
3088
|
export module Collection {
|
|
3370
3089
|
|
|
3371
3090
|
/**
|
|
3372
|
-
* @deprecated use `const { isKeyed } = require('immutable@4.0.0-rc.
|
|
3091
|
+
* @deprecated use `const { isKeyed } = require('immutable@4.0.0-rc.9')`
|
|
3373
3092
|
*/
|
|
3374
3093
|
function isKeyed(maybeKeyed: any): maybeKeyed is Collection.Keyed<any, any>;
|
|
3375
3094
|
|
|
3376
3095
|
/**
|
|
3377
|
-
* @deprecated use `const { isIndexed } = require('immutable@4.0.0-rc.
|
|
3096
|
+
* @deprecated use `const { isIndexed } = require('immutable@4.0.0-rc.9')`
|
|
3378
3097
|
*/
|
|
3379
3098
|
function isIndexed(maybeIndexed: any): maybeIndexed is Collection.Indexed<any>;
|
|
3380
3099
|
|
|
3381
3100
|
/**
|
|
3382
|
-
* @deprecated use `const { isAssociative } = require('immutable@4.0.0-rc.
|
|
3101
|
+
* @deprecated use `const { isAssociative } = require('immutable@4.0.0-rc.9')`
|
|
3383
3102
|
*/
|
|
3384
3103
|
function isAssociative(maybeAssociative: any): maybeAssociative is Collection.Keyed<any, any> | Collection.Indexed<any>;
|
|
3385
3104
|
|
|
3386
3105
|
/**
|
|
3387
|
-
* @deprecated use `const { isOrdered } = require('immutable@4.0.0-rc.
|
|
3106
|
+
* @deprecated use `const { isOrdered } = require('immutable@4.0.0-rc.9')`
|
|
3388
3107
|
*/
|
|
3389
3108
|
function isOrdered(maybeOrdered: any): boolean;
|
|
3390
3109
|
|
|
@@ -3442,7 +3161,7 @@
|
|
|
3442
3161
|
*
|
|
3443
3162
|
* <!-- runkit:activate -->
|
|
3444
3163
|
* ```js
|
|
3445
|
-
* const { Map } = require('immutable@4.0.0-rc.
|
|
3164
|
+
* const { Map } = require('immutable@4.0.0-rc.9')
|
|
3446
3165
|
* Map({ a: 'z', b: 'y' }).flip()
|
|
3447
3166
|
* // Map { "z": "a", "y": "b" }
|
|
3448
3167
|
* ```
|
|
@@ -3460,7 +3179,7 @@
|
|
|
3460
3179
|
* `mapper` function.
|
|
3461
3180
|
*
|
|
3462
3181
|
* ```js
|
|
3463
|
-
* const { Collection } = require('immutable@4.0.0-rc.
|
|
3182
|
+
* const { Collection } = require('immutable@4.0.0-rc.9')
|
|
3464
3183
|
* Collection.Keyed({ a: 1, b: 2 }).map(x => 10 * x)
|
|
3465
3184
|
* // Seq { "a": 10, "b": 20 }
|
|
3466
3185
|
* ```
|
|
@@ -3479,7 +3198,7 @@
|
|
|
3479
3198
|
*
|
|
3480
3199
|
* <!-- runkit:activate -->
|
|
3481
3200
|
* ```js
|
|
3482
|
-
* const { Map } = require('immutable@4.0.0-rc.
|
|
3201
|
+
* const { Map } = require('immutable@4.0.0-rc.9')
|
|
3483
3202
|
* Map({ a: 1, b: 2 }).mapKeys(x => x.toUpperCase())
|
|
3484
3203
|
* // Map { "A": 1, "B": 2 }
|
|
3485
3204
|
* ```
|
|
@@ -3498,7 +3217,7 @@
|
|
|
3498
3217
|
*
|
|
3499
3218
|
* <!-- runkit:activate -->
|
|
3500
3219
|
* ```js
|
|
3501
|
-
* const { Map } = require('immutable@4.0.0-rc.
|
|
3220
|
+
* const { Map } = require('immutable@4.0.0-rc.9')
|
|
3502
3221
|
* Map({ a: 1, b: 2 })
|
|
3503
3222
|
* .mapEntries(([ k, v ]) => [ k.toUpperCase(), v * 2 ])
|
|
3504
3223
|
* // Map { "A": 2, "B": 4 }
|
|
@@ -3624,10 +3343,10 @@
|
|
|
3624
3343
|
* second from each, etc.
|
|
3625
3344
|
*
|
|
3626
3345
|
* <!-- runkit:activate
|
|
3627
|
-
* { "preamble": "require('immutable@4.0.0-rc.
|
|
3346
|
+
* { "preamble": "require('immutable@4.0.0-rc.9')"}
|
|
3628
3347
|
* -->
|
|
3629
3348
|
* ```js
|
|
3630
|
-
* const { List } = require('immutable@4.0.0-rc.
|
|
3349
|
+
* const { List } = require('immutable@4.0.0-rc.9')
|
|
3631
3350
|
* List([ 1, 2, 3 ]).interleave(List([ 'A', 'B', 'C' ]))
|
|
3632
3351
|
* // List [ 1, "A", 2, "B", 3, "C"" ]
|
|
3633
3352
|
* ```
|
|
@@ -3635,7 +3354,7 @@
|
|
|
3635
3354
|
* The shortest Collection stops interleave.
|
|
3636
3355
|
*
|
|
3637
3356
|
* <!-- runkit:activate
|
|
3638
|
-
* { "preamble": "const { List } = require('immutable@4.0.0-rc.
|
|
3357
|
+
* { "preamble": "const { List } = require('immutable@4.0.0-rc.9')" }
|
|
3639
3358
|
* -->
|
|
3640
3359
|
* ```js
|
|
3641
3360
|
* List([ 1, 2, 3 ]).interleave(
|
|
@@ -3662,7 +3381,7 @@
|
|
|
3662
3381
|
*
|
|
3663
3382
|
* <!-- runkit:activate -->
|
|
3664
3383
|
* ```js
|
|
3665
|
-
* const { List } = require('immutable@4.0.0-rc.
|
|
3384
|
+
* const { List } = require('immutable@4.0.0-rc.9')
|
|
3666
3385
|
* List([ 'a', 'b', 'c', 'd' ]).splice(1, 2, 'q', 'r', 's')
|
|
3667
3386
|
* // List [ "a", "q", "r", "s", "d" ]
|
|
3668
3387
|
* ```
|
|
@@ -3686,7 +3405,7 @@
|
|
|
3686
3405
|
*
|
|
3687
3406
|
*
|
|
3688
3407
|
* <!-- runkit:activate
|
|
3689
|
-
* { "preamble": "const { List } = require('immutable@4.0.0-rc.
|
|
3408
|
+
* { "preamble": "const { List } = require('immutable@4.0.0-rc.9')" }
|
|
3690
3409
|
* -->
|
|
3691
3410
|
* ```js
|
|
3692
3411
|
* const a = List([ 1, 2, 3 ]);
|
|
@@ -3719,7 +3438,7 @@
|
|
|
3719
3438
|
* collections by using a custom `zipper` function.
|
|
3720
3439
|
*
|
|
3721
3440
|
* <!-- runkit:activate
|
|
3722
|
-
* { "preamble": "const { List } = require('immutable@4.0.0-rc.
|
|
3441
|
+
* { "preamble": "const { List } = require('immutable@4.0.0-rc.9')" }
|
|
3723
3442
|
* -->
|
|
3724
3443
|
* ```js
|
|
3725
3444
|
* const a = List([ 1, 2, 3 ]);
|
|
@@ -3787,7 +3506,7 @@
|
|
|
3787
3506
|
* `mapper` function.
|
|
3788
3507
|
*
|
|
3789
3508
|
* ```js
|
|
3790
|
-
* const { Collection } = require('immutable@4.0.0-rc.
|
|
3509
|
+
* const { Collection } = require('immutable@4.0.0-rc.9')
|
|
3791
3510
|
* Collection.Indexed([1,2]).map(x => 10 * x)
|
|
3792
3511
|
* // Seq [ 1, 2 ]
|
|
3793
3512
|
* ```
|
|
@@ -3839,7 +3558,7 @@
|
|
|
3839
3558
|
* the value as both the first and second arguments to the provided function.
|
|
3840
3559
|
*
|
|
3841
3560
|
* ```js
|
|
3842
|
-
* const { Collection } = require('immutable@4.0.0-rc.
|
|
3561
|
+
* const { Collection } = require('immutable@4.0.0-rc.9')
|
|
3843
3562
|
* const seq = Collection.Set([ 'A', 'B', 'C' ])
|
|
3844
3563
|
* // Seq { "A", "B", "C" }
|
|
3845
3564
|
* seq.forEach((v, k) =>
|
|
@@ -3971,7 +3690,7 @@
|
|
|
3971
3690
|
* lookup via a different instance.
|
|
3972
3691
|
*
|
|
3973
3692
|
* <!-- runkit:activate
|
|
3974
|
-
* { "preamble": "const { Set, List } = require('immutable@4.0.0-rc.
|
|
3693
|
+
* { "preamble": "const { Set, List } = require('immutable@4.0.0-rc.9')" }
|
|
3975
3694
|
* -->
|
|
3976
3695
|
* ```js
|
|
3977
3696
|
* const a = List([ 1, 2, 3 ]);
|
|
@@ -4036,7 +3755,7 @@
|
|
|
4036
3755
|
*
|
|
4037
3756
|
* <!-- runkit:activate -->
|
|
4038
3757
|
* ```js
|
|
4039
|
-
* const { Map, List } = require('immutable@4.0.0-rc.
|
|
3758
|
+
* const { Map, List } = require('immutable@4.0.0-rc.9')
|
|
4040
3759
|
* const deepData = Map({ x: List([ Map({ y: 123 }) ]) });
|
|
4041
3760
|
* getIn(deepData, ['x', 0, 'y']) // 123
|
|
4042
3761
|
* ```
|
|
@@ -4046,7 +3765,7 @@
|
|
|
4046
3765
|
*
|
|
4047
3766
|
* <!-- runkit:activate -->
|
|
4048
3767
|
* ```js
|
|
4049
|
-
* const { Map, List } = require('immutable@4.0.0-rc.
|
|
3768
|
+
* const { Map, List } = require('immutable@4.0.0-rc.9')
|
|
4050
3769
|
* const deepData = Map({ x: [ { y: 123 } ] });
|
|
4051
3770
|
* getIn(deepData, ['x', 0, 'y']) // 123
|
|
4052
3771
|
* ```
|
|
@@ -4069,7 +3788,7 @@
|
|
|
4069
3788
|
*
|
|
4070
3789
|
* <!-- runkit:activate -->
|
|
4071
3790
|
* ```js
|
|
4072
|
-
* const { Seq } = require('immutable@4.0.0-rc.
|
|
3791
|
+
* const { Seq } = require('immutable@4.0.0-rc.9')
|
|
4073
3792
|
*
|
|
4074
3793
|
* function sum(collection) {
|
|
4075
3794
|
* return collection.reduce((sum, x) => sum + x, 0)
|
|
@@ -4165,7 +3884,7 @@
|
|
|
4165
3884
|
*
|
|
4166
3885
|
* <!-- runkit:activate -->
|
|
4167
3886
|
* ```js
|
|
4168
|
-
* const { Map, List } = require('immutable@4.0.0-rc.
|
|
3887
|
+
* const { Map, List } = require('immutable@4.0.0-rc.9')
|
|
4169
3888
|
* var myMap = Map({ a: 'Apple', b: 'Banana' })
|
|
4170
3889
|
* List(myMap) // List [ [ "a", "Apple" ], [ "b", "Banana" ] ]
|
|
4171
3890
|
* myMap.toList() // List [ "Apple", "Banana" ]
|
|
@@ -4202,7 +3921,7 @@
|
|
|
4202
3921
|
*
|
|
4203
3922
|
* <!-- runkit:activate -->
|
|
4204
3923
|
* ```js
|
|
4205
|
-
* const { Seq } = require('immutable@4.0.0-rc.
|
|
3924
|
+
* const { Seq } = require('immutable@4.0.0-rc.9')
|
|
4206
3925
|
* const indexedSeq = Seq([ 'A', 'B', 'C' ])
|
|
4207
3926
|
* // Seq [ "A", "B", "C" ]
|
|
4208
3927
|
* indexedSeq.filter(v => v === 'B')
|
|
@@ -4283,7 +4002,7 @@
|
|
|
4283
4002
|
*
|
|
4284
4003
|
* <!-- runkit:activate -->
|
|
4285
4004
|
* ```js
|
|
4286
|
-
* const { Collection } = require('immutable@4.0.0-rc.
|
|
4005
|
+
* const { Collection } = require('immutable@4.0.0-rc.9')
|
|
4287
4006
|
* Collection({ a: 1, b: 2 }).map(x => 10 * x)
|
|
4288
4007
|
* // Seq { "a": 10, "b": 20 }
|
|
4289
4008
|
* ```
|
|
@@ -4310,7 +4029,7 @@
|
|
|
4310
4029
|
*
|
|
4311
4030
|
* <!-- runkit:activate -->
|
|
4312
4031
|
* ```js
|
|
4313
|
-
* const { Map } = require('immutable@4.0.0-rc.
|
|
4032
|
+
* const { Map } = require('immutable@4.0.0-rc.9')
|
|
4314
4033
|
* Map({ a: 1, b: 2, c: 3, d: 4}).filter(x => x % 2 === 0)
|
|
4315
4034
|
* // Map { "b": 2, "d": 4 }
|
|
4316
4035
|
* ```
|
|
@@ -4333,7 +4052,7 @@
|
|
|
4333
4052
|
*
|
|
4334
4053
|
* <!-- runkit:activate -->
|
|
4335
4054
|
* ```js
|
|
4336
|
-
* const { Map } = require('immutable@4.0.0-rc.
|
|
4055
|
+
* const { Map } = require('immutable@4.0.0-rc.9')
|
|
4337
4056
|
* Map({ a: 1, b: 2, c: 3, d: 4}).filterNot(x => x % 2 === 0)
|
|
4338
4057
|
* // Map { "a": 1, "c": 3 }
|
|
4339
4058
|
* ```
|
|
@@ -4370,7 +4089,7 @@
|
|
|
4370
4089
|
*
|
|
4371
4090
|
* <!-- runkit:activate -->
|
|
4372
4091
|
* ```js
|
|
4373
|
-
* const { Map } = require('immutable@4.0.0-rc.
|
|
4092
|
+
* const { Map } = require('immutable@4.0.0-rc.9')
|
|
4374
4093
|
* Map({ "c": 3, "a": 1, "b": 2 }).sort((a, b) => {
|
|
4375
4094
|
* if (a < b) { return -1; }
|
|
4376
4095
|
* if (a > b) { return 1; }
|
|
@@ -4410,7 +4129,7 @@
|
|
|
4410
4129
|
*
|
|
4411
4130
|
* <!-- runkit:activate -->
|
|
4412
4131
|
* ```js
|
|
4413
|
-
* const { List, Map } = require('immutable@4.0.0-rc.
|
|
4132
|
+
* const { List, Map } = require('immutable@4.0.0-rc.9')
|
|
4414
4133
|
* const listOfMaps = List([
|
|
4415
4134
|
* Map({ v: 0 }),
|
|
4416
4135
|
* Map({ v: 1 }),
|
|
@@ -4497,7 +4216,7 @@
|
|
|
4497
4216
|
*
|
|
4498
4217
|
* <!-- runkit:activate -->
|
|
4499
4218
|
* ```js
|
|
4500
|
-
* const { List } = require('immutable@4.0.0-rc.
|
|
4219
|
+
* const { List } = require('immutable@4.0.0-rc.9')
|
|
4501
4220
|
* List([ 'dog', 'frog', 'cat', 'hat', 'god' ])
|
|
4502
4221
|
* .skipWhile(x => x.match(/g/))
|
|
4503
4222
|
* // List [ "cat", "hat", "god"" ]
|
|
@@ -4514,7 +4233,7 @@
|
|
|
4514
4233
|
*
|
|
4515
4234
|
* <!-- runkit:activate -->
|
|
4516
4235
|
* ```js
|
|
4517
|
-
* const { List } = require('immutable@4.0.0-rc.
|
|
4236
|
+
* const { List } = require('immutable@4.0.0-rc.9')
|
|
4518
4237
|
* List([ 'dog', 'frog', 'cat', 'hat', 'god' ])
|
|
4519
4238
|
* .skipUntil(x => x.match(/hat/))
|
|
4520
4239
|
* // List [ "hat", "god"" ]
|
|
@@ -4543,7 +4262,7 @@
|
|
|
4543
4262
|
*
|
|
4544
4263
|
* <!-- runkit:activate -->
|
|
4545
4264
|
* ```js
|
|
4546
|
-
* const { List } = require('immutable@4.0.0-rc.
|
|
4265
|
+
* const { List } = require('immutable@4.0.0-rc.9')
|
|
4547
4266
|
* List([ 'dog', 'frog', 'cat', 'hat', 'god' ])
|
|
4548
4267
|
* .takeWhile(x => x.match(/o/))
|
|
4549
4268
|
* // List [ "dog", "frog" ]
|
|
@@ -4560,7 +4279,7 @@
|
|
|
4560
4279
|
*
|
|
4561
4280
|
* <!-- runkit:activate -->
|
|
4562
4281
|
* ```js
|
|
4563
|
-
* const { List } = require('immutable@4.0.0-rc.
|
|
4282
|
+
* const { List } = require('immutable@4.0.0-rc.9')
|
|
4564
4283
|
* List([ 'dog', 'frog', 'cat', 'hat', 'god' ])
|
|
4565
4284
|
* .takeUntil(x => x.match(/at/))
|
|
4566
4285
|
* // List [ "dog", "frog" ]
|
|
@@ -4779,82 +4498,361 @@
|
|
|
4779
4498
|
*/
|
|
4780
4499
|
keyOf(searchValue: V): K | undefined;
|
|
4781
4500
|
|
|
4782
|
-
/**
|
|
4783
|
-
* Returns the last key associated with the search value, or undefined.
|
|
4784
|
-
*/
|
|
4785
|
-
lastKeyOf(searchValue: V): K | undefined;
|
|
4501
|
+
/**
|
|
4502
|
+
* Returns the last key associated with the search value, or undefined.
|
|
4503
|
+
*/
|
|
4504
|
+
lastKeyOf(searchValue: V): K | undefined;
|
|
4505
|
+
|
|
4506
|
+
/**
|
|
4507
|
+
* Returns the maximum value in this collection. If any values are
|
|
4508
|
+
* comparatively equivalent, the first one found will be returned.
|
|
4509
|
+
*
|
|
4510
|
+
* The `comparator` is used in the same way as `Collection#sort`. If it is not
|
|
4511
|
+
* provided, the default comparator is `>`.
|
|
4512
|
+
*
|
|
4513
|
+
* When two values are considered equivalent, the first encountered will be
|
|
4514
|
+
* returned. Otherwise, `max` will operate independent of the order of input
|
|
4515
|
+
* as long as the comparator is commutative. The default comparator `>` is
|
|
4516
|
+
* commutative *only* when types do not differ.
|
|
4517
|
+
*
|
|
4518
|
+
* If `comparator` returns 0 and either value is NaN, undefined, or null,
|
|
4519
|
+
* that value will be returned.
|
|
4520
|
+
*/
|
|
4521
|
+
max(comparator?: (valueA: V, valueB: V) => number): V | undefined;
|
|
4522
|
+
|
|
4523
|
+
/**
|
|
4524
|
+
* Like `max`, but also accepts a `comparatorValueMapper` which allows for
|
|
4525
|
+
* comparing by more sophisticated means:
|
|
4526
|
+
*
|
|
4527
|
+
* hitters.maxBy(hitter => hitter.avgHits);
|
|
4528
|
+
*
|
|
4529
|
+
*/
|
|
4530
|
+
maxBy<C>(
|
|
4531
|
+
comparatorValueMapper: (value: V, key: K, iter: this) => C,
|
|
4532
|
+
comparator?: (valueA: C, valueB: C) => number
|
|
4533
|
+
): V | undefined;
|
|
4534
|
+
|
|
4535
|
+
/**
|
|
4536
|
+
* Returns the minimum value in this collection. If any values are
|
|
4537
|
+
* comparatively equivalent, the first one found will be returned.
|
|
4538
|
+
*
|
|
4539
|
+
* The `comparator` is used in the same way as `Collection#sort`. If it is not
|
|
4540
|
+
* provided, the default comparator is `<`.
|
|
4541
|
+
*
|
|
4542
|
+
* When two values are considered equivalent, the first encountered will be
|
|
4543
|
+
* returned. Otherwise, `min` will operate independent of the order of input
|
|
4544
|
+
* as long as the comparator is commutative. The default comparator `<` is
|
|
4545
|
+
* commutative *only* when types do not differ.
|
|
4546
|
+
*
|
|
4547
|
+
* If `comparator` returns 0 and either value is NaN, undefined, or null,
|
|
4548
|
+
* that value will be returned.
|
|
4549
|
+
*/
|
|
4550
|
+
min(comparator?: (valueA: V, valueB: V) => number): V | undefined;
|
|
4551
|
+
|
|
4552
|
+
/**
|
|
4553
|
+
* Like `min`, but also accepts a `comparatorValueMapper` which allows for
|
|
4554
|
+
* comparing by more sophisticated means:
|
|
4555
|
+
*
|
|
4556
|
+
* hitters.minBy(hitter => hitter.avgHits);
|
|
4557
|
+
*
|
|
4558
|
+
*/
|
|
4559
|
+
minBy<C>(
|
|
4560
|
+
comparatorValueMapper: (value: V, key: K, iter: this) => C,
|
|
4561
|
+
comparator?: (valueA: C, valueB: C) => number
|
|
4562
|
+
): V | undefined;
|
|
4563
|
+
|
|
4564
|
+
|
|
4565
|
+
// Comparison
|
|
4566
|
+
|
|
4567
|
+
/**
|
|
4568
|
+
* True if `iter` includes every value in this Collection.
|
|
4569
|
+
*/
|
|
4570
|
+
isSubset(iter: Iterable<V>): boolean;
|
|
4571
|
+
|
|
4572
|
+
/**
|
|
4573
|
+
* True if this Collection includes every value in `iter`.
|
|
4574
|
+
*/
|
|
4575
|
+
isSuperset(iter: Iterable<V>): boolean;
|
|
4576
|
+
}
|
|
4577
|
+
|
|
4578
|
+
/**
|
|
4579
|
+
* The interface to fulfill to qualify as a Value Object.
|
|
4580
|
+
*/
|
|
4581
|
+
export interface ValueObject {
|
|
4582
|
+
/**
|
|
4583
|
+
* True if this and the other Collection have value equality, as defined
|
|
4584
|
+
* by `Immutable.is()`.
|
|
4585
|
+
*
|
|
4586
|
+
* Note: This is equivalent to `Immutable.is(this, other)`, but provided to
|
|
4587
|
+
* allow for chained expressions.
|
|
4588
|
+
*/
|
|
4589
|
+
equals(other: any): boolean;
|
|
4590
|
+
|
|
4591
|
+
/**
|
|
4592
|
+
* Computes and returns the hashed identity for this Collection.
|
|
4593
|
+
*
|
|
4594
|
+
* The `hashCode` of a Collection is used to determine potential equality,
|
|
4595
|
+
* and is used when adding this to a `Set` or as a key in a `Map`, enabling
|
|
4596
|
+
* lookup via a different instance.
|
|
4597
|
+
*
|
|
4598
|
+
* <!-- runkit:activate -->
|
|
4599
|
+
* ```js
|
|
4600
|
+
* const { List, Set } = require('immutable@4.0.0-rc.9');
|
|
4601
|
+
* const a = List([ 1, 2, 3 ]);
|
|
4602
|
+
* const b = List([ 1, 2, 3 ]);
|
|
4603
|
+
* assert.notStrictEqual(a, b); // different instances
|
|
4604
|
+
* const set = Set([ a ]);
|
|
4605
|
+
* assert.equal(set.has(b), true);
|
|
4606
|
+
* ```
|
|
4607
|
+
*
|
|
4608
|
+
* Note: hashCode() MUST return a Uint32 number. The easiest way to
|
|
4609
|
+
* guarantee this is to return `myHash | 0` from a custom implementation.
|
|
4610
|
+
*
|
|
4611
|
+
* If two values have the same `hashCode`, they are [not guaranteed
|
|
4612
|
+
* to be equal][Hash Collision]. If two values have different `hashCode`s,
|
|
4613
|
+
* they must not be equal.
|
|
4614
|
+
*
|
|
4615
|
+
* Note: `hashCode()` is not guaranteed to always be called before
|
|
4616
|
+
* `equals()`. Most but not all Immutable.js collections use hash codes to
|
|
4617
|
+
* organize their internal data structures, while all Immutable.js
|
|
4618
|
+
* collections use equality during lookups.
|
|
4619
|
+
*
|
|
4620
|
+
* [Hash Collision]: http://en.wikipedia.org/wiki/Collision_(computer_science)
|
|
4621
|
+
*/
|
|
4622
|
+
hashCode(): number;
|
|
4623
|
+
}
|
|
4624
|
+
|
|
4625
|
+
/**
|
|
4626
|
+
* Deeply converts plain JS objects and arrays to Immutable Maps and Lists.
|
|
4627
|
+
*
|
|
4628
|
+
* If a `reviver` is optionally provided, it will be called with every
|
|
4629
|
+
* collection as a Seq (beginning with the most nested collections
|
|
4630
|
+
* and proceeding to the top-level collection itself), along with the key
|
|
4631
|
+
* refering to each collection and the parent JS object provided as `this`.
|
|
4632
|
+
* For the top level, object, the key will be `""`. This `reviver` is expected
|
|
4633
|
+
* to return a new Immutable Collection, allowing for custom conversions from
|
|
4634
|
+
* deep JS objects. Finally, a `path` is provided which is the sequence of
|
|
4635
|
+
* keys to this value from the starting value.
|
|
4636
|
+
*
|
|
4637
|
+
* `reviver` acts similarly to the [same parameter in `JSON.parse`][1].
|
|
4638
|
+
*
|
|
4639
|
+
* If `reviver` is not provided, the default behavior will convert Objects
|
|
4640
|
+
* into Maps and Arrays into Lists like so:
|
|
4641
|
+
*
|
|
4642
|
+
* <!-- runkit:activate -->
|
|
4643
|
+
* ```js
|
|
4644
|
+
* const { fromJS, isKeyed } = require('immutable@4.0.0-rc.9')
|
|
4645
|
+
* function (key, value) {
|
|
4646
|
+
* return isKeyed(value) ? value.Map() : value.toList()
|
|
4647
|
+
* }
|
|
4648
|
+
* ```
|
|
4649
|
+
*
|
|
4650
|
+
* `fromJS` is conservative in its conversion. It will only convert
|
|
4651
|
+
* arrays which pass `Array.isArray` to Lists, and only raw objects (no custom
|
|
4652
|
+
* prototype) to Map.
|
|
4653
|
+
*
|
|
4654
|
+
* Accordingly, this example converts native JS data to OrderedMap and List:
|
|
4655
|
+
*
|
|
4656
|
+
* <!-- runkit:activate -->
|
|
4657
|
+
* ```js
|
|
4658
|
+
* const { fromJS, isKeyed } = require('immutable@4.0.0-rc.9')
|
|
4659
|
+
* fromJS({ a: {b: [10, 20, 30]}, c: 40}, function (key, value, path) {
|
|
4660
|
+
* console.log(key, value, path)
|
|
4661
|
+
* return isKeyed(value) ? value.toOrderedMap() : value.toList()
|
|
4662
|
+
* })
|
|
4663
|
+
*
|
|
4664
|
+
* > "b", [ 10, 20, 30 ], [ "a", "b" ]
|
|
4665
|
+
* > "a", {b: [10, 20, 30]}, [ "a" ]
|
|
4666
|
+
* > "", {a: {b: [10, 20, 30]}, c: 40}, []
|
|
4667
|
+
* ```
|
|
4668
|
+
*
|
|
4669
|
+
* Keep in mind, when using JS objects to construct Immutable Maps, that
|
|
4670
|
+
* JavaScript Object properties are always strings, even if written in a
|
|
4671
|
+
* quote-less shorthand, while Immutable Maps accept keys of any type.
|
|
4672
|
+
*
|
|
4673
|
+
* <!-- runkit:activate -->
|
|
4674
|
+
* ```js
|
|
4675
|
+
* const { Map } = require('immutable@4.0.0-rc.9')
|
|
4676
|
+
* let obj = { 1: "one" };
|
|
4677
|
+
* Object.keys(obj); // [ "1" ]
|
|
4678
|
+
* assert.equal(obj["1"], obj[1]); // "one" === "one"
|
|
4679
|
+
*
|
|
4680
|
+
* let map = Map(obj);
|
|
4681
|
+
* assert.notEqual(map.get("1"), map.get(1)); // "one" !== undefined
|
|
4682
|
+
* ```
|
|
4683
|
+
*
|
|
4684
|
+
* Property access for JavaScript Objects first converts the key to a string,
|
|
4685
|
+
* but since Immutable Map keys can be of any type the argument to `get()` is
|
|
4686
|
+
* not altered.
|
|
4687
|
+
*
|
|
4688
|
+
* [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Example.3A_Using_the_reviver_parameter
|
|
4689
|
+
* "Using the reviver parameter"
|
|
4690
|
+
*/
|
|
4691
|
+
export function fromJS(
|
|
4692
|
+
jsValue: any,
|
|
4693
|
+
reviver?: (
|
|
4694
|
+
key: string | number,
|
|
4695
|
+
sequence: Collection.Keyed<string, any> | Collection.Indexed<any>,
|
|
4696
|
+
path?: Array<string | number>
|
|
4697
|
+
) => any
|
|
4698
|
+
): any;
|
|
4699
|
+
|
|
4700
|
+
/**
|
|
4701
|
+
* Value equality check with semantics similar to `Object.is`, but treats
|
|
4702
|
+
* Immutable `Collection`s as values, equal if the second `Collection` includes
|
|
4703
|
+
* equivalent values.
|
|
4704
|
+
*
|
|
4705
|
+
* It's used throughout Immutable when checking for equality, including `Map`
|
|
4706
|
+
* key equality and `Set` membership.
|
|
4707
|
+
*
|
|
4708
|
+
* <!-- runkit:activate -->
|
|
4709
|
+
* ```js
|
|
4710
|
+
* const { Map, is } = require('immutable@4.0.0-rc.9')
|
|
4711
|
+
* const map1 = Map({ a: 1, b: 1, c: 1 })
|
|
4712
|
+
* const map2 = Map({ a: 1, b: 1, c: 1 })
|
|
4713
|
+
* assert.equal(map1 !== map2, true)
|
|
4714
|
+
* assert.equal(Object.is(map1, map2), false)
|
|
4715
|
+
* assert.equal(is(map1, map2), true)
|
|
4716
|
+
* ```
|
|
4717
|
+
*
|
|
4718
|
+
* `is()` compares primitive types like strings and numbers, Immutable.js
|
|
4719
|
+
* collections like `Map` and `List`, but also any custom object which
|
|
4720
|
+
* implements `ValueObject` by providing `equals()` and `hashCode()` methods.
|
|
4721
|
+
*
|
|
4722
|
+
* Note: Unlike `Object.is`, `Immutable.is` assumes `0` and `-0` are the same
|
|
4723
|
+
* value, matching the behavior of ES6 Map key equality.
|
|
4724
|
+
*/
|
|
4725
|
+
export function is(first: any, second: any): boolean;
|
|
4786
4726
|
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4727
|
+
/**
|
|
4728
|
+
* The `hash()` function is an important part of how Immutable determines if
|
|
4729
|
+
* two values are equivalent and is used to determine how to store those
|
|
4730
|
+
* values. Provided with any value, `hash()` will return a 31-bit integer.
|
|
4731
|
+
*
|
|
4732
|
+
* When designing Objects which may be equal, it's important than when a
|
|
4733
|
+
* `.equals()` method returns true, that both values `.hashCode()` method
|
|
4734
|
+
* return the same value. `hash()` may be used to produce those values.
|
|
4735
|
+
*
|
|
4736
|
+
* For non-Immutable Objects that do not provide a `.hashCode()` functions
|
|
4737
|
+
* (including plain Objects, plain Arrays, Date objects, etc), a unique hash
|
|
4738
|
+
* value will be created for each *instance*. That is, the create hash
|
|
4739
|
+
* represents referential equality, and not value equality for Objects. This
|
|
4740
|
+
* ensures that if that Object is mutated over time that its hash code will
|
|
4741
|
+
* remain consistent, allowing Objects to be used as keys and values in
|
|
4742
|
+
* Immutable.js collections.
|
|
4743
|
+
*
|
|
4744
|
+
* Note that `hash()` attempts to balance between speed and avoiding
|
|
4745
|
+
* collisions, however it makes no attempt to produce secure hashes.
|
|
4746
|
+
*
|
|
4747
|
+
* *New in Version 4.0*
|
|
4748
|
+
*/
|
|
4749
|
+
export function hash(value: any): number;
|
|
4803
4750
|
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4751
|
+
/**
|
|
4752
|
+
* True if `maybeImmutable` is an Immutable Collection or Record.
|
|
4753
|
+
*
|
|
4754
|
+
* Note: Still returns true even if the collections is within a `withMutations()`.
|
|
4755
|
+
*
|
|
4756
|
+
* <!-- runkit:activate -->
|
|
4757
|
+
* ```js
|
|
4758
|
+
* const { isImmutable, Map, List, Stack } = require('immutable@4.0.0-rc.9');
|
|
4759
|
+
* isImmutable([]); // false
|
|
4760
|
+
* isImmutable({}); // false
|
|
4761
|
+
* isImmutable(Map()); // true
|
|
4762
|
+
* isImmutable(List()); // true
|
|
4763
|
+
* isImmutable(Stack()); // true
|
|
4764
|
+
* isImmutable(Map().asMutable()); // true
|
|
4765
|
+
* ```
|
|
4766
|
+
*/
|
|
4767
|
+
export function isImmutable(maybeImmutable: any): maybeImmutable is Collection<any, any>;
|
|
4815
4768
|
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
*/
|
|
4831
|
-
min(comparator?: (valueA: V, valueB: V) => number): V | undefined;
|
|
4769
|
+
/**
|
|
4770
|
+
* True if `maybeCollection` is a Collection, or any of its subclasses.
|
|
4771
|
+
*
|
|
4772
|
+
* <!-- runkit:activate -->
|
|
4773
|
+
* ```js
|
|
4774
|
+
* const { isCollection, Map, List, Stack } = require('immutable@4.0.0-rc.9');
|
|
4775
|
+
* isCollection([]); // false
|
|
4776
|
+
* isCollection({}); // false
|
|
4777
|
+
* isCollection(Map()); // true
|
|
4778
|
+
* isCollection(List()); // true
|
|
4779
|
+
* isCollection(Stack()); // true
|
|
4780
|
+
* ```
|
|
4781
|
+
*/
|
|
4782
|
+
export function isCollection(maybeCollection: any): maybeCollection is Collection<any, any>;
|
|
4832
4783
|
|
|
4833
|
-
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4784
|
+
/**
|
|
4785
|
+
* True if `maybeKeyed` is a Collection.Keyed, or any of its subclasses.
|
|
4786
|
+
*
|
|
4787
|
+
* <!-- runkit:activate -->
|
|
4788
|
+
* ```js
|
|
4789
|
+
* const { isKeyed, Map, List, Stack } = require('immutable@4.0.0-rc.9');
|
|
4790
|
+
* isKeyed([]); // false
|
|
4791
|
+
* isKeyed({}); // false
|
|
4792
|
+
* isKeyed(Map()); // true
|
|
4793
|
+
* isKeyed(List()); // false
|
|
4794
|
+
* isKeyed(Stack()); // false
|
|
4795
|
+
* ```
|
|
4796
|
+
*/
|
|
4797
|
+
export function isKeyed(maybeKeyed: any): maybeKeyed is Collection.Keyed<any, any>;
|
|
4844
4798
|
|
|
4799
|
+
/**
|
|
4800
|
+
* True if `maybeIndexed` is a Collection.Indexed, or any of its subclasses.
|
|
4801
|
+
*
|
|
4802
|
+
* <!-- runkit:activate -->
|
|
4803
|
+
* ```js
|
|
4804
|
+
* const { isIndexed, Map, List, Stack, Set } = require('immutable@4.0.0-rc.9');
|
|
4805
|
+
* isIndexed([]); // false
|
|
4806
|
+
* isIndexed({}); // false
|
|
4807
|
+
* isIndexed(Map()); // false
|
|
4808
|
+
* isIndexed(List()); // true
|
|
4809
|
+
* isIndexed(Stack()); // true
|
|
4810
|
+
* isIndexed(Set()); // false
|
|
4811
|
+
* ```
|
|
4812
|
+
*/
|
|
4813
|
+
export function isIndexed(maybeIndexed: any): maybeIndexed is Collection.Indexed<any>;
|
|
4845
4814
|
|
|
4846
|
-
|
|
4815
|
+
/**
|
|
4816
|
+
* True if `maybeAssociative` is either a Keyed or Indexed Collection.
|
|
4817
|
+
*
|
|
4818
|
+
* <!-- runkit:activate -->
|
|
4819
|
+
* ```js
|
|
4820
|
+
* const { isAssociative, Map, List, Stack, Set } = require('immutable@4.0.0-rc.9');
|
|
4821
|
+
* isAssociative([]); // false
|
|
4822
|
+
* isAssociative({}); // false
|
|
4823
|
+
* isAssociative(Map()); // true
|
|
4824
|
+
* isAssociative(List()); // true
|
|
4825
|
+
* isAssociative(Stack()); // true
|
|
4826
|
+
* isAssociative(Set()); // false
|
|
4827
|
+
* ```
|
|
4828
|
+
*/
|
|
4829
|
+
export function isAssociative(maybeAssociative: any): maybeAssociative is Collection.Keyed<any, any> | Collection.Indexed<any>;
|
|
4847
4830
|
|
|
4848
|
-
|
|
4849
|
-
|
|
4850
|
-
|
|
4851
|
-
|
|
4831
|
+
/**
|
|
4832
|
+
* True if `maybeOrdered` is a Collection where iteration order is well
|
|
4833
|
+
* defined. True for Collection.Indexed as well as OrderedMap and OrderedSet.
|
|
4834
|
+
*
|
|
4835
|
+
* <!-- runkit:activate -->
|
|
4836
|
+
* ```js
|
|
4837
|
+
* const { isOrdered, Map, OrderedMap, List, Set } = require('immutable@4.0.0-rc.9');
|
|
4838
|
+
* isOrdered([]); // false
|
|
4839
|
+
* isOrdered({}); // false
|
|
4840
|
+
* isOrdered(Map()); // false
|
|
4841
|
+
* isOrdered(OrderedMap()); // true
|
|
4842
|
+
* isOrdered(List()); // true
|
|
4843
|
+
* isOrdered(Set()); // false
|
|
4844
|
+
* ```
|
|
4845
|
+
*/
|
|
4846
|
+
export function isOrdered(maybeOrdered: any): boolean;
|
|
4852
4847
|
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4848
|
+
/**
|
|
4849
|
+
* True if `maybeValue` is a JavaScript Object which has *both* `equals()`
|
|
4850
|
+
* and `hashCode()` methods.
|
|
4851
|
+
*
|
|
4852
|
+
* Any two instances of *value objects* can be compared for value equality with
|
|
4853
|
+
* `Immutable.is()` and can be used as keys in a `Map` or members in a `Set`.
|
|
4854
|
+
*/
|
|
4855
|
+
export function isValueObject(maybeValue: any): maybeValue is ValueObject;
|
|
4858
4856
|
|
|
4859
4857
|
/**
|
|
4860
4858
|
* Returns the value within the provided collection associated with the
|
|
@@ -4865,7 +4863,7 @@
|
|
|
4865
4863
|
*
|
|
4866
4864
|
* <!-- runkit:activate -->
|
|
4867
4865
|
* ```js
|
|
4868
|
-
* const { get } = require('immutable@4.0.0-rc.
|
|
4866
|
+
* const { get } = require('immutable@4.0.0-rc.9')
|
|
4869
4867
|
* get([ 'dog', 'frog', 'cat' ], 2) // 'frog'
|
|
4870
4868
|
* get({ x: 123, y: 456 }, 'x') // 123
|
|
4871
4869
|
* get({ x: 123, y: 456 }, 'z', 'ifNotSet') // 'ifNotSet'
|
|
@@ -4889,14 +4887,14 @@
|
|
|
4889
4887
|
*
|
|
4890
4888
|
* <!-- runkit:activate -->
|
|
4891
4889
|
* ```js
|
|
4892
|
-
* const { has } = require('immutable@4.0.0-rc.
|
|
4890
|
+
* const { has } = require('immutable@4.0.0-rc.9')
|
|
4893
4891
|
* has([ 'dog', 'frog', 'cat' ], 2) // true
|
|
4894
4892
|
* has([ 'dog', 'frog', 'cat' ], 5) // false
|
|
4895
4893
|
* has({ x: 123, y: 456 }, 'x') // true
|
|
4896
4894
|
* has({ x: 123, y: 456 }, 'z') // false
|
|
4897
4895
|
* ```
|
|
4898
4896
|
*/
|
|
4899
|
-
export function has(collection: Object, key:
|
|
4897
|
+
export function has(collection: Object, key: any): boolean;
|
|
4900
4898
|
|
|
4901
4899
|
/**
|
|
4902
4900
|
* Returns a copy of the collection with the value at key removed.
|
|
@@ -4907,7 +4905,7 @@
|
|
|
4907
4905
|
*
|
|
4908
4906
|
* <!-- runkit:activate -->
|
|
4909
4907
|
* ```js
|
|
4910
|
-
* const { remove } = require('immutable@4.0.0-rc.
|
|
4908
|
+
* const { remove } = require('immutable@4.0.0-rc.9')
|
|
4911
4909
|
* const originalArray = [ 'dog', 'frog', 'cat' ]
|
|
4912
4910
|
* remove(originalArray, 1) // [ 'dog', 'cat' ]
|
|
4913
4911
|
* console.log(originalArray) // [ 'dog', 'frog', 'cat' ]
|
|
@@ -4917,10 +4915,10 @@
|
|
|
4917
4915
|
* ```
|
|
4918
4916
|
*/
|
|
4919
4917
|
export function remove<K, C extends Collection<K, any>>(collection: C, key: K): C;
|
|
4920
|
-
export function remove<TProps,
|
|
4918
|
+
export function remove<TProps, C extends Record<TProps>, K extends keyof TProps>(collection: C, key: K): C;
|
|
4921
4919
|
export function remove<C extends Array<any>>(collection: C, key: number): C;
|
|
4922
|
-
export function remove<C, K extends keyof
|
|
4923
|
-
export function remove<
|
|
4920
|
+
export function remove<C, K extends keyof C>(collection: C, key: K): C;
|
|
4921
|
+
export function remove<C extends {[key: string]: any}, K extends keyof C>(collection: C, key: K): C;
|
|
4924
4922
|
|
|
4925
4923
|
/**
|
|
4926
4924
|
* Returns a copy of the collection with the value at key set to the provided
|
|
@@ -4932,7 +4930,7 @@
|
|
|
4932
4930
|
*
|
|
4933
4931
|
* <!-- runkit:activate -->
|
|
4934
4932
|
* ```js
|
|
4935
|
-
* const { set } = require('immutable@4.0.0-rc.
|
|
4933
|
+
* const { set } = require('immutable@4.0.0-rc.9')
|
|
4936
4934
|
* const originalArray = [ 'dog', 'frog', 'cat' ]
|
|
4937
4935
|
* set(originalArray, 1, 'cow') // [ 'dog', 'cow', 'cat' ]
|
|
4938
4936
|
* console.log(originalArray) // [ 'dog', 'frog', 'cat' ]
|
|
@@ -4957,7 +4955,7 @@
|
|
|
4957
4955
|
*
|
|
4958
4956
|
* <!-- runkit:activate -->
|
|
4959
4957
|
* ```js
|
|
4960
|
-
* const { update } = require('immutable@4.0.0-rc.
|
|
4958
|
+
* const { update } = require('immutable@4.0.0-rc.9')
|
|
4961
4959
|
* const originalArray = [ 'dog', 'frog', 'cat' ]
|
|
4962
4960
|
* update(originalArray, 1, val => val.toUpperCase()) // [ 'dog', 'FROG', 'cat' ]
|
|
4963
4961
|
* console.log(originalArray) // [ 'dog', 'frog', 'cat' ]
|
|
@@ -4971,11 +4969,11 @@
|
|
|
4971
4969
|
export function update<TProps, C extends Record<TProps>, K extends keyof TProps>(record: C, key: K, updater: (value: TProps[K]) => TProps[K]): C;
|
|
4972
4970
|
export function update<TProps, C extends Record<TProps>, K extends keyof TProps, NSV>(record: C, key: K, notSetValue: NSV, updater: (value: TProps[K] | NSV) => TProps[K]): C;
|
|
4973
4971
|
export function update<V>(collection: Array<V>, key: number, updater: (value: V) => V): Array<V>;
|
|
4974
|
-
export function update<V, NSV>(collection: Array<V>, key: number, notSetValue: NSV, updater: (value: V | NSV) => V):
|
|
4972
|
+
export function update<V, NSV>(collection: Array<V>, key: number, notSetValue: NSV, updater: (value: V | NSV) => V): Array<V>;
|
|
4975
4973
|
export function update<C, K extends keyof C>(object: C, key: K, updater: (value: C[K]) => C[K]): C;
|
|
4976
4974
|
export function update<C, K extends keyof C, NSV>(object: C, key: K, notSetValue: NSV, updater: (value: C[K] | NSV) => C[K]): C;
|
|
4977
|
-
export function update<V, C extends {[key: string]: V}>(collection: C, key: K, updater: (value: V) => V): {[key: string]: V};
|
|
4978
|
-
export function update<V, C extends {[key: string]: V}, NSV>(collection: C, key: K, notSetValue: NSV, updater: (value: V | NSV) => V): {[key: string]: V};
|
|
4975
|
+
export function update<V, C extends {[key: string]: V}, K extends keyof C>(collection: C, key: K, updater: (value: V) => V): {[key: string]: V};
|
|
4976
|
+
export function update<V, C extends {[key: string]: V}, K extends keyof C, NSV>(collection: C, key: K, notSetValue: NSV, updater: (value: V | NSV) => V): {[key: string]: V};
|
|
4979
4977
|
|
|
4980
4978
|
/**
|
|
4981
4979
|
* Returns the value at the provided key path starting at the provided
|
|
@@ -4986,7 +4984,7 @@
|
|
|
4986
4984
|
*
|
|
4987
4985
|
* <!-- runkit:activate -->
|
|
4988
4986
|
* ```js
|
|
4989
|
-
* const { getIn } = require('immutable@4.0.0-rc.
|
|
4987
|
+
* const { getIn } = require('immutable@4.0.0-rc.9')
|
|
4990
4988
|
* getIn({ x: { y: { z: 123 }}}, ['x', 'y', 'z']) // 123
|
|
4991
4989
|
* getIn({ x: { y: { z: 123 }}}, ['x', 'q', 'p'], 'ifNotSet') // 'ifNotSet'
|
|
4992
4990
|
* ```
|
|
@@ -5001,7 +4999,7 @@
|
|
|
5001
4999
|
*
|
|
5002
5000
|
* <!-- runkit:activate -->
|
|
5003
5001
|
* ```js
|
|
5004
|
-
* const { hasIn } = require('immutable@4.0.0-rc.
|
|
5002
|
+
* const { hasIn } = require('immutable@4.0.0-rc.9')
|
|
5005
5003
|
* hasIn({ x: { y: { z: 123 }}}, ['x', 'y', 'z']) // true
|
|
5006
5004
|
* hasIn({ x: { y: { z: 123 }}}, ['x', 'q', 'p']) // false
|
|
5007
5005
|
* ```
|
|
@@ -5016,7 +5014,7 @@
|
|
|
5016
5014
|
*
|
|
5017
5015
|
* <!-- runkit:activate -->
|
|
5018
5016
|
* ```js
|
|
5019
|
-
* const { removeIn } = require('immutable@4.0.0-rc.
|
|
5017
|
+
* const { removeIn } = require('immutable@4.0.0-rc.9')
|
|
5020
5018
|
* const original = { x: { y: { z: 123 }}}
|
|
5021
5019
|
* removeIn(original, ['x', 'y', 'z']) // { x: { y: {}}}
|
|
5022
5020
|
* console.log(original) // { x: { y: { z: 123 }}}
|
|
@@ -5033,7 +5031,7 @@
|
|
|
5033
5031
|
*
|
|
5034
5032
|
* <!-- runkit:activate -->
|
|
5035
5033
|
* ```js
|
|
5036
|
-
* const { setIn } = require('immutable@4.0.0-rc.
|
|
5034
|
+
* const { setIn } = require('immutable@4.0.0-rc.9')
|
|
5037
5035
|
* const original = { x: { y: { z: 123 }}}
|
|
5038
5036
|
* setIn(original, ['x', 'y', 'z'], 456) // { x: { y: { z: 456 }}}
|
|
5039
5037
|
* console.log(original) // { x: { y: { z: 123 }}}
|
|
@@ -5050,7 +5048,7 @@
|
|
|
5050
5048
|
*
|
|
5051
5049
|
* <!-- runkit:activate -->
|
|
5052
5050
|
* ```js
|
|
5053
|
-
* const { setIn } = require('immutable@4.0.0-rc.
|
|
5051
|
+
* const { setIn } = require('immutable@4.0.0-rc.9')
|
|
5054
5052
|
* const original = { x: { y: { z: 123 }}}
|
|
5055
5053
|
* setIn(original, ['x', 'y', 'z'], val => val * 6) // { x: { y: { z: 738 }}}
|
|
5056
5054
|
* console.log(original) // { x: { y: { z: 123 }}}
|
|
@@ -5067,7 +5065,7 @@
|
|
|
5067
5065
|
*
|
|
5068
5066
|
* <!-- runkit:activate -->
|
|
5069
5067
|
* ```js
|
|
5070
|
-
* const { merge } = require('immutable@4.0.0-rc.
|
|
5068
|
+
* const { merge } = require('immutable@4.0.0-rc.9')
|
|
5071
5069
|
* const original = { x: 123, y: 456 }
|
|
5072
5070
|
* merge(original, { y: 789, z: 'abc' }) // { x: 123, y: 789, z: 'abc' }
|
|
5073
5071
|
* console.log(original) // { x: { y: { z: 123 }}}
|
|
@@ -5087,7 +5085,7 @@
|
|
|
5087
5085
|
*
|
|
5088
5086
|
* <!-- runkit:activate -->
|
|
5089
5087
|
* ```js
|
|
5090
|
-
* const { mergeWith } = require('immutable@4.0.0-rc.
|
|
5088
|
+
* const { mergeWith } = require('immutable@4.0.0-rc.9')
|
|
5091
5089
|
* const original = { x: 123, y: 456 }
|
|
5092
5090
|
* mergeWith(
|
|
5093
5091
|
* (oldVal, newVal) => oldVal + newVal,
|
|
@@ -5112,7 +5110,7 @@
|
|
|
5112
5110
|
*
|
|
5113
5111
|
* <!-- runkit:activate -->
|
|
5114
5112
|
* ```js
|
|
5115
|
-
* const { merge } = require('immutable@4.0.0-rc.
|
|
5113
|
+
* const { merge } = require('immutable@4.0.0-rc.9')
|
|
5116
5114
|
* const original = { x: { y: 123 }}
|
|
5117
5115
|
* merge(original, { x: { z: 456 }}) // { x: { y: 123, z: 456 }}
|
|
5118
5116
|
* console.log(original) // { x: { y: 123 }}
|
|
@@ -5133,7 +5131,7 @@
|
|
|
5133
5131
|
*
|
|
5134
5132
|
* <!-- runkit:activate -->
|
|
5135
5133
|
* ```js
|
|
5136
|
-
* const { merge } = require('immutable@4.0.0-rc.
|
|
5134
|
+
* const { merge } = require('immutable@4.0.0-rc.9')
|
|
5137
5135
|
* const original = { x: { y: 123 }}
|
|
5138
5136
|
* mergeDeepWith(
|
|
5139
5137
|
* (oldVal, newVal) => oldVal + newVal,
|
|
@@ -5144,7 +5142,7 @@
|
|
|
5144
5142
|
* ```
|
|
5145
5143
|
*/
|
|
5146
5144
|
export function mergeDeepWith<C>(
|
|
5147
|
-
merger: (oldVal: any, newVal: any, key: any) =>
|
|
5145
|
+
merger: (oldVal: any, newVal: any, key: any) => any,
|
|
5148
5146
|
collection: C,
|
|
5149
5147
|
...collections: Array<Iterable<any> | Iterable<[any, any]> | {[key: string]: any}>
|
|
5150
5148
|
): C;
|