Skip to content

Instantly share code, notes, and snippets.

@jquense
Created February 23, 2015 21:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jquense/95b6d811c0a03007baf5 to your computer and use it in GitHub Desktop.
Save jquense/95b6d811c0a03007baf5 to your computer and use it in GitHub Desktop.
compose([your, code, looks, like, shit]);
function compose(_chain) {
chain = _chain.reverse();
(function next(index, args) {
args.push(callback)
if(index < chain.length)
chain[index].apply(this, args)
function callback(err, val) {
if (err) throw err
next(index + 1, [val])
}
})(0, []);
}
shit()
.then(like)
.then(looks)
.then(code)
.then(your)
.catch( err => //handle it);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment