Skip to content

Commit cfec0c6

Browse files
promiseForObject: convert to be async function (#3736)
1 parent d3146a1 commit cfec0c6

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/jsutils/promiseForObject.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,16 @@ import type { ObjMap } from './ObjMap.js';
77
* This is akin to bluebird's `Promise.props`, but implemented only using
88
* `Promise.all` so it will work with any implementation of ES6 promises.
99
*/
10-
export function promiseForObject<T>(
10+
export async function promiseForObject<T>(
1111
object: ObjMap<Promise<T>>,
1212
): Promise<ObjMap<T>> {
1313
const keys = Object.keys(object);
1414
const values = Object.values(object);
1515

16-
return Promise.all(values).then((resolvedValues) => {
17-
const resolvedObject = Object.create(null);
18-
for (let i = 0; i < keys.length; ++i) {
19-
resolvedObject[keys[i]] = resolvedValues[i];
20-
}
21-
return resolvedObject;
22-
});
16+
const resolvedValues = await Promise.all(values);
17+
const resolvedObject = Object.create(null);
18+
for (let i = 0; i < keys.length; ++i) {
19+
resolvedObject[keys[i]] = resolvedValues[i];
20+
}
21+
return resolvedObject;
2322
}

0 commit comments

Comments
 (0)