functional: add undefined checker
This commit is contained in:
@@ -6,3 +6,11 @@ export const sequence = <T, U>(fn: ($: T) => Promise<U>) => async (L: T[]) => {
|
|||||||
export const parallel = <T, U>(fn: ($: T) => Promise<U>) => async (L: T[]) => {
|
export const parallel = <T, U>(fn: ($: T) => Promise<U>) => async (L: T[]) => {
|
||||||
await Promise.all(L.map(fn));
|
await Promise.all(L.map(fn));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export const notUndefined: <T>($: T | undefined) => T = $ => {
|
||||||
|
if ($ === undefined)
|
||||||
|
throw Error('the value is undefined!');
|
||||||
|
else
|
||||||
|
return $;
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user