Skip to content

Commit

Permalink
fix: need internals changes
Browse files Browse the repository at this point in the history
  • Loading branch information
erights committed Nov 9, 2022
1 parent 275a160 commit 173f452
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/internal/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,3 +353,13 @@ export const fsStreamReady = stream =>
stream.on('ready', onReady);
stream.on('error', onError);
});

/** @type { <X, Y>(xs: X[], ys: Y[]) => [X, Y][]} */
export const zip = (xs, ys) => harden(xs.map((x, i) => [x, ys[+i]]));

/** @type { <K extends string, V>(obj: Record<K, V | PromiseLike<V>>) => Promise<Record<K, V>> } */
export const allValues = async obj => {
const resolved = await Promise.all(Object.values(obj));
// @ts-expect-error cast
return harden(fromEntries(zip(Object.keys(obj), resolved)));
};

0 comments on commit 173f452

Please sign in to comment.