Skip to content

Instantly share code, notes, and snippets.

@0xemc
Created June 15, 2020 01:37
Show Gist options
  • Select an option

  • Save 0xemc/4bb4b45ec16e3dac816b9f882b4980a8 to your computer and use it in GitHub Desktop.

Select an option

Save 0xemc/4bb4b45ec16e3dac816b9f882b4980a8 to your computer and use it in GitHub Desktop.
Functional Utilities
// AND composition, apply all functions
compose = fns => x => fns.reduceRight((y, f) => f(y), x);
// OR composition, apply functions until one returns true
composeAny = fns => x => fns.some(f => f(x));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment