10000 readme · rvrobotics/immutable-js@ecec719 · GitHub
[go: up one dir, main page]

Skip to content

Commit ecec719

Browse files
committed
readme
1 parent b94941b commit ecec719

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ Almost all of the methods on `Array` will be found in similar form on
131131
found on `Immutable.Set`, including sequence operations.
132132

133133

134-
Mutation and when to break the rules
135-
------------------------------------
134+
Batching mutations
135+
------------------
136136

137137
> If a tree falls in the woods, does it make a sound?
138138
>
@@ -144,19 +144,19 @@ Mutation and when to break the rules
144144
There is a performance penalty paid every time you create a new immutable object
145145
via applying a mutation. If you need to apply a series of mutations
146146
`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.
150150

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.
152152

153153
```javascript
154-
var vect1 = Immutable.Vector();
154+
var vect1 = Immutable.Vector(1,2,3);
155155
var vect2 = vect1.withMutations(function (vect) {
156-
vect.push(1).push(2).push(3);
156+
vect.push(4).push(5).push(6);
157157
});
158-
assert(vect1.length === 0);
159-
assert(vect2.length === 3);
158+
assert(vect1.length === 3);
159+
assert(vect2.length === 6);
160160
```
161161

162162

0 commit comments

Comments
 (0)
0