@extra-array/flat-map.min

Flattens nested array, based on map function.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
@extra-array/flat-map.min
1402.10.197 months ago2 years agoMinified + gzip package size for @extra-array/flat-map.min in KB

Readme

Flattens nested array, based on map function. :package: :smileycat: :running: :vhs: :moon: :scroll: :newspaper: :bluebook:
Alternatives: flat, flatMap.

This is part of package extra-array.

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



array.flatMap(x, [fm], [ft]);
// x:  an array
// fm: map function (v, i, x)
// ft: test function (v, i, x)

const array = require("extra-array");

var x = [[1, 2], [3, [4, [5]]]];
array.flatMap(x);
// [ 1, 2, 3, [ 4, [ 5 ] ] ]

array.flatMap(x, v => array.flat(v, 1));
// [ 1, 2, 3, 4, [ 5 ] ]

array.flatMap(x, v => array.flat(v));
// [ 1, 2, 3, 4, 5 ]



References