Package Exports
- flat-util
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (flat-util) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
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.
Features
- Small utility to flatten nested arrays.
- Free of TypeScript. 😄
Install
Install with npm
$ npm install flat-utilOr unpkg
<script src="https://unpkg.com/flat-util@1.1.3/umd/index.js" />Check out the unit tests on CodePen.
Usage
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 | ➡ | ![]() |
|---|
API
flatten(input, shallow)
input
Type: array
Default: none
The array to flatten.
shallow
Type: boolean
Default: false
Whether or not to flatten the array only one level.
License
MIT
