@@ -131,8 +131,8 @@ Almost all of the methods on `Array` will be found in similar form on
131
131
found on ` Immutable.Set ` , including sequence operations.
132
132
133
133
134
- Mutation and when to break the rules
135
- ------------------------------------
134
+ Batching mutations
135
+ ------------------
136
136
137
137
> If a tree falls in the woods, does it make a sound?
138
138
>
@@ -144,19 +144,19 @@ Mutation and when to break the rules
144
144
There is a performance penalty paid every time you create a new immutable object
145
145
via applying a mutation. If you need to apply a series of mutations
146
146
` immutable-data ` gives you the ability to create a temporary mutable copy of a
147
- collection and applying mutations in a highly performant manner by using
148
- ` withMutations ` . In fact, this is exactly how ` immutable-data ` applies complex
149
- mutations itself.
147
+ collection and applying a batch of mutations in a highly performant manner by
148
+ using ` withMutations ` . In fact, this is exactly how ` immutable-data ` applies
149
+ complex mutations itself.
150
150
151
- As an example, this results in 1 , not 3 , new immutable objects .
151
+ As an example, this results in the creation of 2 , not 4 , new immutable Vectors .
152
152
153
153
``` javascript
154
- var vect1 = Immutable .Vector ();
154
+ var vect1 = Immutable .Vector (1 , 2 , 3 );
155
155
var vect2 = vect1 .withMutations (function (vect ) {
156
- vect .push (1 ).push (2 ).push (3 );
156
+ vect .push (4 ).push (5 ).push (6 );
157
157
});
158
- assert (vect1 .length === 0 );
159
- assert (vect2 .length === 3 );
158
+ assert (vect1 .length === 3 );
159
+ assert (vect2 .length === 6 );
160
160
```
161
161
162
162
0 commit comments