insomnia/packages/insomnia-smoke-test/modules/find-async.ts

7 lines
228 B
TypeScript
Raw Normal View History

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];
}