ThinkSSL🔒 一键申购 5分钟快速签发 30天无理由退款 购买更放心 广告
https://immutable-js.github.io/immutable-js/ # Immutable collections for JavaScript [Immutable](http://en.wikipedia.org/wiki/Immutable_object)data cannot be changed once created, leading to much simpler application development, no defensive copying, and enabling advanced memoization and change detection techniques with simple logic.[Persistent](http://en.wikipedia.org/wiki/Persistent_data_structure)data presents a mutative API which does not update the data in-place, but instead always yields new updated data. Immutable.js provides many Persistent Immutable data structures including: [List](https://immutable-js.github.io/immutable-js/docs/#/List),[Stack](https://immutable-js.github.io/immutable-js/docs/#/Stack),[Map](https://immutable-js.github.io/immutable-js/docs/#/Map),[OrderedMap](https://immutable-js.github.io/immutable-js/docs/#/OrderedMap),[Set](https://immutable-js.github.io/immutable-js/docs/#/Set),[OrderedSet](https://immutable-js.github.io/immutable-js/docs/#/OrderedSet) and [Record](https://immutable-js.github.io/immutable-js/docs/#/Record). These data structures are highly efficient on modern JavaScript VMs by using structural sharing via[hash maps tries](http://en.wikipedia.org/wiki/Hash_array_mapped_trie)and[vector tries](http://hypirion.com/musings/understanding-persistent-vector-pt-1)as popularized by Clojure and Scala, minimizing the need to copy or cache data. Immutable.js also provides a lazy [Seq](https://immutable-js.github.io/immutable-js/docs/#/Seq), allowing efficient chaining of collection methods like`map`and`filter`without creating intermediate representations. Create some [Seq](https://immutable-js.github.io/immutable-js/docs/#/Seq) with [Range](https://immutable-js.github.io/immutable-js/docs/#/Range) and [Repeat](https://immutable-js.github.io/immutable-js/docs/#/Repeat). ## Getting started Install [immutable](https://immutable-js.github.io/immutable-js/docs/#/)using npm. `npm install immutable` Then require it into any module. ```js const { Map } = require('immutable'); const map1 = Map({ a: 1, b: 2, c: 3 }); const map2 = map1.set('b', 50); map1.get('b') + " vs. " + map2.get('b'); // 2 vs. 50` ```