Last change
on this file since fa375fe was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
460 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | # flatten
|
---|
| 2 |
|
---|
| 3 | A tiny utility to flatten arrays of arrays (of arrays, etc., recursively, infinitely or to an optional depth) into a single array of non-arrays.
|
---|
| 4 |
|
---|
| 5 | ## example:
|
---|
| 6 |
|
---|
| 7 | ```js
|
---|
| 8 | > var flatten = require('flatten');
|
---|
| 9 | undefined
|
---|
| 10 | > flatten([1, [2, 3], [4, 5, 6], [7, [8, 9]], 10])
|
---|
| 11 | [ 1,
|
---|
| 12 | 2,
|
---|
| 13 | 3,
|
---|
| 14 | 4,
|
---|
| 15 | 5,
|
---|
| 16 | 6,
|
---|
| 17 | 7,
|
---|
| 18 | 8,
|
---|
| 19 | 9,
|
---|
| 20 | 10 ]
|
---|
| 21 | > flatten([1, [2, [3, [4, [5]]]]], 2)
|
---|
| 22 | [ 1,
|
---|
| 23 | 2,
|
---|
| 24 | 3,
|
---|
| 25 | [ 4, [ 5 ] ] ]
|
---|
| 26 | ```
|
---|
| 27 |
|
---|
| 28 | ## install:
|
---|
| 29 |
|
---|
| 30 | npm install flatten
|
---|
| 31 |
|
---|
| 32 | ## license:
|
---|
| 33 |
|
---|
| 34 | MIT/X11.
|
---|
Note:
See
TracBrowser
for help on using the repository browser.