Skip to content

Commit

Permalink
NS-98
Browse files Browse the repository at this point in the history
  • Loading branch information
KarolinaFilipiuk committed Nov 12, 2020
1 parent c8754de commit 252f35b
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/helpers/array.helper.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
export class ArrayHelper {
public static zip<T>(array1: T[], array2: T[]): [T, T][] {
let longer: T[];
let shorter: T[];
if (array1.length >= array2.length) {
[longer, shorter] = [array1, array2];
} else {
[longer, shorter] = [array2, array1];
public static zip<T1, T2>(
array1: (T1 | null)[],
array2: (T2 | null)[]
): [T1 | null, T2 | null][] {
if (array1.length < array2.length) {
const count = array2.length - array1.length;
array1.fill(null, count);
}
return longer.map((v: T, index: number) => [v, shorter[index]]);
return array1.map((v, index: number) => [v, array2[index]]);
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down

0 comments on commit 252f35b

Please sign in to comment.