Skip to content

Instantly share code, notes, and snippets.

@Bondifrench
Last active May 17, 2017 00:05
Show Gist options
  • Save Bondifrench/2f968df5f58735dc78af52da704b8520 to your computer and use it in GitHub Desktop.
Save Bondifrench/2f968df5f58735dc78af52da704b8520 to your computer and use it in GitHub Desktop.
if you have a list of functions that return promises, that should be applied in sequence
//Thanks @JAForbes
const chain = (p, f) => p.then(f)
const zero = Promise.resolve()
const series = xs => xs.reduce(chain, zero)
series([ getX, getY, getZ ]).then( z => ... )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment