Skip to content

Instantly share code, notes, and snippets.

@bravelincy
Created April 20, 2017 12:18
Show Gist options
  • Save bravelincy/9d137329fecaf34f6e8eaeb95560c28c to your computer and use it in GitHub Desktop.
Save bravelincy/9d137329fecaf34f6e8eaeb95560c28c to your computer and use it in GitHub Desktop.
function pipe() {
let funcs = arguments;
return function() {
let length = funcs.length;
let index = 0;
let result;
while (index < length) {
let fn = funcs[index];
result = index ? fn.call(null, result) : fn.apply(null, arguments)
index++;
}
return result;
}
}
function compose() {
return pipe.apply(null, [].reverse.call(arguments))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment