source: node_modules/es-toolkit/dist/compat/array/unzipWith.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: 804 bytes
RevLine 
[a762898]1'use strict';
2
3Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
5const unzip = require('../../array/unzip.js');
6const isArray = require('../predicate/isArray.js');
7const isArrayLikeObject = require('../predicate/isArrayLikeObject.js');
8
9function unzipWith(array, iteratee) {
10 if (!isArrayLikeObject.isArrayLikeObject(array) || !array.length) {
11 return [];
12 }
13 const unzipped = isArray.isArray(array) ? unzip.unzip(array) : unzip.unzip(Array.from(array, value => Array.from(value)));
14 if (!iteratee) {
15 return unzipped;
16 }
17 const result = new Array(unzipped.length);
18 for (let i = 0; i < unzipped.length; i++) {
19 const value = unzipped[i];
20 result[i] = iteratee(...value);
21 }
22 return result;
23}
24
25exports.unzipWith = unzipWith;
Note: See TracBrowser for help on using the repository browser.