Skip to content

Instantly share code, notes, and snippets.

@nhz-io
Created October 29, 2017 13:27
Show Gist options
  • Save nhz-io/3ee1d477ae3be376d8e58ba95ee5985b to your computer and use it in GitHub Desktop.
Save nhz-io/3ee1d477ae3be376d8e58ba95ee5985b to your computer and use it in GitHub Desktop.
Magic pipe
const $ = (...fs) => {
const g = (fs, f = fs.shift(), n = f.length, a = []) =>
x => (--n > 0)
? g(fs, f, n, [...a, x])
: fs.length ? g(fs)(f(...a, x)) : f(...a, x)
return g(fs)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment