Socket
Socket
Sign inDemoInstall

immutable

Package Overview
Dependencies
0
Maintainers
1
Versions
101
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.0.0-rc.12 to 4.0.0-rc.14

100

package.json
{
"name": "immutable",
"version": "4.0.0-rc.12",
"version": "4.0.0-rc.14",
"description": "Immutable Data Collections",
"license": "MIT",
"homepage": "https://facebook.github.com/immutable-js",
"homepage": "https://immutable-js.com",
"author": {

@@ -13,6 +13,6 @@ "name": "Lee Byron",

"type": "git",
"url": "git://github.com/facebook/immutable-js.git"
"url": "git://github.com/immutable-js/immutable-js.git"
},
"bugs": {
"url": "https://github.com/facebook/immutable-js/issues"
"url": "https://github.com/immutable-js/immutable-js/issues"
},

@@ -25,91 +25,4 @@ "main": "dist/immutable.js",

},
"scripts": {
"build": "run-s build:*",
"build:dist": "run-s clean:dist bundle:dist bundle:es copy:dist stats:dist",
"build:pages": "gulp --gulpfile ./resources/gulpfile.js default",
"stats:dist": "node ./resources/dist-stats.js",
"clean:dist": "rimraf dist",
"bundle:dist": "rollup -c ./resources/rollup-config.js",
"bundle:es": "rollup -c ./resources/rollup-config-es.js",
"copy:dist": "node ./resources/copy-dist-typedefs.js",
"lint": "run-s lint:*",
"lint:ts": "tslint \"__tests__/**/*.ts\"",
"lint:js": "eslint \"{__tests__,src,pages/src,pages/lib}/**/*.js\"",
"format": "prettier --single-quote --trailing-comma=es5 --write \"{__tests__,src,pages/src,pages/lib,perf,resources}/**/*{\\.js,\\.ts}\"",
"testonly": "./resources/jest",
"test": "run-s format build lint testonly test:types:*",
"test:travis": "npm run test && ./resources/check-changes",
"test:types:ts": "tsc ./type-definitions/Immutable.d.ts --lib es2015 && dtslint type-definitions/ts-tests",
"test:types:flow": "flow check type-definitions/tests --include-warnings",
"perf": "node ./resources/bench.js",
"start": "gulp --gulpfile ./resources/gulpfile.js dev",
"deploy": "./resources/deploy-ghpages.sh",
"gitpublish": "./resources/gitpublish.sh"
},
"jest": {
"moduleFileExtensions": [
"js",
"ts"
],
"transform": {
"^.+\\.ts$": "<rootDir>/resources/jestPreprocessor.js"
},
"testRegex": "/__tests__/.*\\.(ts|js)$",
"unmockedModulePathPatterns": [
"./node_modules/react"
]
},
"devDependencies": {
"benchmark": "2.1.4",
"browser-sync": "^2.26.3",
"browserify": "16.2.2",
"colors": "1.2.5",
"del": "3.0.0",
"dtslint": "0.1.2",
"eslint": "4.19.1",
"eslint-config-airbnb": "16.1.0",
"eslint-config-prettier": "2.9.0",
"eslint-plugin-import": "2.12.0",
"eslint-plugin-jsx-a11y": "6.0.3",
"eslint-plugin-prettier": "2.6.2",
"eslint-plugin-react": "7.8.2",
"flow-bin": "0.85.0",
"gulp": "3.9.1",
"gulp-concat": "2.6.1",
"gulp-filter": "5.1.0",
"gulp-header": "2.0.5",
"gulp-less": "3.5.0",
"gulp-size": "3.0.0",
"gulp-sourcemaps": "2.6.4",
"gulp-uglify": "2.1.0",
"gulp-util": "3.0.8",
"jasmine-check": "0.1.5",
"jest": "23.6.0",
"marked": "0.3.19",
"microtime": "2.1.8",
"mkdirp": "0.5.1",
"npm-run-all": "4.1.3",
"prettier": "1.14.2",
"react": "^0.12.0",
"react-router": "^0.11.2",
"react-tools": "0.13.3",
"rimraf": "2.6.2",
"rollup": "0.59.1",
"rollup-plugin-buble": "0.19.2",
"rollup-plugin-commonjs": "9.1.3",
"rollup-plugin-json": "3.0.0",
"rollup-plugin-strip-banner": "0.2.0",
"run-sequence": "2.2.1",
"through2": "2.0.3",
"transducers-js": "^0.4.174",
"tslint": "5.7.0",
"typescript": "3.0.3",
"uglify-js": "2.8.11",
"uglify-save-license": "0.4.1",
"vinyl-buffer": "1.0.1",
"vinyl-source-stream": "2.0.0"
},
"files": [
"dist",
"contrib",
"README.md",

@@ -129,4 +42,3 @@ "LICENSE"

"iteration"
],
"dependencies": {}
}
]
}

