insomnia/packages/insomnia-smoke-test/modules/find-async.js
2020-11-25 15:26:00 +13:00

7 lines
228 B
JavaScript

export default async function findAsync(arr, asyncCallback) {
const promises = arr.map(asyncCallback);
const results = await Promise.all(promises);
const index = results.findIndex(result => result);
return arr[index];
}