Skip to content

Instantly share code, notes, and snippets.

@tobynet
Created October 19, 2015 20:26
Show Gist options
  • Save tobynet/a2cec6ca3e453b3e30e3 to your computer and use it in GitHub Desktop.
Save tobynet/a2cec6ca3e453b3e30e3 to your computer and use it in GitHub Desktop.
Let's play on the Promises
let double = (x) => x * x
, plus = (x) => (y) => x + y
, print = (x) => {
document.querySelector("#log")
.appendChild(
document.createTextNode(x + "\n"));
return x;
}
Promise.resolve(10)
.then(print)
.then(double)
.then(print)
.then(plus(10))
.then(print);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment