diff --git a/packages/xod-func-tools/src/index.js b/packages/xod-func-tools/src/index.js index 2f237800..431c6b7d 100644 --- a/packages/xod-func-tools/src/index.js +++ b/packages/xod-func-tools/src/index.js @@ -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.