github immutable-js/immutable-js 2.3.0

latest releases: v5.0.0-beta.5, v4.3.5, v5.0.0-beta.4...
9 years ago

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.

Don't miss a new immutable-js release

NewReleases is sending notifications on new releases.