mirror of
https://github.com/xodio/xod.git
synced 2026-03-07 09:16:51 +01:00
feat(xod-func-tools): add ‘eitherToPromise’ util
This commit is contained in:
@@ -71,6 +71,12 @@ export const foldEither = def(
|
||||
)
|
||||
);
|
||||
|
||||
// :: Either a b -> Promise a b
|
||||
export const eitherToPromise = foldEither(
|
||||
Promise.reject.bind(Promise),
|
||||
Promise.resolve.bind(Promise)
|
||||
);
|
||||
|
||||
/**
|
||||
* Unwraps Either monad and returns it’s value if it is Right and throws an Error
|
||||
* if it is Left.
|
||||
|
||||
Reference in New Issue
Block a user