2.1.44 • Published 4 years ago
@extra-set/zip.min v2.1.44
Combines values from sets.
Similar: cartesianProduct, zip. This is part of package extra-set.
This is browserified, minified version of @extra-set/zip. It is exported as global variable set_zip. CDN: unpkg, jsDelivr.
set.zip(xs, [fm], [ft], [vd]);
// xs: sets
// fm: map function (vs, vs)
// ft: till function (dones) (some)
// vd: default value
const set = require('extra-set');
const array = require('extra-array');
var x = new Set([1, 2, 3]);
var y = new Set([10, 20]);
set.zip([x, y]);
// set(2) { 'a' => [ 1, 10 ], 'b' => [ 2, 20 ] } (shortest)
set.zip([x, y], ([a, b]) => a + b);
// set(2) { 'a' => 11, 'b' => 22 }
set.zip([x, y], null, array.some);
// set(2) { 'a' => [ 1, 10 ], 'b' => [ 2, 20 ] } (shortest)
set.zip([x, y], null, array.every, 0);
// set(3) { 'a' => [ 1, 10 ], 'b' => [ 2, 20 ], 'c' => [ 3, 0 ] } (longest)
set.zip([x, y], null, array.head, 0);
// set(3) { 'a' => [ 1, 10 ], 'b' => [ 2, 20 ], 'c' => [ 3, 0 ] } (first)