Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@extra-array/partition-as

nodef57MIT2.10.19TypeScript support: included

Segregates values by similarity.

extra, array, partition, as, partitionAs

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.


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 ] }


References