@extra-iterable/flat-map.min

Flattens nested iterable, based on map function.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
@extra-iterable/flat-map.min
512.5.222 years ago3 years agoMinified + gzip package size for @extra-iterable/flat-map.min in KB

Readme

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

This is part of package extra-iterable.

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



iterable.flatMap(x, [fm], [ft]);
// x:  a nested iterable
// fm: map function (v, i, x)
// ft: test function (v, i, x)

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

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

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

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



References