const NO_PROMISES_MESSAGE = "No promises to race";
const wrapPromise = (key, promise) => Promise.resolve(promise).then((result) => ({
  key,
  status: "fulfilled",
  result
}));
async function promiseRace(promises) {
  const keys = Object.keys(promises);
  if (keys.length === 0) {
    throw new Error(NO_PROMISES_MESSAGE);
  }
  const wrapped = keys.map(
    (key) => wrapPromise(key, promises[key])
  );
  return await Promise.race(wrapped);
}
export {
  promiseRace
};
//# sourceMappingURL=promise-race.js.map
