17 lines
413 B
TypeScript
17 lines
413 B
TypeScript
export const sequence = <T, U>(fn: ($: T) => Promise<U>) => async (L: T[]) => {
|
|
for (const o of L)
|
|
await fn(o);
|
|
};
|
|
|
|
export const parallel = <T, U>(fn: ($: T) => Promise<U>) => async (L: T[]) => {
|
|
await Promise.all(L.map(fn));
|
|
};
|
|
|
|
|
|
export const notUndefined: <T>($: T | undefined) => T = $ => {
|
|
if ($ === undefined)
|
|
throw Error('the value is undefined!');
|
|
else
|
|
return $;
|
|
};
|