@extra-array/zip
TypeScript icon, indicating that this package has built-in type declarations

2.10.19 • Public • Published

Combines values from arrays. 📦 😺 🏃 📼 🌔 📜 📰 📘

Similar: cartesianProduct, zip.

This is part of package extra-array.


array.zip(xs, [fm], [ft], [vd]);
// xs: arrays
// fm: map function (vs, i)
// ft: till function (dones) (some)
// vd: default value
const array = require("extra-array");

var x = [1, 2, 3];
var y = [4, 5];
array.zip([x, y]);
// [ [ 1, 4 ], [ 2, 5 ] ] (shortest)

array.zip([x, y], ([a, b]) => a + b);
// [ 5, 7 ]

array.zip([x, y], null, array.some);
// [ [ 1, 4 ], [ 2, 5 ] ] (shortest)

array.zip([x, y], null, array.every, 0);
// [ [ 1, 4 ], [ 2, 5 ], [ 3, 0 ] ] (longest)

array.zip([x, y], null, array.head, 0);
// [ [ 1, 4 ], [ 2, 5 ], [ 3, 0 ] ] (first)


References

Readme

Keywords

Package Sidebar

Install

npm i @extra-array/zip

Weekly Downloads

1

Version

2.10.19

License

MIT

Unpacked Size

6.07 kB

Total Files

8

Last publish

Collaborators

  • wolfram77