UNPKG

@augment-vir/common

Version:

A collection of augments, helpers types, functions, and classes for any JavaScript environment.

18 lines (17 loc) 505 B
/** * Race all the given values and return the one that finished first. * * @category Promise * @category Package : @augment-vir/common * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common) */ export async function racePromiseObject(promises) { return await Promise.race(Object.entries(promises).map(([key, value,]) => { return value.then((value) => { return { value, key, }; }); })); }