Files
openzeppelin-contracts/test/helpers/iterate.js
Hadrien Croubois cffb2f1ddc Migrate math tests to ethers.js v6 (#4769)
Co-authored-by: Ernesto García <ernestognw@gmail.com>
2023-12-04 13:00:00 -06:00

11 lines
321 B
JavaScript

// Map values in an object
const mapValues = (obj, fn) => Object.fromEntries(Object.entries(obj).map(([k, v]) => [k, fn(v)]));
// Cartesian product of a list of arrays
const product = (...arrays) => arrays.reduce((a, b) => a.flatMap(ai => b.map(bi => [...ai, bi])), [[]]);
module.exports = {
mapValues,
product,
};