@appolo/utils
Advanced tools
Comparing version 8.0.30 to 8.0.31
@@ -131,3 +131,13 @@ "use strict"; | ||
static zip(arr, ...args) { | ||
return arr.map((value, idx) => [value, ...args.map(arr => arr[idx])]); | ||
let arrs = [arr].concat(args); | ||
let maxLen = Math.max(...arrs.map(item => item.length)); | ||
let output = []; | ||
for (let i = 0; i < maxLen; i++) { | ||
let dto = []; | ||
for (let j = 0; j < arrs.length; j++) { | ||
dto.push(arrs[j][i]); | ||
} | ||
output.push(dto); | ||
} | ||
return output; | ||
} | ||
@@ -134,0 +144,0 @@ static sort(arr) { |
@@ -186,4 +186,19 @@ import {Classes} from "./classes"; | ||
public static zip<T>(arr: T[], ...args: Array<T>): Array<Array<T | undefined>> { | ||
return arr.map((value, idx) => [value, ...args.map(arr => arr[idx])]) | ||
public static zip<T>(arr: T[], ...args: Array<T[]>): Array<Array<T | undefined>> { | ||
let arrs = [arr].concat(args); | ||
let maxLen = Math.max(...arrs.map(item => item.length)); | ||
let output = []; | ||
for (let i = 0; i < maxLen; i++) { | ||
let dto = [] | ||
for (let j = 0; j < arrs.length; j++) { | ||
dto.push(arrs[j][i]); | ||
} | ||
output.push(dto); | ||
} | ||
return output; | ||
} | ||
@@ -190,0 +205,0 @@ |
@@ -50,3 +50,3 @@ "use strict"; | ||
zip(...args) { | ||
this._value = arrays_1.Arrays.zip(this._value, args); | ||
this._value = arrays_1.Arrays.zip(this._value, ...args); | ||
return this; | ||
@@ -53,0 +53,0 @@ } |
@@ -59,4 +59,4 @@ import {Arrays} from "./arrays"; | ||
public zip(...args: Array<K>): this { | ||
this._value = Arrays.zip(this._value, args); | ||
public zip(...args: Array<Array<K>>): this { | ||
this._value = Arrays.zip(this._value, ...args); | ||
return this; | ||
@@ -63,0 +63,0 @@ } |
@@ -20,3 +20,3 @@ { | ||
"main": "./index.js", | ||
"version": "8.0.30", | ||
"version": "8.0.31", | ||
"license": "MIT", | ||
@@ -33,13 +33,13 @@ "repository": { | ||
"devDependencies": { | ||
"@types/benchmark": "^2.1.0", | ||
"@types/chai": "^4.2.16", | ||
"@types/lodash": "^4.14.168", | ||
"@types/mocha": "^8.2.2", | ||
"@types/node": "^14.14.37", | ||
"@types/benchmark": "^2.1.1", | ||
"@types/chai": "^4.2.22", | ||
"@types/lodash": "^4.14.175", | ||
"@types/mocha": "^9.0.0", | ||
"@types/node": "^16.10.3", | ||
"benchmark": "^2.1.4", | ||
"chai": "^4.3.4", | ||
"mocha": "^8.3.2", | ||
"tslib": "^2.1.0", | ||
"typescript": "^4.2.3" | ||
"mocha": "^9.1.2", | ||
"tslib": "^2.3.1", | ||
"typescript": "^4.4.3" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
225503
4102