feat(xod-func-tools): add ‘eitherToPromise’ util

This commit is contained in:
Evgeny Kochetkov
2017-07-19 16:59:10 +03:00
parent 14cd8c6d53
commit ea8bbdbacf

View File

@@ -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 its value if it is Right and throws an Error
* if it is Left.