@0x/contracts-test-utils
: Add shortZip()
.
This commit is contained in:
committed by
Lawrence Forman
parent
993f05d5ac
commit
b4b6d4d969
9
contracts/test-utils/src/lang_utils.ts
Normal file
9
contracts/test-utils/src/lang_utils.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import * as _ from 'lodash';
|
||||
|
||||
/**
|
||||
* _.zip() that clips to the shortest array.
|
||||
*/
|
||||
export function shortZip<T1, T2>(a: T1[], b: T2[]): Array<[T1, T2]> {
|
||||
const minLength = Math.min(a.length, b.length);
|
||||
return _.zip(a.slice(0, minLength), b.slice(0, minLength)) as Array<[T1, T2]>;
|
||||
}
|
Reference in New Issue
Block a user