@extra-iterable/group-on.min

Keeps similar values together and in order.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
@extra-iterable/group-on.min
512.2.303 years ago3 years agoMinified + gzip package size for @extra-iterable/group-on.min in KB

Readme

Keeps similar values together and in order. :running: :vhs: :package: :moon: :ledger:
Alternatives: compare, map.
This is part of package extra-iterable.

This is browserified, minified version of @extra-iterable/group-on.
It is exported as global variable iterablegroupOn.
CDN: unpkg
, jsDelivr.

iterable.groupOn(x, [fn], [ths]);
// x:   an iterable
// fn:  map function (v, i, x)
// ths: this argument

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

var x = [1, 2, 2, -2, -2, 4];
[...iterable.groupOn(x)];
// [ [ 1 ], [ 2, 2 ], [ -2, -2 ], [ 4 ] ]

[...iterable.groupOn(x, v => Math.abs(v))];
// [ [ 1 ], [ 2, 2, -2, -2 ], [ 4 ] ]

references