Flatten a nested array.
npm install flat-util> Flatten a nested array.
The nesting can be to any depth. If you pass shallow, the array will only be flattened one level.
- Small utility to flatten nested arrays.
- Free of TypeScript. 😄
Install with npm
```
$ npm install flat-util
Or unpkg
``
Check out the unit tests on CodePen.
`js
const flatten = require('flat-util');
flatten([1, 2, [3, 4]]);
//=> [1, 2, 3, 4]
flatten([1, [2], [3, [[4]]]]);
//=> [1, 2, 3, 4];
flatten([1, [2], [3, [[4]]]], true);
//=> [1, 2, 3, [[4]]];
`
---
| Like us a lot? Help others know why you like us! Review this package on pkgreview.dev | âž¡ |  |
| ----------------------------------------------------------------------------------------------------------------------------------------- | --- | --------------------------------------------------------------------------------------------------------------------- |
#### input
Type: array none
Default:
The array to flatten.
#### shallow
Type: boolean false`
Default:
Whether or not to flatten the array only one level.
MIT