Promise.re (native implementation)
-
-
Save hew/c5db1bcaf128d78599b2822fcf69f77a to your computer and use it in GitHub Desktop.
Promise.re (native implementation)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let all = Js.Promise.all; | |
let resolve = Js.Promise.resolve; | |
let reject = Js.Promise.reject; | |
let andThen = | |
(p: Js.Promise.t('a), fn: 'a => Js.Promise.t('b)): Js.Promise.t('b) => | |
p->Js.Promise.then_(fn, _); | |
let map = (p: Js.Promise.t('a), fn: 'a => 'b): Js.Promise.t('b) => | |
p->Js.Promise.then_(x => x->fn->resolve, _); | |
let wait = (p: Js.Promise.t('a), fn: 'a => unit): unit => | |
p->Js.Promise.then_(x => x->fn->resolve, _)->ignore; | |
let catch = (p: Js.Promise.t('a), fn: Js.Promise.error => Js.Promise.t('a)) => | |
p->Js.Promise.catch(fn, _); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment