Have ideas to improve npm?Join in the discussion! »

@extra-array/flatten.min

2.3.10 • Public • Published

Flattens nested array to given depth.

This is part of package extra-array.

This is browserified, minified version of @extra-array/flatten.
It is exported as global variable array_flatten.
CDN: unpkg, jsDelivr.

array.flatten(x, [dep]);
// x:   a nested array
// dep: maximum depth (-1)
// --> flattened
const array = require('extra-array');
 
var x = [[1, 2], [3, [4, [5]]]];
array.flatten(x);
// [1, 2, 3, 4, 5]
 
array.flatten(x, 1);
// [1, 2, 3, [4, [5]]]
 
array.flatten(x, 2);
// [1, 2, 3, 4, [5]]

references

Install

npm i @extra-array/flatten.min

DownloadsWeekly Downloads

76

Version

2.3.10

License

MIT

Unpacked Size

3.84 kB

Total Files

3

Last publish

Collaborators

  • avatar