Skip to content

Instantly share code, notes, and snippets.

@ernestlv
Created April 17, 2016 17:17
Show Gist options
  • Save ernestlv/fe574e241634f3b8aa45a4d73d49f914 to your computer and use it in GitHub Desktop.
Save ernestlv/fe574e241634f3b8aa45a4d73d49f914 to your computer and use it in GitHub Desktop.
Pipes two functions
/*
Pipes two functions
*/
function pipe(fn, fnPipe, obj){
var fnx = function(){};
if (typeof fn === 'function'){
fnx = function(){
var res = fn.apply(this, [].slice.apply(arguments));
return typeof fnPipe === 'function' ? fnPipe.call(this, res) : res;
}.bind(obj || window);
}else{
console.log('pipe warning not a function:', fn);
}
return fnx;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment