|
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
|
| Rev | Line | |
|---|
| [a762898] | 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|---|
| 4 |
|
|---|
| 5 | const unzip = require('../../array/unzip.js');
|
|---|
| 6 | const isArray = require('../predicate/isArray.js');
|
|---|
| 7 | const isArrayLikeObject = require('../predicate/isArrayLikeObject.js');
|
|---|
| 8 |
|
|---|
| 9 | function 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 |
|
|---|
| 25 | exports.unzipWith = unzipWith;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.