From ea8bbdbacfc7efe1b8ad64e85a1efe792cf49f7f Mon Sep 17 00:00:00 2001 From: Evgeny Kochetkov Date: Wed, 19 Jul 2017 16:59:10 +0300 Subject: [PATCH] =?UTF-8?q?feat(xod-func-tools):=20add=20=E2=80=98eitherTo?= =?UTF-8?q?Promise=E2=80=99=20util?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/xod-func-tools/src/index.js | 6 ++++++ 1 file changed, 6 insertions(+) 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.