A JavaScript utility to combine arrays.
Use this if you want to combine multiple arrays to create a new array where each element from each array is combined with each element in each other array.
npm install --save array.combine
const { combine } = require('array.combine');
combine([1, 2], [3, 4]); // => [1, 3], [1, 4], [2, 3], [2, 4]const { combine, combineWith } = require('array.combine');combine([1, 2], [3, 4]); // => [1, 3], [1, 4], [2, 3], [2, 4]const add = (n1, n2) => n1 + n2;
combineWith([1, 2], [3, 4], add); // => [4, 5, 5, 6]add is invoked with (item1:*, [itemN:*]).
In this example it would be (1, 3), (1, 4), etc…
const { combine, combineWith } = require('array.combine/fp');combine([[1, 2], [3, 4]]); // => [1, 3], [1, 4], [2, 3], [2, 4]const add = (n1, n2) => n1 + n2;
const addAll = (numbers) => numbers.reduce(add, 0);
combineWith(addAll, [[1, 2], [3, 4]]); // => [4, 5, 5, 6]addAll is invoked with (Array<*>).
In this example it would be ([1, 3]), ([1, 4]), etc…