{"id":22793093,"url":"https://github.com/kripod/undefined-iet-2019","last_synced_at":"2025-10-12T01:46:38.340Z","repository":{"id":81145014,"uuid":"184293102","full_name":"kripod/undefined-iet-2019","owner":"kripod","description":"iet-2019 created for undefined","archived":false,"fork":false,"pushed_at":"2019-05-20T13:28:02.000Z","size":1001,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-30T17:22:09.385Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kripod.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-30T16:07:57.000Z","updated_at":"2021-05-05T15:18:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"ddb091a0-7312-43cc-a1d6-7847cd161a20","html_url":"https://github.com/kripod/undefined-iet-2019","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/kripod/undefined-iet-2019","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kripod%2Fundefined-iet-2019","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kripod%2Fundefined-iet-2019/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kripod%2Fundefined-iet-2019/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kripod%2Fundefined-iet-2019/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kripod","download_url":"https://codeload.github.com/kripod/undefined-iet-2019/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kripod%2Fundefined-iet-2019/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279009794,"owners_count":26084648,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-12T03:18:00.960Z","updated_at":"2025-10-12T01:46:38.318Z","avatar_url":"https://github.com/kripod.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Immutable collections for JavaScript\n====================================\n\n[![Build Status](https://travis-ci.com/BME-MIT-IET/undefined-iet-2019.svg?branch=master)](https://travis-ci.com/BME-MIT-IET/undefined-iet-2019)\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/18aa5584e64244df9df00fac27633ac2)](https://app.codacy.com/app/undefined-iet-2019/undefined-iet-2019?utm_source=github.com\u0026utm_medium=referral\u0026utm_content=BME-MIT-IET/undefined-iet-2019\u0026utm_campaign=Badge_Grade_Dashboard)\n[![codecov](https://codecov.io/gh/BME-MIT-IET/undefined-iet-2019/branch/master/graph/badge.svg)](https://codecov.io/gh/BME-MIT-IET/undefined-iet-2019)\n[![Join the chat at https://gitter.im/immutable-js/Lobby](https://badges.gitter.im/immutable-js/Lobby.svg)](https://gitter.im/immutable-js/Lobby?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\n[Immutable][] data cannot be changed once created, leading to much simpler\napplication development, no defensive copying, and enabling advanced memoization\nand change detection techniques with simple logic. [Persistent][] data presents\na mutative API which does not update the data in-place, but instead always\nyields new updated data.\n\nImmutable.js provides many Persistent Immutable data structures including:\n`List`, `Stack`, `Map`, `OrderedMap`, `Set`, `OrderedSet` and `Record`.\n\nThese data structures are highly efficient on modern JavaScript VMs by using\nstructural sharing via [hash maps tries][] and [vector tries][] as popularized\nby Clojure and Scala, minimizing the need to copy or cache data.\n\nImmutable.js also provides a lazy `Seq`, allowing efficient\nchaining of collection methods like `map` and `filter` without creating\nintermediate representations. Create some `Seq` with `Range` and `Repeat`.\n\nWant to hear more? Watch the presentation about Immutable.js:\n\n\u003ca href=\"https://youtu.be/I7IdS-PbEgI\" target=\"_blank\" alt=\"Immutable Data and React\"\u003e\u003cimg src=\"https://img.youtube.com/vi/I7IdS-PbEgI/0.jpg\" /\u003e\u003c/a\u003e\n\n[Persistent]: http://en.wikipedia.org/wiki/Persistent_data_structure\n[Immutable]: http://en.wikipedia.org/wiki/Immutable_object\n[hash maps tries]: http://en.wikipedia.org/wiki/Hash_array_mapped_trie\n[vector tries]: http://hypirion.com/musings/understanding-persistent-vector-pt-1\n\n\nGetting started\n---------------\n\nInstall `immutable` using npm.\n\n```shell\nnpm install immutable\n```\n\nThen require it into any module.\n\n\u003c!-- runkit:activate --\u003e\n```js\nconst { Map } = require('immutable');\nconst map1 = Map({ a: 1, b: 2, c: 3 });\nconst map2 = map1.set('b', 50);\nmap1.get('b') + \" vs. \" + map2.get('b'); // 2 vs. 50\n```\n\n### Browser\n\nImmutable.js has no dependencies, which makes it predictable to include in a Browser.\n\nIt's highly recommended to use a module bundler like [webpack](https://webpack.github.io/),\n[rollup](https://rollupjs.org/), or\n[browserify](http://browserify.org/). The `immutable` npm module works\nwithout any additional consideration. All examples throughout the documentation\nwill assume use of this kind of tool.\n\nAlternatively, Immutable.js may be directly included as a script tag. Download\nor link to a CDN such as [CDNJS](https://cdnjs.com/libraries/immutable)\nor [jsDelivr](https://www.jsdelivr.com/package/npm/immutable).\n\nUse a script tag to directly add `Immutable` to the global scope:\n\n```html\n\u003cscript src=\"immutable.min.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n  var map1 = Immutable.Map({ a: 1, b: 2, c: 3 });\n  var map2 = map1.set('b', 50);\n  map1.get('b'); // 2\n  map2.get('b'); // 50\n\u003c/script\u003e\n```\n\nOr use an AMD-style loader (such as [RequireJS](http://requirejs.org/)):\n\n```js\nrequire(['./immutable.min.js'], function (Immutable) {\n  var map1 = Immutable.Map({ a: 1, b: 2, c: 3 });\n  var map2 = map1.set('b', 50);\n  map1.get('b'); // 2\n  map2.get('b'); // 50\n});\n```\n\n### Flow \u0026 TypeScript\n\nUse these Immutable collections and sequences as you would use native\ncollections in your [Flowtype](https://flowtype.org/) or [TypeScript](http://typescriptlang.org) programs while still taking\nadvantage of type generics, error detection, and auto-complete in your IDE.\n\nInstalling `immutable` via npm brings with it type definitions for Flow (v0.55.0 or higher)\nand TypeScript (v2.1.0 or higher), so you shouldn't need to do anything at all!\n\n#### Using TypeScript with Immutable.js v4\n\nImmutable.js type definitions embrace ES2015. While Immutable.js itself supports\nlegacy browsers and environments, its type definitions require TypeScript's 2015\nlib. Include either `\"target\": \"es2015\"` or `\"lib\": \"es2015\"` in your\n`tsconfig.json`, or provide `--target es2015` or `--lib es2015` to the\n`tsc` command.\n\n\u003c!-- runkit:activate --\u003e\n```js\nconst { Map } = require(\"immutable\");\nconst map1 = Map({ a: 1, b: 2, c: 3 });\nconst map2 = map1.set('b', 50);\nmap1.get('b') + \" vs. \" + map2.get('b'); // 2 vs. 50\n```\n\n#### Using TypeScript with Immutable.js v3 and earlier:\n\nPrevious versions of Immutable.js include a reference file which you can include\nvia relative path to the type definitions at the top of your file.\n\n```js\n///\u003creference path='./node_modules/immutable/dist/immutable.d.ts'/\u003e\nimport Immutable from require('immutable');\nvar map1: Immutable.Map\u003cstring, number\u003e;\nmap1 = Immutable.Map({ a: 1, b: 2, c: 3 });\nvar map2 = map1.set('b', 50);\nmap1.get('b'); // 2\nmap2.get('b'); // 50\n```\n\n\nThe case for Immutability\n-------------------------\n\nMuch of what makes application development difficult is tracking mutation and\nmaintaining state. Developing with immutable data encourages you to think\ndifferently about how data flows through your application.\n\nSubscribing to data events throughout your application creates a huge overhead of\nbook-keeping which can hurt performance, sometimes dramatically, and creates\nopportunities for areas of your application to get out of sync with each other\ndue to easy to make programmer error. Since immutable data never changes,\nsubscribing to changes throughout the model is a dead-end and new data can only\never be passed from above.\n\nThis model of data flow aligns well with the architecture of [React][]\nand especially well with an application designed using the ideas of [Flux][].\n\nWhen data is passed from above rather than being subscribed to, and you're only\ninterested in doing work when something has changed, you can use equality.\n\nImmutable collections should be treated as *values* rather than *objects*. While\nobjects represent some thing which could change over time, a value represents\nthe state of that thing at a particular instance of time. This principle is most\nimportant to understanding the appropriate use of immutable data. In order to\ntreat Immutable.js collections as values, it's important to use the\n`Immutable.is()` function or `.equals()` method to determine *value equality*\ninstead of the `===` operator which determines object *reference identity*.\n\n\u003c!-- runkit:activate --\u003e\n```js\nconst { Map } = require('immutable');\nconst map1 = Map({ a: 1, b: 2, c: 3 });\nconst map2 = Map({ a: 1, b: 2, c: 3 });\nmap1.equals(map2); // true\nmap1 === map2; // false\n```\n\nNote: As a performance optimization Immutable.js attempts to return the existing\ncollection when an operation would result in an identical collection, allowing\nfor using `===` reference equality to determine if something definitely has not\nchanged. This can be extremely useful when used within a memoization function\nwhich would prefer to re-run the function if a deeper equality check could\npotentially be more costly. The `===` equality check is also used internally by\n`Immutable.is` and `.equals()` as a performance optimization.\n\n\u003c!-- runkit:activate --\u003e\n```js\nconst { Map } = require('immutable');\nconst map1 = Map({ a: 1, b: 2, c: 3 });\nconst map2 = map1.set('b', 2); // Set to same value\nmap1 === map2; // true\n```\n\nIf an object is immutable, it can be \"copied\" simply by making another reference\nto it instead of copying the entire object. Because a reference is much smaller\nthan the object itself, this results in memory savings and a potential boost in\nexecution speed for programs which rely on copies (such as an undo-stack).\n\n\u003c!-- runkit:activate --\u003e\n```js\nconst { Map } = require('immutable');\nconst map = Map({ a: 1, b: 2, c: 3 });\nconst mapCopy = map; // Look, \"copies\" are free!\n```\n\n[React]: http://facebook.github.io/react/\n[Flux]: http://facebook.github.io/flux/docs/overview.html\n\n\nJavaScript-first API\n--------------------\n\nWhile Immutable.js is inspired by Clojure, Scala, Haskell and other functional\nprogramming environments, it's designed to bring these powerful concepts to\nJavaScript, and therefore has an Object-Oriented API that closely mirrors that\nof [ES2015][] [Array][], [Map][], and [Set][].\n\n[ES2015]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/New_in_JavaScript/ECMAScript_6_support_in_Mozilla\n[Array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array\n[Map]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map\n[Set]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set\n\nThe difference for the immutable collections is that methods which would mutate\nthe collection, like `push`, `set`, `unshift` or `splice`, instead return a new\nimmutable collection. Methods which return new arrays, like `slice` or `concat`,\ninstead return new immutable collections.\n\n\u003c!-- runkit:activate --\u003e\n```js\nconst { List } = require('immutable');\nconst list1 = List([ 1, 2 ]);\nconst list2 = list1.push(3, 4, 5);\nconst list3 = list2.unshift(0);\nconst list4 = list1.concat(list2, list3);\nassert.equal(list1.size, 2);\nassert.equal(list2.size, 5);\nassert.equal(list3.size, 6);\nassert.equal(list4.size, 13);\nassert.equal(list4.get(0), 1);\n```\n\nAlmost all of the methods on [Array][] will be found in similar form on\n`Immutable.List`, those of [Map][] found on `Immutable.Map`, and those of [Set][]\nfound on `Immutable.Set`, including collection operations like `forEach()`\nand `map()`.\n\n\u003c!-- runkit:activate --\u003e\n```js\nconst { Map } = require('immutable');\nconst alpha = Map({ a: 1, b: 2, c: 3, d: 4 });\nalpha.map((v, k) =\u003e k.toUpperCase()).join();\n// 'A,B,C,D'\n```\n\n### Convert from raw JavaScript objects and arrays.\n\nDesigned to inter-operate with your existing JavaScript, Immutable.js\naccepts plain JavaScript Arrays and Objects anywhere a method expects a\n`Collection`.\n\n\u003c!-- runkit:activate --\u003e\n```js\nconst { Map, List } = require('immutable');\nconst map1 = Map({ a: 1, b: 2, c: 3, d: 4 });\nconst map2 = Map({ c: 10, a: 20, t: 30 });\nconst obj = { d: 100, o: 200, g: 300 };\nconst map3 = map1.merge(map2, obj);\n// Map { a: 20, b: 2, c: 10, d: 100, t: 30, o: 200, g: 300 }\nconst list1 = List([ 1, 2, 3 ]);\nconst list2 = List([ 4, 5, 6 ]);\nconst array = [ 7, 8, 9 ];\nconst list3 = list1.concat(list2, array);\n// List [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]\n```\n\nThis is possible because Immutable.js can treat any JavaScript Array or Object\nas a Collection. You can take advantage of this in order to get sophisticated\ncollection methods on JavaScript Objects, which otherwise have a very sparse\nnative API. Because Seq evaluates lazily and does not cache intermediate\nresults, these operations can be extremely efficient.\n\n\u003c!-- runkit:activate --\u003e\n```js\nconst { Seq } = require('immutable');\nconst myObject = { a: 1, b: 2, c: 3 };\nSeq(myObject).map(x =\u003e x * x).toObject();\n// { a: 1, b: 4, c: 9 }\n```\n\nKeep in mind, when using JS objects to construct Immutable Maps, that\nJavaScript Object properties are always strings, even if written in a quote-less\nshorthand, while Immutable Maps accept keys of any type.\n\n\u003c!-- runkit:activate --\u003e\n```js\nconst { fromJS } = require('immutable');\n\nconst obj = { 1: \"one\" };\nconsole.log(Object.keys(obj)); // [ \"1\" ]\nconsole.log(obj[\"1\"], obj[1]); // \"one\", \"one\"\n\nconst map = fromJS(obj);\nconsole.log(map.get(\"1\"), map.get(1)); // \"one\", undefined\n```\n\nProperty access for JavaScript Objects first converts the key to a string, but\nsince Immutable Map keys can be of any type the argument to `get()` is\nnot altered.\n\n\n### Converts back to raw JavaScript objects.\n\nAll Immutable.js Collections can be converted to plain JavaScript Arrays and\nObjects shallowly with `toArray()` and `toObject()` or deeply with `toJS()`.\nAll Immutable Collections also implement `toJSON()` allowing them to be passed\nto `JSON.stringify` directly. They also respect the custom `toJSON()` methods of\nnested objects.\n\n\u003c!-- runkit:activate --\u003e\n```js\nconst { Map, List } = require('immutable');\nconst deep = Map({ a: 1, b: 2, c: List([ 3, 4, 5 ]) });\nconsole.log(deep.toObject()); // { a: 1, b: 2, c: List [ 3, 4, 5 ] }\nconsole.log(deep.toArray()); // [ 1, 2, List [ 3, 4, 5 ] ]\nconsole.log(deep.toJS()); // { a: 1, b: 2, c: [ 3, 4, 5 ] }\nJSON.stringify(deep); // '{\"a\":1,\"b\":2,\"c\":[3,4,5]}'\n```\n\n### Embraces ES2015\n\nImmutable.js supports all JavaScript environments, including legacy\nbrowsers (even IE8). However it also takes advantage of features added to\nJavaScript in [ES2015][], the latest standard version of JavaScript, including\n[Iterators][], [Arrow Functions][], [Classes][], and [Modules][]. It's inspired\nby the native [Map][] and [Set][] collections added to ES2015.\n\nAll examples in the Documentation are presented in ES2015. To run in all\nbrowsers, they need to be translated to ES5.\n\n```js\n// ES2015\nconst mapped = foo.map(x =\u003e x * x);\n// ES5\nvar mapped = foo.map(function (x) { return x * x; });\n```\n\nAll Immutable.js collections are [Iterable][Iterators], which allows them to be\nused anywhere an Iterable is expected, such as when spreading into an Array.\n\n\u003c!-- runkit:activate --\u003e\n```js\nconst { List } = require('immutable');\nconst aList = List([ 1, 2, 3 ]);\nconst anArray = [ 0, ...aList, 4, 5 ]; // [ 0, 1, 2, 3, 4, 5 ]\n```\n\nNote: A Collection is always iterated in the same order, however that order may\nnot always be well defined, as is the case for the `Map` and `Set`.\n\n[Iterators]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/The_Iterator_protocol\n[Arrow Functions]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions\n[Classes]: http://wiki.ecmascript.org/doku.php?id=strawman:maximally_minimal_classes\n[Modules]: http://www.2ality.com/2014/09/es6-modules-final.html\n\n\nNested Structures\n-----------------\n\nThe collections in Immutable.js are intended to be nested, allowing for deep\ntrees of data, similar to JSON.\n\n\u003c!-- runkit:activate --\u003e\n```js\nconst { fromJS } = require('immutable');\nconst nested = fromJS({ a: { b: { c: [ 3, 4, 5 ] } } });\n// Map { a: Map { b: Map { c: List [ 3, 4, 5 ] } } }\n```\n\nA few power-tools allow for reading and operating on nested data. The\nmost useful are `mergeDeep`, `getIn`, `setIn`, and `updateIn`, found on `List`,\n`Map` and `OrderedMap`.\n\n\u003c!-- runkit:activate --\u003e\n```js\nconst { fromJS } = require('immutable');\nconst nested = fromJS({ a: { b: { c: [ 3, 4, 5 ] } } });\n\nconst nested2 = nested.mergeDeep({ a: { b: { d: 6 } } });\n// Map { a: Map { b: Map { c: List [ 3, 4, 5 ], d: 6 } } }\n\nconsole.log(nested2.getIn([ 'a', 'b', 'd' ])); // 6\n\nconst nested3 = nested2.updateIn([ 'a', 'b', 'd' ], value =\u003e value + 1);\nconsole.log(nested3);\n// Map { a: Map { b: Map { c: List [ 3, 4, 5 ], d: 7 } } }\n\nconst nested4 = nested3.updateIn([ 'a', 'b', 'c' ], list =\u003e list.push(6));\n// Map { a: Map { b: Map { c: List [ 3, 4, 5, 6 ], d: 7 } } }\n```\n\n\nEquality treats Collections as Values\n-------------------------------------\n\nImmutable.js collections are treated as pure data *values*. Two immutable\ncollections are considered *value equal* (via `.equals()` or `is()`) if they\nrepresent the same collection of values. This differs from JavaScript's typical\n*reference equal* (via `===` or `==`) for Objects and Arrays which only\ndetermines if two variables represent references to the same object instance.\n\nConsider the example below where two identical `Map` instances are not\n*reference equal* but are *value equal*.\n\n\u003c!-- runkit:activate --\u003e\n```js\n// First consider:\nconst obj1 = { a: 1, b: 2, c: 3 };\nconst obj2 = { a: 1, b: 2, c: 3 };\nobj1 !== obj2; // two different instances are always not equal with ===\n\nconst { Map, is } = require('immutable');\nconst map1 = Map({ a: 1, b: 2, c: 3 });\nconst map2 = Map({ a: 1, b: 2, c: 3 });\nmap1 !== map2; // two different instances are not reference-equal\nmap1.equals(map2); // but are value-equal if they have the same values\nis(map1, map2); // alternatively can use the is() function\n```\n\nValue equality allows Immutable.js collections to be used as keys in Maps or\nvalues in Sets, and retrieved with different but equivalent collections:\n\n\u003c!-- runkit:activate --\u003e\n```js\nconst { Map, Set } = require('immutable');\nconst map1 = Map({ a: 1, b: 2, c: 3 });\nconst map2 = Map({ a: 1, b: 2, c: 3 });\nconst set = Set().add(map1);\nset.has(map2); // true because these are value-equal\n```\n\nNote: `is()` uses the same measure of equality as [Object.is][] for scalar\nstrings and numbers, but uses value equality for Immutable collections,\ndetermining if both are immutable and all keys and values are equal\nusing the same measure of equality.\n\n[Object.is]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is\n\n#### Performance tradeoffs\n\nWhile value equality is useful in many circumstances, it has different\nperformance characteristics than reference equality. Understanding these\ntradeoffs may help you decide which to use in each case, especially when used\nto memoize some operation.\n\nWhen comparing two collections, value equality may require considering every\nitem in each collection, on an `O(N)` time complexity. For large collections of\nvalues, this could become a costly operation. Though if the two are not equal\nand hardly similar, the inequality is determined very quickly. In contrast, when\ncomparing two collections with reference equality, only the initial references\nto memory need to be compared which is not based on the size of the collections,\nwhich has an `O(1)` time complexity. Checking reference equality is always very\nfast, however just because two collections are not reference-equal does not rule\nout the possibility that they may be value-equal.\n\n#### Return self on no-op optimization\n\nWhen possible, Immutable.js avoids creating new objects for updates where no\nchange in *value* occurred, to allow for efficient *reference equality* checking\nto quickly determine if no change occurred.\n\n\u003c!-- runkit:activate --\u003e\n```js\nconst { Map } = require('immutable');\nconst originalMap = Map({ a: 1, b: 2, c: 3 });\nconst updatedMap = originalMap.set('b', 2);\nupdatedMap === originalMap; // No-op .set() returned the original reference.\n```\n\nHowever updates which do result in a change will return a new reference. Each\nof these operations occur independently, so two similar updates will not return\nthe same reference:\n\n\u003c!-- runkit:activate --\u003e\n```js\nconst { Map } = require('immutable');\nconst originalMap = Map({ a: 1, b: 2, c: 3 });\nconst updatedMap = originalMap.set('b', 1000);\n// New instance, leaving the original immutable.\nupdatedMap !== originalMap;\nconst anotherUpdatedMap = originalMap.set('b', 1000);\n// Despite both the results of the same operation, each created a new reference.\nanotherUpdatedMap !== updatedMap;\n// However the two are value equal.\nanotherUpdatedMap.equals(updatedMap);\n```\n\nBatching Mutations\n------------------\n\n\u003e If a tree falls in the woods, does it make a sound?\n\u003e\n\u003e If a pure function mutates some local data in order to produce an immutable\n\u003e return value, is that ok?\n\u003e\n\u003e — Rich Hickey, Clojure\n\nApplying a mutation to create a new immutable object results in some overhead,\nwhich can add up to a minor performance penalty. If you need to apply a series\nof mutations locally before returning, Immutable.js gives you the ability to\ncreate a temporary mutable (transient) copy of a collection and apply a batch of\nmutations in a performant manner by using `withMutations`. In fact, this is\nexactly how  Immutable.js applies complex mutations itself.\n\nAs an example, building `list2` results in the creation of 1, not 3, new\nimmutable Lists.\n\n\u003c!-- runkit:activate --\u003e\n```js\nconst { List } = require('immutable');\nconst list1 = List([ 1, 2, 3 ]);\nconst list2 = list1.withMutations(function (list) {\n  list.push(4).push(5).push(6);\n});\nassert.equal(list1.size, 3);\nassert.equal(list2.size, 6);\n```\n\nNote: Immutable.js also provides `asMutable` and `asImmutable`, but only\nencourages their use when `withMutations` will not suffice. Use caution to not\nreturn a mutable copy, which could result in undesired behavior.\n\n*Important!*: Only a select few methods can be used in `withMutations` including\n`set`, `push` and `pop`. These methods can be applied directly against a\npersistent data-structure where other methods like `map`, `filter`, `sort`,\nand `splice` will always return new immutable data-structures and never mutate\na mutable collection.\n\n\nLazy Seq\n--------\n\n`Seq` describes a lazy operation, allowing them to efficiently chain\nuse of all the higher-order collection methods (such as `map` and `filter`)\nby not creating intermediate collections.\n\n**Seq is immutable** — Once a Seq is created, it cannot be\nchanged, appended to, rearranged or otherwise modified. Instead, any mutative\nmethod called on a `Seq` will return a new `Seq`.\n\n**Seq is lazy** — `Seq` does as little work as necessary to respond to any\nmethod call. Values are often created during iteration, including implicit\niteration when reducing or converting to a concrete data structure such as\na `List` or JavaScript `Array`.\n\nFor example, the following performs no work, because the resulting\n`Seq`'s values are never iterated:\n\n```js\nconst { Seq } = require('immutable');\nconst oddSquares = Seq([ 1, 2, 3, 4, 5, 6, 7, 8 ])\n  .filter(x =\u003e x % 2 !== 0)\n  .map(x =\u003e x * x);\n```\n\nOnce the `Seq` is used, it performs only the work necessary. In this\nexample, no intermediate arrays are ever created, filter is called three\ntimes, and map is only called once:\n\n```js\noddSquares.get(1); // 9\n```\n\nAny collection can be converted to a lazy Seq with `Seq()`.\n\n\u003c!-- runkit:activate --\u003e\n```js\nconst { Map, Seq } = require('immutable');\nconst map = Map({ a: 1, b: 2, c: 3 });\nconst lazySeq = Seq(map);\n```\n\n`Seq` allows for the efficient chaining of operations, allowing for the\nexpression of logic that can otherwise be very tedious:\n\n```js\nlazySeq\n  .flip()\n  .map(key =\u003e key.toUpperCase())\n  .flip();\n// Seq { A: 1, B: 2, C: 3 }\n```\n\nAs well as expressing logic that would otherwise seem memory or time\nlimited, for example `Range` is a special kind of Lazy sequence.\n\n\u003c!-- runkit:activate --\u003e\n```js\nconst { Range } = require('immutable');\nRange(1, Infinity)\n  .skip(1000)\n  .map(n =\u003e -n)\n  .filter(n =\u003e n % 2 === 0)\n  .take(2)\n  .reduce((r, n) =\u003e r * n, 1);\n// 1006008\n```\n\n\nDocumentation\n-------------\n\n[Read the docs](http://facebook.github.io/immutable-js/docs/) and eat your vegetables.\n\nDocs are automatically generated from [Immutable.d.ts](https://github.com/facebook/immutable-js/blob/master/type-definitions/Immutable.d.ts).\nPlease contribute!\n\nAlso, don't miss the [Wiki](https://github.com/facebook/immutable-js/wiki) which\ncontains articles on specific topics. Can't find something? Open an [issue](https://github.com/facebook/immutable-js/issues).\n\n\nTesting\n-------\n\nIf you are using the [Chai Assertion Library](http://chaijs.com/), [Chai Immutable](https://github.com/astorije/chai-immutable) provides a set of assertions to use against Immutable.js collections.\n\n\nContribution\n------------\n\nUse [Github issues](https://github.com/facebook/immutable-js/issues) for requests.\n\nWe actively welcome pull requests, learn how to [contribute](https://github.com/facebook/immutable-js/blob/master/.github/CONTRIBUTING.md).\n\n\nChangelog\n---------\n\nChanges are tracked as [Github releases](https://github.com/facebook/immutable-js/releases).\n\n\nThanks\n------\n\n[Phil Bagwell](https://www.youtube.com/watch?v=K2NYwP90bNs), for his inspiration\nand research in persistent data structures.\n\n[Hugh Jackson](https://github.com/hughfdjackson/), for providing the npm package\nname. If you're looking for his unsupported package, see [this repository](https://github.com/hughfdjackson/immutable).\n\n\nLicense\n-------\n\nImmutable.js is [MIT-licensed](https://github.com/facebook/immutable-js/blob/master/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkripod%2Fundefined-iet-2019","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkripod%2Fundefined-iet-2019","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkripod%2Fundefined-iet-2019/lists"}