Skip to content

2.3.0

Compare
Choose a tag to compare
@leebyron leebyron released this 12 Oct 07:09
· 1261 commits to main since this release

Iterators!

All Sequences, including both concrete collections (Map, Vector, Set) and lazy Sequences (mapped, filtered) can be iterated.

API:

values() returns an iterator object where each call to next() provides the next value.

keys() returns an iterator object where each call to next() provides the next key.

entries() returns an iterator object where each call to next() provides the next entry as a [key, value] tuple.

Example:

var myMap = Immutable.Map([['A', 1], ['B', 2], ['C', 3]]);
var entries = myMap.entries();
entries.next() // { value: ['A', 1], done: false }
entries.next() // { value: ['B', 2], done: false }
entries.next() // { value: ['C', 3], done: false }
entries.next() // { value: undefined, done: true }

All Sequences also support iteration via the @@iterator and Symbol.iterator methods, so they can be used in ES6 for-of comprehensions.

New

  • interpose()
  • Sequence documentation is easier to follow now that methods are categorized and alphabetized.
  • A number of lazy sequence optimizations. For example, seq.flip().reverse().flip() becomes seq.reverse().
  • Optimizations that allow get() and has() to be O(1) on lazy sequences.

Bugs

  • Equality checking via Immutable.is or seq.equals() could throw or incorrectly return false.