eg this
function sad(input) {
return new Promise((resolve, reject) =>
foo(input).then((data) => {
bar(data).then((data2) => {
baz(data2).then(resolve, reject)
})
})
);
}
could quite as easily have been written like this: function happy(input) {
return foo(input)
.then((data) => bar(data))
.then((data2) => baz(data2))
}
But no one seemed to be aware that you can return a promise in the `.then()` callback and have it chain neatly...