Skip to content

Instantly share code, notes, and snippets.

@leonardovillela
Created October 4, 2018 12:26
Show Gist options
  • Save leonardovillela/8f3a7178ad5bcac51dd77eb99ed68c4f to your computer and use it in GitHub Desktop.
Save leonardovillela/8f3a7178ad5bcac51dd77eb99ed68c4f to your computer and use it in GitHub Desktop.
Compose fns and bail if any function has result
function composeBailResultP(...args) {
return args.reduce((accumulator, currentFunction) => async function* exec(...params) {
const result = await currentFunction(...params);
if (!!result) {
yield result;
}
return accumulator(result);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment