source: node_modules/es-toolkit/dist/array/zipWith.js

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 503 bytes
Line 
1'use strict';
2
3Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
5function zipWith(arr1, ...rest) {
6 const arrs = [arr1, ...rest.slice(0, -1)];
7 const combine = rest[rest.length - 1];
8 const maxIndex = Math.max(...arrs.map(arr => arr.length));
9 const result = Array(maxIndex);
10 for (let i = 0; i < maxIndex; i++) {
11 const elements = arrs.map(arr => arr[i]);
12 result[i] = combine(...elements, i);
13 }
14 return result;
15}
16
17exports.zipWith = zipWith;
Note: See TracBrowser for help on using the repository browser.