@0x/contracts-test-utils
: Add shortZip()
.
This commit is contained in:
parent
993f05d5ac
commit
b4b6d4d969
@ -84,7 +84,11 @@
|
||||
},
|
||||
{
|
||||
"note": "Tweaks/Upgrades to `hex_utils`, most notably `hexSlice()`",
|
||||
"pr": "TODO"
|
||||
"pr": 2155
|
||||
},
|
||||
{
|
||||
"note": "Add `shortZip()` to `lang_utils.ts`",
|
||||
"pr": 2155
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -50,3 +50,4 @@ export {
|
||||
export { blockchainTests, BlockchainTestsEnvironment, describe } from './mocha_blockchain';
|
||||
export { chaiSetup, expect } from './chai_setup';
|
||||
export { getCodesizeFromArtifact } from './codesize';
|
||||
export { shortZip } from './lang_utils';
|
||||
|
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]>;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user