208

README.md

@@ -1,5 +0,4 @@

Immutable collections for JavaScript
====================================
# Immutable collections for JavaScript
[![Build Status](https://travis-ci.org/facebook/immutable-js.svg?branch=master)](https://travis-ci.org/facebook/immutable-js) [![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&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Build Status](https://github.com/immutable-js/immutable-js/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/immutable-js/immutable-js/actions/workflows/ci.yml?query=branch%3Amain) [Chat on slack](https://immutable-js.slack.com)

@@ -25,13 +24,11 @@ [Immutable][] data cannot be changed once created, leading to much simpler

<a href="https://youtu.be/I7IdS-PbEgI" target="_blank" alt="Immutable Data and React"><img src="https://img.youtube.com/vi/I7IdS-PbEgI/0.jpg" /></a>
[![Immutable Data and React](website/public/Immutable-Data-and-React-YouTube.png)](https://youtu.be/I7IdS-PbEgI)
[Persistent]: http://en.wikipedia.org/wiki/Persistent_data_structure
[Immutable]: http://en.wikipedia.org/wiki/Immutable_object
[hash maps tries]: http://en.wikipedia.org/wiki/Hash_array_mapped_trie
[vector tries]: http://hypirion.com/musings/understanding-persistent-vector-pt-1
[Persistent]: https://en.wikipedia.org/wiki/Persistent_data_structure
[Immutable]: https://en.wikipedia.org/wiki/Immutable_object
[hash maps tries]: https://en.wikipedia.org/wiki/Hash_array_mapped_trie
[vector tries]: https://hypirion.com/musings/understanding-persistent-vector-pt-1
## Getting started
Getting started
---------------
Install `immutable` using npm.

@@ -43,5 +40,12 @@

Or install using yarn.
```shell
yarn add immutable
```
Then require it into any module.
<!-- runkit:activate -->
```js

@@ -51,3 +55,3 @@ const { Map } = require('immutable');

const map2 = map1.set('b', 50);
map1.get('b') + " vs. " + map2.get('b'); // 2 vs. 50
map1.get('b') + ' vs. ' + map2.get('b'); // 2 vs. 50
```

@@ -61,3 +65,3 @@

[rollup](https://rollupjs.org/), or
[browserify](http://browserify.org/). The `immutable` npm module works
[browserify](https://browserify.org/). The `immutable` npm module works
without any additional consideration. All examples throughout the documentation

@@ -82,3 +86,3 @@ will assume use of this kind of tool.

Or use an AMD-style loader (such as [RequireJS](http://requirejs.org/)):
Or use an AMD-style loader (such as [RequireJS](https://requirejs.org/)):

@@ -97,3 +101,3 @@ ```js

Use these Immutable collections and sequences as you would use native
collections in your [Flowtype](https://flowtype.org/) or [TypeScript](http://typescriptlang.org) programs while still taking
collections in your [Flowtype](https://flowtype.org/) or [TypeScript](https://typescriptlang.org) programs while still taking
advantage of type generics, error detection, and auto-complete in your IDE.

@@ -113,7 +117,8 @@

<!-- runkit:activate -->
```js
const { Map } = require("immutable");
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
map1.get('b') + ' vs. ' + map2.get('b'); // 2 vs. 50
```

@@ -136,6 +141,4 @@

## The case for Immutability
The case for Immutability
-------------------------
Much of what makes application development difficult is tracking mutation and

@@ -158,3 +161,3 @@ maintaining state. Developing with immutable data encourages you to think

Immutable collections should be treated as *values* rather than *objects*. While
Immutable collections should be treated as _values_ rather than _objects_. While
objects represent some thing which could change over time, a value represents

@@ -164,6 +167,7 @@ the state of that thing at a particular instance of time. This principle is most

treat Immutable.js collections as values, it's important to use the
`Immutable.is()` function or `.equals()` method to determine *value equality*
instead of the `===` operator which determines object *reference identity*.
`Immutable.is()` function or `.equals()` method to determine _value equality_
instead of the `===` operator which determines object _reference identity_.
<!-- runkit:activate -->
```js

@@ -186,2 +190,3 @@ const { Map } = require('immutable');

<!-- runkit:activate -->
```js

@@ -200,2 +205,3 @@ const { Map } = require('immutable');

<!-- runkit:activate -->
```js

@@ -207,8 +213,7 @@ const { Map } = require('immutable');

[React]: http://facebook.github.io/react/
[Flux]: http://facebook.github.io/flux/docs/overview.html
[React]: https://reactjs.org/
[Flux]: https://facebook.github.io/flux/docs/in-depth-overview/
JavaScript-first API
--------------------
## JavaScript-first API

@@ -220,6 +225,6 @@ While Immutable.js is inspired by Clojure, Scala, Haskell and other functional

[ES2015]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/New_in_JavaScript/ECMAScript_6_support_in_Mozilla
[Array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
[Map]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map
[Set]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
[es2015]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/New_in_JavaScript/ECMAScript_6_support_in_Mozilla
[array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
[map]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map
[set]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set

@@ -232,5 +237,6 @@ The difference for the immutable collections is that methods which would mutate

<!-- runkit:activate -->
```js
const { List } = require('immutable');
const list1 = List([ 1, 2 ]);
const list1 = List([1, 2]);
const list2 = list1.push(3, 4, 5);

@@ -252,2 +258,3 @@ const list3 = list2.unshift(0);

<!-- runkit:activate -->
```js

@@ -267,2 +274,3 @@ const { Map } = require('immutable');

<!-- runkit:activate -->
```js

@@ -275,5 +283,5 @@ const { Map, List } = require('immutable');

// Map { a: 20, b: 2, c: 10, d: 100, t: 30, o: 200, g: 300 }
const list1 = List([ 1, 2, 3 ]);
const list2 = List([ 4, 5, 6 ]);
const array = [ 7, 8, 9 ];
const list1 = List([1, 2, 3]);
const list2 = List([4, 5, 6]);
const array = [7, 8, 9];
const list3 = list1.concat(list2, array);

@@ -290,6 +298,9 @@ // List [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]

<!-- runkit:activate -->
```js
const { Seq } = require('immutable');
const myObject = { a: 1, b: 2, c: 3 };
Seq(myObject).map(x => x * x).toObject();
Seq(myObject)
.map(x => x * x)
.toObject();
// { a: 1, b: 4, c: 9 }

@@ -303,11 +314,12 @@ ```

<!-- runkit:activate -->
```js
const { fromJS } = require('immutable');
const obj = { 1: "one" };
const obj = { 1: 'one' };
console.log(Object.keys(obj)); // [ "1" ]
console.log(obj["1"], obj[1]); // "one", "one"
console.log(obj['1'], obj[1]); // "one", "one"
const map = fromJS(obj);
console.log(map.get("1"), map.get(1)); // "one", undefined
console.log(map.get('1'), map.get(1)); // "one", undefined
```

@@ -319,3 +331,2 @@

### Converts back to raw JavaScript objects.

@@ -330,5 +341,6 @@

<!-- runkit:activate -->
```js
const { Map, List } = require('immutable');
const deep = Map({ a: 1, b: 2, c: List([ 3, 4, 5 ]) });
const deep = Map({ a: 1, b: 2, c: List([3, 4, 5]) });
console.log(deep.toObject()); // { a: 1, b: 2, c: List [ 3, 4, 5 ] }

@@ -343,3 +355,3 @@ console.log(deep.toArray()); // [ 1, 2, List [ 3, 4, 5 ] ]

Immutable.js supports all JavaScript environments, including legacy
browsers (even IE8). However it also takes advantage of features added to
browsers (even IE11). However it also takes advantage of features added to
JavaScript in [ES2015][], the latest standard version of JavaScript, including

@@ -356,13 +368,16 @@ [Iterators][], [Arrow Functions][], [Classes][], and [Modules][]. It's inspired

// ES5
var mapped = foo.map(function (x) { return x * x; });
var mapped = foo.map(function (x) {
return x * x;
});
```
All Immutable.js collections are [Iterable][Iterators], which allows them to be
All Immutable.js collections are [Iterable][iterators], which allows them to be
used anywhere an Iterable is expected, such as when spreading into an Array.
<!-- runkit:activate -->
```js
const { List } = require('immutable');
const aList = List([ 1, 2, 3 ]);
const anArray = [ 0, ...aList, 4, 5 ]; // [ 0, 1, 2, 3, 4, 5 ]
const aList = List([1, 2, 3]);
const anArray = [0, ...aList, 4, 5]; // [ 0, 1, 2, 3, 4, 5 ]
```

@@ -375,8 +390,7 @@

[Arrow Functions]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions
[Classes]: http://wiki.ecmascript.org/doku.php?id=strawman:maximally_minimal_classes
[Modules]: http://www.2ality.com/2014/09/es6-modules-final.html
[Classes]: https://wiki.ecmascript.org/doku.php?id=strawman:maximally_minimal_classes
[Modules]: https://www.2ality.com/2014/09/es6-modules-final.html
Nested Structures
-----------------
## Nested Structures

@@ -387,5 +401,6 @@ The collections in Immutable.js are intended to be nested, allowing for deep

<!-- runkit:activate -->
```js
const { fromJS } = require('immutable');
const nested = fromJS({ a: { b: { c: [ 3, 4, 5 ] } } });
const nested = fromJS({ a: { b: { c: [3, 4, 5] } } });
// Map { a: Map { b: Map { c: List [ 3, 4, 5 ] } } }

@@ -399,5 +414,6 @@ ```

<!-- runkit:activate -->
```js
const { fromJS } = require('immutable');
const nested = fromJS({ a: { b: { c: [ 3, 4, 5 ] } } });
const nested = fromJS({ a: { b: { c: [3, 4, 5] } } });

@@ -407,26 +423,25 @@ const nested2 = nested.mergeDeep({ a: { b: { d: 6 } } });

console.log(nested2.getIn([ 'a', 'b', 'd' ])); // 6
console.log(nested2.getIn(['a', 'b', 'd'])); // 6
const nested3 = nested2.updateIn([ 'a', 'b', 'd' ], value => value + 1);
const nested3 = nested2.updateIn(['a', 'b', 'd'], value => value + 1);
console.log(nested3);
// Map { a: Map { b: Map { c: List [ 3, 4, 5 ], d: 7 } } }
const nested4 = nested3.updateIn([ 'a', 'b', 'c' ], list => list.push(6));
const nested4 = nested3.updateIn(['a', 'b', 'c'], list => list.push(6));
// Map { a: Map { b: Map { c: List [ 3, 4, 5, 6 ], d: 7 } } }
```
## Equality treats Collections as Values
Equality treats Collections as Values
-------------------------------------
Immutable.js collections are treated as pure data *values*. Two immutable
collections are considered *value equal* (via `.equals()` or `is()`) if they
Immutable.js collections are treated as pure data _values_. Two immutable
collections are considered _value equal_ (via `.equals()` or `is()`) if they
represent the same collection of values. This differs from JavaScript's typical
*reference equal* (via `===` or `==`) for Objects and Arrays which only
_reference equal_ (via `===` or `==`) for Objects and Arrays which only
determines if two variables represent references to the same object instance.
Consider the example below where two identical `Map` instances are not
*reference equal* but are *value equal*.
_reference equal_ but are _value equal_.
<!-- runkit:activate -->
```js

@@ -450,2 +465,3 @@ // First consider:

<!-- runkit:activate -->
```js

@@ -464,3 +480,3 @@ const { Map, Set } = require('immutable');

[Object.is]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
[object.is]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is

@@ -487,6 +503,7 @@ #### Performance tradeoffs

When possible, Immutable.js avoids creating new objects for updates where no
change in *value* occurred, to allow for efficient *reference equality* checking
change in _value_ occurred, to allow for efficient _reference equality_ checking
to quickly determine if no change occurred.
<!-- runkit:activate -->
```js

@@ -504,2 +521,3 @@ const { Map } = require('immutable');

<!-- runkit:activate -->
```js

@@ -518,4 +536,3 @@ const { Map } = require('immutable');

Batching Mutations
------------------
## Batching Mutations

@@ -534,3 +551,3 @@ > If a tree falls in the woods, does it make a sound?

mutations in a performant manner by using `withMutations`. In fact, this is
exactly how Immutable.js applies complex mutations itself.
exactly how Immutable.js applies complex mutations itself.

@@ -541,5 +558,6 @@ As an example, building `list2` results in the creation of 1, not 3, new

<!-- runkit:activate -->
```js
const { List } = require('immutable');
const list1 = List([ 1, 2, 3 ]);
const list1 = List([1, 2, 3]);
const list2 = list1.withMutations(function (list) {

@@ -556,3 +574,3 @@ list.push(4).push(5).push(6);

*Important!*: Only a select few methods can be used in `withMutations` including
_Important!_: Only a select few methods can be used in `withMutations` including
`set`, `push` and `pop`. These methods can be applied directly against a

@@ -563,6 +581,4 @@ persistent data-structure where other methods like `map`, `filter`, `sort`,

## Lazy Seq
Lazy Seq
--------
`Seq` describes a lazy operation, allowing them to efficiently chain

@@ -586,3 +602,3 @@ use of all the higher-order collection methods (such as `map` and `filter`)

const { Seq } = require('immutable');
const oddSquares = Seq([ 1, 2, 3, 4, 5, 6, 7, 8 ])
const oddSquares = Seq([1, 2, 3, 4, 5, 6, 7, 8])
.filter(x => x % 2 !== 0)

@@ -603,2 +619,3 @@ .map(x => x * x);

<!-- runkit:activate -->
```js

@@ -618,3 +635,3 @@ const { Map, Seq } = require('immutable');

.flip();
// Seq { A: 1, B: 1, C: 1 }
// Seq { A: 1, B: 2, C: 3 }
```

@@ -626,2 +643,3 @@

<!-- runkit:activate -->
```js

@@ -638,38 +656,36 @@ const { Range } = require('immutable');

## Documentation
Documentation
-------------
## Documentation
[Read the docs](http://facebook.github.io/immutable-js/docs/) and eat your vegetables.
[Read the docs](https://immutable-js.com) and eat your vegetables.
Docs are automatically generated from [Immutable.d.ts](https://github.com/facebook/immutable-js/blob/master/type-definitions/Immutable.d.ts).
Docs are automatically generated from [Immutable.d.ts](https://github.com/immutable-js/immutable-js/blob/main/type-definitions/Immutable.d.ts).
Please contribute!
Also, don't miss the [Wiki](https://github.com/facebook/immutable-js/wiki) which
contains articles on specific topics. Can't find something? Open an [issue](https://github.com/facebook/immutable-js/issues).
Also, don't miss the [Wiki](https://github.com/immutable-js/immutable-js/wiki) which
contains articles on specific topics. Can't find something? Open an [issue](https://github.com/immutable-js/immutable-js/issues).
## Testing
Testing
-------
If you are using the [Chai Assertion Library](https://chaijs.com/), [Chai Immutable](https://github.com/astorije/chai-immutable) provides a set of assertions to use against Immutable.js collections.
If 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.
## Contribution
## Contribution
Contribution
------------
Use [Github issues](https://github.com/immutable-js/immutable-js/issues) for requests.
Use [Github issues](https://github.com/facebook/immutable-js/issues) for requests.
We actively welcome pull requests, learn how to [contribute](https://github.com/immutable-js/immutable-js/blob/main/.github/CONTRIBUTING.md).
We actively welcome pull requests, learn how to [contribute](https://github.com/facebook/immutable-js/blob/master/.github/CONTRIBUTING.md).
Immutable.js is maintained within the [Contributor Covenant's Code of Conduct](https://www.contributor-covenant.org/version/2/0/code_of_conduct/).
We actively welcome pull requests, learn how to [contribute](https://github.com/immutable-js/immutable-js/blob/main/.github/CONTRIBUTING.md).
Changelog
---------
## Changelog
Changes are tracked as [Github releases](https://github.com/facebook/immutable-js/releases).
Changes are tracked as [Github releases](https://github.com/immutable-js/immutable-js/releases).
## Thanks
Thanks
------
[Phil Bagwell](https://www.youtube.com/watch?v=K2NYwP90bNs), for his inspiration

@@ -681,6 +697,4 @@ and research in persistent data structures.

## License
License
-------
Immutable.js is [MIT-licensed](https://github.com/facebook/immutable-js/blob/master/LICENSE).
Immutable.js is [MIT-licensed](./LICENSE).

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc