source: node_modules/es-toolkit/dist/compat/array/unzipWith.mjs

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

Added visualizations

  • Property mode set to 100644
File size: 668 bytes
Line 
1import { unzip } from '../../array/unzip.mjs';
2import { isArray } from '../predicate/isArray.mjs';
3import { isArrayLikeObject } from '../predicate/isArrayLikeObject.mjs';
4
5function unzipWith(array, iteratee) {
6 if (!isArrayLikeObject(array) || !array.length) {
7 return [];
8 }
9 const unzipped = isArray(array) ? unzip(array) : unzip(Array.from(array, value => Array.from(value)));
10 if (!iteratee) {
11 return unzipped;
12 }
13 const result = new Array(unzipped.length);
14 for (let i = 0; i < unzipped.length; i++) {
15 const value = unzipped[i];
16 result[i] = iteratee(...value);
17 }
18 return result;
19}
20
21export { unzipWith };
Note: See TracBrowser for help on using the repository browser.