diff --git a/src/functional.ts b/src/functional.ts index 05c4e57..46ca2d4 100644 --- a/src/functional.ts +++ b/src/functional.ts @@ -6,3 +6,11 @@ export const sequence = (fn: ($: T) => Promise) => async (L: T[]) => { export const parallel = (fn: ($: T) => Promise) => async (L: T[]) => { await Promise.all(L.map(fn)); }; + + +export const notUndefined: ($: T | undefined) => T = $ => { + if ($ === undefined) + throw Error('the value is undefined!'); + else + return $; +};