monet / monet.js

monet.js - Monadic types library for JavaScript
https://monet.github.io/monet.js/
MIT License
1.6k stars 114 forks source link

`Either.fromPromise` #222

Closed wookieb closed 4 years ago

wookieb commented 4 years ago

I found that monet.js does not support async functions very well. How about adding Either.fromPromise? I can handle that...

ulfryk commented 4 years ago

@wookieb - great - I'll wait with 0.9.1 for this feature then :)

ulfryk commented 4 years ago

Just maybe add also .toPromise() to Either instances ;)

wookieb commented 4 years ago

Not sure about how it should work. Return rejected promise for Left?

ulfryk commented 4 years ago

@wookieb Promise if rejected holds an Error or any other Failure value, so it should be on the left.

Left(xyz) --> Promise.reject(xyz)
Right(xyz) --> Promise.resolve(xyz)
ulfryk commented 4 years ago

.cata(Promise.reject, Promise.resolve) ? :D

wookieb commented 4 years ago

Ok. Just few minutes