Updated tools, proper linting, build README

This commit is contained in:
Angelos Chalaris
2017-12-14 19:38:11 +02:00
parent 3e79c9071d
commit 94c1923ee7
13 changed files with 74 additions and 61 deletions

View File

@ -7,7 +7,7 @@ Omit the second element, `depth` to flatten only to a depth of `1` (single flatt
```js
const flattenDepth = (arr, depth = 1) =>
depth != 1 ? arr.reduce((a, v) => a.concat(Array.isArray(v) ? flattenDepth (v, depth-1) : v), [])
: arr.reduce((a,v) => a.concat(v),[]);
depth != 1 ? arr.reduce((a, v) => a.concat(Array.isArray(v) ? flattenDepth(v, depth - 1) : v), [])
: arr.reduce((a, v) => a.concat(v), []);
// flattenDepth([1,[2],[[[3],4],5]], 2) -> [1,2,[3],4,5]
```