Skip to content

Instantly share code, notes, and snippets.

@timruffles
Last active August 29, 2015 14:02
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 timruffles/3b0c2d81d11c94922b37 to your computer and use it in GitHub Desktop.
Save timruffles/3b0c2d81d11c94922b37 to your computer and use it in GitHub Desktop.
pipe - it's more readable than compose
// compose functions left to right,
// more readable than 'compose'
// => pipe(parseInt,Math.sqrt)("64.928")
// 8
function pipe() {
var fns = arguments;
return function() {
var value = arguments;
for(var i = 0; i < fns.length; i++) {
value = [fns[i].apply(null,value)];
}
return value[0];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment