@extra-array/flatten

2.3.10 • Public • Published

Flattens nested array to given depth.

This is part of package extra-array.

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

Dependents (0)

Package Sidebar

Install

npm i @extra-array/flatten

Weekly Downloads

4

Version

2.3.10

License

MIT

Unpacked Size

2.97 kB

Total Files

3

Last publish

Collaborators

  • wolfram77