8000 bump version, use Hughs npm package name · rvrobotics/immutable-js@2f90b5b · GitHub
[go: up one dir, main page]

Skip to content

Commit 2f90b5b

Browse files
committed
bump version, use Hughs npm package name
1 parent a981428 commit 2f90b5b

File tree

4 files changed

+100
-41
lines changed

4 files changed

+100
-41
lines changed

README.md

Lines changed: 46 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,29 @@ as lazy evaluation. This provides a lazy `Sequence`, allowing efficient chaining
77
of sequence methods like `map` and `filter` without creating intermediate
88
representations.
99

10-
`immutable-data` implements a sparse `Vector`, `Map`, `OrderedMap`, `Set` and
11-
`Range` by using lazy sequences and hash maps tries. They achieve acceptable
12-
performance by using structural sharing and minimizing the need to copy data.
10+
`immutable` provides `Sequence`, `Range`, `Repeat`, `Map`, `OrderedMap`, `Set`
11+
and a sparse `Vector` by using lazy sequences and [hash maps tries](http://en.wikipedia.org/wiki/Hash_array_mapped_trie).
12+
They achieve efficiency by using structural sharing and minimizing the need to
13+
copy or cache data.
1314

1415

1516
Getting started
1617
---------------
1718

18-
Install immutable-data using npm
19+
Install `immutable` using npm
1920

2021
```shell
21-
npm install immutable-data
22+
npm install immutable
2223
```
2324

2425
Then require it into any module.
2526

2627
```javascript
27-
var Immutable = require('immutable-data');
28+
var Immutable = require('immutable');
2829
var map = Immutable.Map({a:1, b:2, c:3});
2930
```
3031

31-
To use `immutable-data` from a browser, try [Browserify](http://browserify.org/).
32+
To use `immutable` from a browser, try [Browserify](http://browserify.org/).
3233

3334

3435
Use these Immutable collections and sequences as you would use native
@@ -39,7 +40,7 @@ advantage of type generics, error detection, and auto-complete in your IDE.
3940
require the full file path)
4041

4142
```javascript
42-
import Immutable = require('./node_modules/immutable-data/dist/Immutable');
43+
import Immutable = require('./node_modules/immutable/dist/Immutable');
4344
var map: Immutable.Map<string, number>;
4445
map = Immutable.Map({a:1, b:2, c:3});
4546
```
@@ -61,11 +62,11 @@ to changes throughout the model is a dead-end and new data can only ever be
6162
passed from above.
6263

6364
This model of data flow aligns well with the architecture of [React](http://facebook.github.io/react/)
64-
and especially an application designed using the ideas of [Flux](http://facebook.github.io/react/docs/flux-overview.html).
65+
and especially well with an application designed using the ideas of [Flux](http://facebook.github.io/react/docs/flux-overview.html).
6566

6667
When data is passed from above rather than being subscribed to, and you're only
6768
interested in doing work when something has changed, you can use equality.
68-
`immutable-data` always returns itself when a mutation results in an identical
69+
`immutable` always returns itself when a mutation results in an identical
6970
collection, allowing for using `===` equality to determine if something
7071
has changed.
7172

@@ -89,7 +90,7 @@ var clone = map1;
8990
JavaScript-first API
9091
--------------------
9192

92-
While `immutable-data` is inspired by Clojure, Haskell and other functional
93+
While `immutable` is inspired by Clojure, Haskell and other functional
9394
programming environments, it's designed to bring these powerful concepts to
9495
JavaScript, and therefore has an Object-Oriented API that closely mirrors that
9596
of [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array),
@@ -115,15 +116,12 @@ Almost all of the methods on `Array` will be found in similar form on
115116
found on `Immutable.Set`, including sequence operations like `forEach` and `map`.
116117

117118
```javascript
118-
> var alpha = Immutable.Map({a:1, b:2, c:3, d:4});
119-
> alpha.map((v, k) => k.toUpperCase()).forEach(k => console.log(k));
120-
A
121-
B
122-
C
123-
D
119+
var alpha = Immutable.Map({a:1, b:2, c:3, d:4});
120+
alpha.map((v, k) => k.toUpperCase()).join();
121+
// 'A,B,C,D'
124122
```
125123

126-
Designed to inter-operate with your existing JavaScript, `immutable-data`
124+
Designed to inter-operate with your existing JavaScript, `immutable`
127125
accepts plain JavaScript Array and Objects anywhere a method expects a
128126
`Sequence` with no performance penalty.
129127

@@ -135,7 +133,19 @@ var map3 = map1.merge(map2, obj);
135133
// Map { a: 20, b: 2, c: 10, d: 1000, t: 30, o: 2000, g: 300 }
136134
```
137135

138-
All `immutable-data` Sequences can be converted to plain JavaScript Arrays and
136+
This is possible because `immutible` can treat any JavaScript Array or Object
137+
as a Sequence. You can take advantage of this in order to get sophisticated
138+
sequence methods on JavaScript Objects, which otherwise have a very sparse
139+
native API. Because Sequences evaluate lazily and do not cache intermediate
140+
results, these operations are extremely efficient.
141+
142+
```javascript
143+
var myObject = {a:1,b:2,c:3};
144+
Sequence(myObject).map(x => x * x).toObject();
145+
// { a: 1, b: 4, c: 9 }
146+
```
147+
148+
All `immutable` Sequences can be converted to plain JavaScript Arrays and
139149
Objects shallowly with `toArray()` and `toObject()` or deeply with `toJSON()`,
140150
allowing `JSON.stringify` to work automatically.
141151

@@ -151,7 +161,7 @@ JSON.stringify(deep) // '{"a":1,"b":2,"c":[3,4,5]}'
151161
Nested Structures
152162
-----------------
153163

154-
The collections in `immutable-data` are intended to be nested, allowing for deep
164+
The collections in `immutable` are intended to be nested, allowing for deep
155165
trees of data, similar to JSON.
156166

157167
```javascript
@@ -179,7 +189,7 @@ Lazy Sequences
179189
--------------
180190

181191
The `Sequence` is a set of (key, value) entries which can be iterated, and
182-
is the base class for all collections in `immutable-data`, allowing them to make
192+
is the base class for all collections in `immutable`, allowing them to make
183193
use of all the Sequence methods (such as `map` and `filter`).
184194

185195
**Sequences are immutable** — Once a sequence is created, it cannot be
@@ -225,7 +235,7 @@ not always be well defined, as is the case for the `Map`.
225235
Equality treats Collections as Data
226236
-----------------------------------
227237

228-
`immutable-data` provides equality which treats immutable data structures as
238+
`immutable` provides equality which treats immutable data structures as
229239
pure data, performing a deep equality check if necessary.
230240

231241
```javascript
@@ -252,9 +262,9 @@ Batching Mutations
252262
253263
There is a performance penalty paid every time you create a new immutable object
254264
via applying a mutation. If you need to apply a series of mutations
255-
`immutable-data` gives you the ability to create a temporary mutable copy of a
265+
`immutable` gives you the ability to create a temporary mutable copy of a
256266
collection and applying a batch of mutations in a highly performant manner by
257-
using `withMutations`. In fact, this is exactly how `immutable-data` applies
267+
using `withMutations`. In fact, this is exactly how `immutable` applies
258268
complex mutations itself.
259269

260270
As an example, this results in the creation of 2, not 4, new immutable Vectors.
@@ -278,4 +288,15 @@ All documentation is contained within the type definition file, [Immutable.d.ts]
278288
Contribution
279289
------------
280290

281-
Taking pull requests! Or, use Github issues for requests.
291+
Or, use [Github issues](https://github.com/leebyron/immutable-js/issues) for requests.
292+
293+
Taking [pull requests](https://help.github.com/articles/creating-a-pull-request)!
294+
Before submitting your diff, please add a test to the [__tests__](./__tests__)
295+
directory and build and run all tests by running `grunt`.
296+
297+
298+
Thanks
299+
------
300+
301+
[Hugh Jackson](https://github.com/hughfdjackson/), for providing the npm package
302+
name. If you're looking for his unsupported package, see [v1.4.1](https://www.npmjs.org/package/immutable/1.4.1).

dist/Immutable.d.ts

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export declare function fromJSON(
6767
* --------
6868
*
6969
* The `Sequence` is a set of (key, value) entries which can be iterated, and
70-
* is the base class for all collections in `immutable-data`, allowing them to
70+
* is the base class for all collections in `immutable`, allowing them to
7171
* make use of all the Sequence methods (such as `map` and `filter`).
7272
*
7373
* **Sequences are immutable** — Once a sequence is created, it cannot be
@@ -181,28 +181,43 @@ export interface Sequence<K, V> {
181181

182182
/**
183183
* Converts this sequence to a Vector, discarding keys.
184+
*
185+
* Note: This is equivalent to `Vector.from(this)`, but provided to allow for
186+
* chained expressions.
184187
*/
185188
toVector(): Vector<V>;
186189

187190
/**
188191
* Converts this sequence to a Map, Throws if keys are not hashable.
192+
*
193+
* Note: This is equivalent to `Map.from(this)`, but provided to allow for
194+
* chained expressions.
189195
*/
190196
toMap(): Map<K, V>;
191197

192198
/**
193199
* Converts this sequence to a Map, maintaining the order of iteration.
200+
*
201+
* Note: This is equivalent to `OrderedMap.from(this)`, but provided to allow
202+
* for chained expressions.
194203
*/
195204
toOrderedMap(): Map<K, V>;
196205

197206
/**
198207
* Converts this sequence to a Set, discarding keys. Throws if values
199208
* are not hashable.
209+
*
210+
* Note: This is equivalent to `Set.from(this)`, but provided to allow for
211+
* chained expressions.
200212
*/
201213
toSet(): Set<V>;
202214

203215
/**
204216
* True if this and the other sequence have value equality, as defined
205-
* by `Immutable.is()`
217+
* by `Immutable.is()`.
218+
*
219+
* Note: This is equivalent to `Immutable.is(this, other)`, but provided to
220+
* allow for chained expressions.
206221
*/
207222
equals(other: Sequence<K, V>): boolean;
208223

@@ -242,10 +257,11 @@ export interface Sequence<K, V> {
242257
entries(): IndexedSequence</*(K, V)*/Array<any>>;
243258

244259
/**
245-
* SideEffect is executed for every entry in the sequence.
260+
* The `sideEffect` is executed for every entry in the sequence.
246261
*
247-
* Unlike `Array.prototype.forEach`, if any sideEffect returns `false`, the
248-
* iteration will stop. Returns the length of the sequence which was iterated.
262+
* Unlike `Array.prototype.forEach`, if any call of `sideEffect` returns
263+
* `false`, the iteration will stop. Returns the length of the sequence which
264+
* was iterated.
249265
*/
250266
forEach(
251267
sideEffect: (value?: V, key?: K, seq?: Sequence<K, V>) => any,
@@ -263,7 +279,10 @@ export interface Sequence<K, V> {
263279
): R;
264280

265281
/**
266-
* Reduces the sequence in reverse
282+
* Reduces the sequence in reverse (from the right side).
283+
*
284+
* Note: Equivalent to this.reverse().reduce(), but provided for parity
285+
* with `Array.prototype.reduceRight`.
267286
*/
268287
reduceRight<R>(
269288
reducer: (reduction?: R, value?: V, key?: K, seq?: Sequence<K, V>) => R,
@@ -370,7 +389,7 @@ export interface Sequence<K, V> {
370389
* Returns a new sequence with this sequences's keys as it's values, and this
371390
* sequences's values as it's keys.
372391
*
373-
* Sequence({a:'z',b:'y'}).flip() // { z: 'a', y: 'b' }
392+
* Sequence({ a: 'z', b: 'y' }).flip() // { z: 'a', y: 'b' }
374393
*
375394
*/
376395
flip(): Sequence<V, K>;

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "immutable-data",
3-
"version": "0.4.1",
2+
"name": "immutable",
3+
"version": "2.0.0",
44
"description": "Immutable Data Collections",
55
"homepage": "https://github.com/leebyron/immutable-js",
66
"author": {

type-definitions/Immutable.d.ts

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export declare function fromJSON(
6767
* --------
6868
*
6969
* The `Sequence` is a set of (key, value) entries which can be iterated, and
70-
* is the base class for all collections in `immutable-data`, allowing them to
70+
* is the base class for all collections in `immutable`, allowing them to
7171
* make use of all the Sequence methods (such as `map` and `filter`).
7272
*
7373
* **Sequences are immutable** — Once a sequence is created, it cannot be
@@ -181,28 +181,43 @@ export interface Sequence<K, V> {
181181

182182
/**
183183
* Converts this sequence to a Vector, discarding keys.
184+
*
185+
* Note: This is equivalent to `Vector.from(this)`, but provided to allow for
186+
* chained expressions.
184187
*/
185188
toVector(): Vector<V>;
186189

187190
/**
188191
* Converts this sequence to a Map, Throws if keys are not hashable.
192+
*
193+
* Note: This is equivalent to `Map.from(this)`, but provided to allow for
194+
* chained expressions.
189195
*/
190196
toMap(): Map<K, V>;
191197

192198
/**
193199
* Converts this sequence to a Map, maintaining the order of iteration.
200+
*
201+
* Note: This is equivalent to `OrderedMap.from(this)`, but provided to allow
202+
* for chained expressions.
194203
*/
195204
toOrderedMap(): Map<K, V>;
196205

197206
/**
198207
* Converts this sequence to a Set, discarding keys. Throws if values
199208
* are not hashable.
209+
*
210+
* Note: This is equivalent to `Set.from(this)`, but provided to allow for
211+
* chained expressions.
200212
*/
201213
toSet(): Set<V>;
202214

203215
/**
204216
* True if this and the other sequence have value equality, as defined
205-
* by `Immutable.is()`
217+
* by `Immutable.is()`.
218+
*
219+
* Note: This is equivalent to `Immutable.is(this, other)`, but provided to
220+
* allow for chained expressions.
206221
*/
207222
equals(other: Sequence<K, V>): boolean;
208223

@@ -242,10 +257,11 @@ export interface Sequence<K, V> {
242257
entries(): IndexedSequence</*(K, V)*/Array<any>>;
243258

244259
/**
245-
* SideEffect is executed for every entry in the sequence.
260+
* The `sideEffect` is executed for every entry in the sequence.
246261
*
247-
* Unlike `Array.prototype.forEach`, if any sideEffect returns `false`, the
248-
* iteration will stop. Returns the length of the sequence which was iterated.
262+
* Unlike `Array.prototype.forEach`, if any call of `sideEffect` returns
263+
* `false`, the iteration will stop. Returns the length of the sequence which
264+
* was iterated.
249265
*/
250266
forEach(
251267
sideEffect: (value?: V, key?: K, seq?: Sequence<K, V>) => any,
@@ -263,7 +279,10 @@ export interface Sequence<K, V> {
263279
): R;
264280

265281
/**
266-
* Reduces the sequence in reverse
282+
* Reduces the sequence in reverse (from the right side).
283+
*
284+
* Note: Equivalent to this.reverse().reduce(), but provided for parity
285+
* with `Array.prototype.reduceRight`.
267286
*/
268287
reduceRight<R>(
269288
reducer: (reduction?: R, value?: V, key?: K, seq?: Sequence<K, V>) => R,
@@ -370,7 +389,7 @@ export interface Sequence<K, V> {
370389
* Returns a new sequence with this sequences's keys as it's values, and this
371390
* sequences's values as it's keys.
372391
*
373-
* Sequence({a:'z',b:'y'}).flip() // { z: 'a', y: 'b' }
392+
* Sequence({ a: 'z', b: 'y' }).flip() // { z: 'a', y: 'b' }
374393
*
375394
*/
376395
flip(): Sequence<V, K>;

0 commit comments

Comments
 (0)
0