JSPM

  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q37919F
  • License MIT

Flattens nested array to given depth.

Package Exports

  • @extra-array/flatten

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 (@extra-array/flatten) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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