Skip to content

Instantly share code, notes, and snippets.

@djfm
Created September 18, 2016 14:51
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 djfm/1fae66cb56be86f77042bcbecdee9a4d to your computer and use it in GitHub Desktop.
Save djfm/1fae66cb56be86f77042bcbecdee9a4d to your computer and use it in GitHub Desktop.
const just = x => Promise.resolve(x);
const nothing = () => Promise.reject();
chain(
() => just(1),
() => nothing(),
(_, x, y) => just(x / y)
)()
.should.be.rejected;
chain(
() => just(1),
() => just(2),
(_, x, y) => just(x / y)
)()
.should.eventually.equal(0.5);
// try it: https://jsfiddle.net/r7haet84/1/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment