hardhat
Version:
Hardhat is an extensible developer tool that helps smart contract developers increase productivity by reliably bringing together the tools they want.
22 lines (18 loc) • 452 B
text/typescript
export function fromEntries<T = any>(entries: Array<[string, any]>): T {
return Object.assign(
{},
...entries.map(([name, value]) => ({
[name]: value,
}))
);
}
export function mapValues<T extends object, ResultT>(
o: T,
callback: (value: T[keyof T]) => ResultT[keyof ResultT]
): ResultT {
const result: any = {};
for (const [key, value] of Object.entries(o)) {
result[key] = callback(value);
}
return result;
}