Skip to content

Instantly share code, notes, and snippets.

@dwickstrom
Created August 24, 2017 10:45
Show Gist options
  • Save dwickstrom/bcd6b56538b93d9ba7cee7fa0aa84c9c to your computer and use it in GitHub Desktop.
Save dwickstrom/bcd6b56538b93d9ba7cee7fa0aa84c9c to your computer and use it in GitHub Desktop.
Fantasy Land Promise
Promise.of = Promise.resolve
Promise.prototype.chain = Promise.prototype.then
Promise.prototype.map = Promise.prototype.then
Promise.prototype.ap = function (other) {
this.chain(f => other.map(x => f(x)))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment