-
Notifications
You must be signed in to change notification settings - Fork 1
zip
Subhajit Sahu edited this page Jun 12, 2020
·
15 revisions
Combines entries from objects. 🏃 📼 📦 🌔 📒
Similar: cartesianProduct, zip.
object.zip(xs, [fm], [ft], [vd]);
// xs: objects
// fm: map function (vs, k, null)
// ft: till function (dones) (some)
// vd: default value
const map = require('extra-map');
const array = require('extra-array');
var x = new Map([['a', 1], ['b', 2], ['c', 3]]);
var y = new Map([['a', 10], ['b', 20]]);
map.zip([x, y]);
// { a: [ 1, 10 ], b: [ 2, 20 ] } (shortest)
map.zip([x, y], ([a, b]) => a + b);
// { a: 11, b: 22 }
map.zip([x, y], null, array.some);
// { a: [ 1, 10 ], b: [ 2, 20 ] } (shortest)
map.zip([x, y], null, array.every, 0);
// { a: [ 1, 10 ], b: [ 2, 20 ], c: [ 3, 0 ] } (longest)
map.zip([x, y], null, array.head, 0);
// { a: [ 1, 10 ], b: [ 2, 20 ], c: [ 3, 0 ] } (first)