Skip to content
Subhajit Sahu edited this page Jun 11, 2020 · 13 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 object = require('extra-object');
const array = require('extra-array');

var x = {a: 1, b: 2, c: 3};
var y = {a: 10, b: 20};
object.zip([x, y]);
// { a: [ 1, 10 ], b: [ 2, 20 ] } (shortest)

object.zip([x, y], ([a, b]) => a + b);
// { a: 11, b: 22 }

object.zip([x, y], null, array.some);
// { a: [ 1, 10 ], b: [ 2, 20 ] } (shortest)

object.zip([x, y], null, array.every, 0);
// { a: [ 1, 10 ], b: [ 2, 20 ], c: [ 3, 0 ] } (longest)

object.zip([x, y], null, array.head, 0);
// { a: [ 1, 10 ], b: [ 2, 20 ], c: [ 3, 0 ] } (first)

references

Clone this wiki locally