1
0
mirror of https://github.com/oceanprotocol-archive/squid-js.git synced 2024-02-02 15:31:51 +01:00
squid-js/src/utils/PromiseResolver.ts
2019-04-23 12:46:52 +02:00

13 lines
346 B
TypeScript

const zipObject = (keys = [], values = []) => {
return keys.reduce((acc, key, index) => ({
...acc,
[key]: values[index],
}), {})
}
export const objectPromiseAll = async (obj: {[key: string]: Promise<any>}) => {
const keys = Object.keys(obj)
const result = await Promise.all(Object.values(obj))
return zipObject(keys, result)
}