This release brings new functionality and many fixes.
Iterableis renamed to Collection
+ Collection.[Symbol.iterator] + Collection.toJSON + Collection.update + Collection.Indexed.[Symbol.iterator] + Collection.Indexed.toJSON + Collection.Indexed.update + Collection.Indexed.zipAll + Collection.Keyed.[Symbol.iterator] + Collection.Keyed.toJSON + Collection.Keyed.update + Collection.Set.[Symbol.iterator] + Collection.Set.toJSON + Collection.Set.update - Collection.size - Collection.Indexed.size - Collection.Keyed.size - Collection.Set.size + List.[Symbol.iterator] + List.toJSON + List.wasAltered + List.zipAll - List.mergeDeep - List.mergeDeepWith - List.mergeWith + Map.[Symbol.iterator] + Map.deleteAll + Map.toJSON + Map.wasAltered + OrderedMap.[Symbol.iterator] + OrderedMap.deleteAll + OrderedMap.toJSON + OrderedMap.wasAltered + OrderedSet.[Symbol.iterator] + OrderedSet.toJSON + OrderedSet.update + OrderedSet.wasAltered + OrderedSet.zip + OrderedSet.zipAll + OrderedSet.zipWith + Record.[Symbol.iterator] + Record.asImmutable + Record.asMutable + Record.clear + Record.delete + Record.deleteIn + Record.merge + Record.mergeDeep + Record.mergeDeepIn + Record.mergeDeepWith + Record.mergeIn + Record.mergeWith + Record.set + Record.setIn + Record.toJSON + Record.update + Record.updateIn + Record.wasAltered + Record.withMutations + Record.Factory.displayName - Record.butLast - Record.concat - Record.count - Record.countBy - Record.entries - Record.entrySeq - Record.every - Record.filter - Record.filterNot - Record.find - Record.findEntry - Record.findKey - Record.findLast - Record.findLastEntry - Record.findLastKey - Record.first - Record.flatMap - Record.flatten - Record.flip - Record.forEach - Record.groupBy - Record.includes - Record.isEmpty - Record.isSubset - Record.isSuperset - Record.join - Record.keyOf - Record.keySeq - Record.keys - Record.last - Record.lastKeyOf - Record.map - Record.mapEntries - Record.mapKeys - Record.max - Record.maxBy - Record.min - Record.minBy - Record.reduce - Record.reduceRight - Record.rest - Record.reverse - Record.skip - Record.skipLast - Record.skipUntil - Record.skipWhile - Record.slice - Record.some - Record.sort - Record.sortBy - Record.take - Record.takeLast - Record.takeUntil - Record.takeWhile - Record.toArray - Record.toIndexedSeq - Record.toKeyedSeq - Record.toList - Record.toMap - Record.toOrderedMap - Record.toOrderedSet - Record.toSet - Record.toSetSeq - Record.toStack - Record.valueSeq - Record.values + Seq.[Symbol.iterator] + Seq.toJSON + Seq.update + Seq.Indexed.[Symbol.iterator] + Seq.Indexed.toJSON + Seq.Indexed.update + Seq.Indexed.zipAll + Seq.Keyed.[Symbol.iterator] + Seq.Keyed.toJSON + Seq.Keyed.update + Seq.Set.[Symbol.iterator] + Seq.Set.toJSON + Seq.Set.update + Set.[Symbol.iterator] + Set.toJSON + Set.update + Set.wasAltered + Stack.[Symbol.iterator] + Stack.toJSON + Stack.update + Stack.wasAltered + Stack.zipAll + ValueObject.equals + ValueObject.hashCode - Iterable.* - Iterable.Indexed.* - Iterable.Keyed.* - Iterable.Set.*
There were mostly bugfixes and improvements since RC 12. Upgrading should be painless for most users.
However, there is one breaking change: The behavior of
mergeDeep has changed. See below for details.
No longer use value-equality within
This rectifies an inconsistent behavior between
x.mergeDeep(y)where merge would use
===on leaf values to determine return-self optimizations, while mergeDeep would use
is(). This improves consistency across the library and avoids a possible performance pitfall.
No longer deeply coerce argument to merge() (#1339)
Previously, the argument provided to
merge()was deeply converted to Immutable collections via
fromJS(). This was the only function in the library which calls
fromJS()indirectly, and it was surprising and made it difficult to understand what the result of
merge()would be. Now, the value provided to
merge()is only shallowly converted to an Immutable collection, similar to related methods in the library. This may change the behavior of your calls to
Replace incompatible collections when merging nested data (#1840)
It will no longer merge lists of tuples into maps. For more information see #1840 and the updated
Concat Lists when merging deeply (#1344)
map.mergeDeep()with a value containing a
Listwould replace the values in the original List. This has always been confusing, and does not properly treat
Listas a monoid. Now,
List.mergeis simply an alias for
map.mergeDeep()will concatenate deeply-found lists instead of replacing them.
Remove IteratorSequence. Do not attempt to detect iterators in
Iterables can still be provided to
Seq(), and most Iterators are also Iterables, so this change should not affect the vast majority of uses. For more information, see PR #1589
Seq.of() (#1311, #1310)
This method has been removed since it cannot be correctly typed. It's recommended to convert
Seq.of(1, 2, 3)to
Seq([1, 2, 3]).
isImmutable() now returns true for collections currently within a
withMutations() call. (#1374)
isImmutable()did double-duty of both determining if a value was a Collection or Record from this library as well as if it was outside a
withMutations()call. This latter case caused confusion and was rarely used.
KeyedCollection.toArray() returns array of tuples. (#1340)
toArray()on a keyed collection (incl
OrderedMap) would discard keys and return an Array of values. This has always been confusing, and differs from
Array.from(). Now, calling
toArray()on a keyed collection will return an Array of
[key, value]tuples, matching the behavior of
list.concat() now has a slightly more efficient implementation and
map.concat() is an alias for
In rare cases, this may affect use of
map.concat()which expected slightly different behavior from
Iterableclass has been renamed to
isIterable()has been renamed to
isCollection(). Aliases with the existing names exist to make transitioning code easier.
forEach) no longer exist on Records.
clear()no longer exist on Records.
Causes some hash values to change, which could impact the order of iteration of values in some Maps (which are already advertised as unordered, but highlighting just to be safe)
This changes the behavior of a few common methods with respect to plain Objects and Arrays where these were previously considered opaque to
setIn(), they now are treated as collections and can be merged into and updated (persistently). This offers an exciting alternative to small Lists and Records.
isAssociativehave been moved from
Iterable.to the top level exports.
toJSON()method performs a shallow conversion (previously it was an alias for
toJS(), which remains a deep conversion).
Iterable<T>as tuple from Map constructor types (#1626)
Typescript allowed constructing a Map with a list of List instances, assuming each was a key, value pair. While this runtime behavior still works, this type led to more issues than it solved, so it has been removed. (Note, this may break previous v4 rcs, but is not a change against v3)
Seq()to support Sets (#1865)
New functions are exported from the
Cursory test is >10% faster than both v3.8.2 and v4.0.0-rc.7, and corrects the regression since v4.0.0-rc.9.
isArrayLikecheck more precise to avoid false positives (#1520)
map()for List, Map, and Set returns itself for no-ops (#1455) (5726bd1)
set(), and more which support both Immutable.js collections and plain Objects and Arrays (#1369)
getIn()has a bad path (668f2236)
isValueObject()helps to detect objects which implement
hashCode(), and type definitions now define the interface
ValueObjectwhich you can implement in your own code to create objects which behave as values and can be keys in Maps or entries in Sets.
fromJS()with a "reviver" function now provides access to the key path to each translated value. (#1118)
Set.mapproduces valid underlying map (#1606)
Support isPlainObj with
constructor key (#1627)
groupBy no longer returns a mutable Map instance (#1602)
mergeWith()method if missing the required
isPlainObj()to workaround Safari bug and allow cross-realm values (#1557)
sizecheck in merge() (#1521)
getIn()no longer throws when encountering a missing path (#1361)
Do not throw from hasIn (#1319)
Long hash codes no longer cause an infinite loop (#1175)
slice() which should return an empty set could return a full set or vice versa (#1245, #1287)
Released in 2017, still the most commonly used release.