There was an error while loading. Please reload this page.
Segregate entries by similarity.
Similar: partition, partitionAs. Similar: partition, chunk.
function partitionAs(x, fm) // x: an object // fm: map function (v, k, x)
const object = require('extra-object'); var x = {a: 1, b: 2, c: 3, d: 4}; object.partitionAs(x, v => v % 2 == 0); // → Map(2) { false => { a: 1, c: 3 }, true => { b: 2, d: 4 } } var x = {a: 1, b: 2, c: 3, d: 4, e: 5}; object.partitionAs(x, v => v % 3); // → Map(3) { 1 => { a: 1, d: 4 }, 2 => { b: 2, e: 5 }, 0 => { c: 3 } }