This package is an extension of Immutable.js which provides
additional Persistent Immutable data structures SortedMap
and SortedSet
.
These data structures are highly efficient minimizing the need to copy or cache data by structural sharing via B-trees.
npm install immutable-sorted
SortedSet (see more examples on SortedSet page):
> const { SortedSet } = require('immutable-sorted');
> const set1=SortedSet(['orange', 'apple', 'banana']);
SortedSet { "apple", "banana", "orange" }
> const set2=set1.add('mango');
SortedSet { "apple", "banana", "mango", "orange" }
> const set3=set2.delete('banana');
SortedSet { "apple", "mango", "orange" }
SortedMap (see more examples on SortedMap page):
const { SortedMap, isSorted } = require('immutable-sorted');
> const map1=SortedMap([['orange','orange'], ['apple','red'], ['banana','yellow']]);
SortedMap { "apple": "red", "banana": "yellow", "orange": "orange" }
> const map2=map1.set('mango', 'yellow/orange');
SortedMap { "apple": "red", "banana": "yellow", "mango": "yellow/orange", "orange": "orange" }
> const map3=map2.delete('banana');
SortedMap { "apple": "red", "mango": "yellow/orange", "orange": "orange" }
Modified work (Immutable Sorted collections) is MIT Licensed.
Original work (Immutable.js) is BSD-licensed and additional patent grant is provided.