@@ -3,9 +3,9 @@ Immutable Data Collections
3
3
4
4
Immutable data cannot be changed once created, leading to much simpler
5
5
application development and enabling techniques from functional programming such
6
- as lazy evaluation. This provides a lazy ` Sequence ` , allowing efficient chaining
7
- of sequence methods like ` map ` and ` filter ` without creating intermediate
8
- representations.
6
+ as lazy evaluation. Immutable JS provides a lazy ` Sequence ` , allowing efficient
7
+ chaining of sequence methods like ` map ` and ` filter ` without creating
8
+ intermediate representations.
9
9
10
10
` immutable ` provides ` Sequence ` , ` Range ` , ` Repeat ` , ` Map ` , ` OrderedMap ` , ` Set `
11
11
and a sparse ` Vector ` by using lazy sequences and [ hash maps tries] ( http://en.wikipedia.org/wiki/Hash_array_mapped_trie ) .
@@ -43,6 +43,8 @@ require the full file path)
43
43
import Immutable = require(' ./node_modules/immutable/dist/Immutable' );
44
44
var map: Immutable .Map < string, number> ;
45
45
map = Immutable .Map ({a: 1 , b: 2 , c: 3 });
46
+ map = map .set (' b' , 20 );
47
+ map .get (
D89F
' b' ); // 20
46
48
```
47
49
48
50
@@ -109,6 +111,7 @@ assert(vect1.length === 2);
109
111
assert (vect2 .length === 5 );
110
112
assert (vect3 .length === 3 );
111
113
assert (vect4 .length === 10 );
114
+ assert (vect4 .get (0 ) === 2 );
112
115
```
113
116
114
117
Almost all of the methods on ` Array ` will be found in similar form on
@@ -121,6 +124,8 @@ alpha.map((v, k) => k.toUpperCase()).join();
121
124
// 'A,B,C,D'
122
125
```
123
126
127
+ ### Accepts raw JavaScript objects.
128
+
124
129
Designed to inter-operate with your existing JavaScript, ` immutable `
125
130
accepts plain JavaScript Array and Objects anywhere a method expects a
126
131
` Sequence ` with no performance penalty.
@@ -145,6 +150,8 @@ Sequence(myObject).map(x => x * x).toObject();
145
150
// { a: 1, b: 4, c: 9 }
146
151
```
147
152
153
+ ### Converts back to raw JavaScript objects.
154
+
148
155
All ` immutable ` Sequences can be converted to plain JavaScript Arrays and
149
156
Objects shallowly with ` toArray() ` and ` toObject() ` or deeply with ` toJSON() ` ,
150
157
allowing ` JSON.stringify ` to work automatically.
0 commit comments