Skip to content

Instantly share code, notes, and snippets.

@alepeino
Created July 21, 2018 21:30
Show Gist options
  • Save alepeino/609a4cb19993f4877c16ee606af72608 to your computer and use it in GitHub Desktop.
Save alepeino/609a4cb19993f4877c16ee606af72608 to your computer and use it in GitHub Desktop.
deferred (simple Promise implementation)
// https://gist.github.com/fernandezpablo85/d020ea0efada7f5d4ab746f803ce723c
class deferred {
thens = []
then (fn) {
this.thens.push(fn)
return this
}
done (value) {
this.thens.reduce(
(v, fn) => v.then ? v.then(fn) : fn(v),
value
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment