diff --git a/lib/utils/promises.js b/lib/utils/promises.js index 7bd6df564..7bc11f70e 100644 --- a/lib/utils/promises.js +++ b/lib/utils/promises.js @@ -1,40 +1,42 @@ // @flow type Promisable = Promise | T; async function promiseAll }>( input: T, ): Promise<$ObjMap> { const promises = []; const keys = Object.keys(input); for (let i = 0; i < keys.length; i++) { const key = keys[i]; const promise = input[key]; promises.push(promise); } const results = await Promise.all(promises); const byName: { [string]: mixed } = {}; for (let i = 0; i < keys.length; i++) { const key = keys[i]; byName[key] = results[i]; } return byName; } async function promiseFilter( input: $ReadOnlyArray, filterFunc: (value: T) => Promise, ): Promise { const filterResults = await Promise.all(input.map(filterFunc)); return input.filter((value, index) => filterResults[index]); } -async function ignorePromiseRejections(promise: Promise) { - try { - await promise; - } catch (error) { - console.warn(error); - } +function ignorePromiseRejections(promise: Promise) { + void (async () => { + try { + await promise; + } catch (error) { + console.warn(error); + } + })(); } export { promiseAll, promiseFilter, ignorePromiseRejections };