8000 Tweak docs for converting from raw JS. · lisongyu/immutable-js@bcc932f · GitHub
[go: up one dir, main page]

Skip to content

Commit bcc932f

Browse files
committed
Tweak docs for converting from raw JS.
Closes immutable-js#578
1 parent 91585d2 commit bcc932f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,20 +235,25 @@ alpha.map((v, k) => k.toUpperCase()).join();
235235
// 'A,B,C,D'
236236
```
237237

238-
### Accepts raw JavaScript objects.
238+
### Convert from raw JavaScript objects and arrays.
239239

240240
Designed to inter-operate with your existing JavaScript, Immutable.js
241241
accepts plain JavaScript Arrays and Objects anywhere a method expects an
242242
`Collection`.
243243

244244
<!-- runkit:activate -->
245245
```js
246-
const { Map } = require('immutable')
246+
const { Map, List } = require('immutable')
247247
const map1 = Map({ a: 1, b: 2, c: 3, d: 4 })
248248
const map2 = Map({ c: 10, a: 20, t: 30 })
249249
const obj = { d: 100, o: 200, g: 300 }
250250
const map3 = map1.merge(map2, obj);
251251
// Map { a: 20, b: 2, c: 10, d: 100, t: 30, o: 200, g: 300 }
252+
const list1 = List([ 1, 2, 3 ])
253+
const list2 = List([ 4, 5, 6 ])
254+
const array = [ 7, 8, 9 ]
255+
const list3 = list1.concat(list2, array)
256+
// List [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]
252257
```
253258

< 3C7D /td>
254259
This is possible because Immutable.js can treat any JavaScript Array or Object

0 commit comments

Comments
 (0)
0