Skip to content

Commit d09acdc

Browse files
Łukasz Kużyńskiulfryk
authored andcommitted
Added Either.fromPromise and Either.prototype.toPromise #222
1 parent 0abb87d commit d09acdc

File tree

5 files changed

+3968
-1
lines changed

5 files changed

+3968
-1
lines changed

docs/EITHER.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ const i = 1;
3737
Either.fromTry(i.toPrecision(500))
3838
```
3939

40+
41+
### Creating an Either from a Promise
42+
```javascript
43+
Either.fromPromise(Promise.resolve({foo: 'bar'})) // Promise of Either.Right
44+
Either.fromPromise(Promise.reject(new Error('error'))) // Promise of Either.Left
45+
```
46+
4047
## Methods
4148

4249
### map
@@ -220,6 +227,14 @@ Either[E,A].toMaybe(): Maybe[A]
220227

221228
Converts to a `Maybe` dropping the left side.
222229

230+
### toPromise
231+
232+
```scala
233+
Either[E,A].toPromise(): Promise[A]
234+
```
235+
236+
Converts to resolved Promise on the right side and rejected Promise on the left side.
237+
223238
### ...and undocumented
224239
- equals
225240
- join

0 commit comments

Comments
 (0)