source: node_modules/es-toolkit/dist/array/zipWith.mjs@ ba17441

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

Added visualizations

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