fzip
Zip collections and map or iterate over the result at once. Combination of zip
and map
, or zip
and forEach
.
Accepts functions and string specs (to build objects from). Falls back to plain zip
.
Examples
> 2 2 2 > 2 1 0 > name: 'mom' adjective: 'dear' name: 'dad' adjective: 'awesome' name: 'dog' adjective: 'joyful' > 0 2 1 1 2 0 > 0 1 2 > sums = > fzip> sums2 2 2 > sum = 0> fzip> sum3
API
fzip([array]..., func)
Apply func
to arrays, passing one argument per array each time. Collect returned values in the resulting array.
Return null
if no arrays given.
fzip([array]..., spec)
Construct array of objects according to a string spec
, which must comprise object keys, separated by comma and optional whitespace. The number of keys and the number of arrays should match.
Return null
if no arrays given.
fzip([array]...)
Zip arrays into a single array of corresponding items (see examples).
Return null
if no arrays given.
fzip.each([array]..., func)
Similar to fzip([array]..., func)
, but does not collect the results.
Install
npm install fzip
License
MIT