@extra-array/partition-as.min
v2.10.19
Published
Segregates values by similarity.
Downloads
172
Maintainers
Readme
Segregates values by similarity. :package: :smiley_cat: :running: :vhs: :moon: :scroll: :newspaper: :blue_book:
Alternatives: partition, partitionAs. Similar: count, partition.
This is part of package extra-array.
This is browserified, minified version of @extra-array/partition-as. It is exported as global variable array_partitionAs. CDN: unpkg, jsDelivr.
array.partitionAs(x, [fm]);
// x: an array
// fm: map function (v, i, x)
// → Map {key => values}
const array = require("extra-array");
var x = [1, 2, 3, 4];
array.partitionAs(x, v => v % 2 == 0);
// Map(2) { false => [ 1, 3 ], true => [ 2, 4 ] }
var x = [1, 2, 3, 4, 5];
array.partitionAs(x, v => v % 3);
// Map(3) { 1 => [ 1, 4 ], 2 => [ 2, 5 ], 0 => [ 3 ] }