Skip to content

Instantly share code, notes, and snippets.

@lestoni
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 lestoni/5f7e4fa3794db843a999 to your computer and use it in GitHub Desktop.
Save lestoni/5f7e4fa3794db843a999 to your computer and use it in GitHub Desktop.
Pre-Pro Fn invocation
function func(fn, beforeFn, afterFn /*, thisArgs*/){
var context = arguments.length === 4 ? arguments[3] : null;
var queue = [beforeFn, fn, afterFn];
return function(){
var args = [].slice.call(arguments);
queue.forEach(function(fn, index){
index === 1 ? fn.apply(context,args) : fn.apply(context);
});
};
}
@lestoni
Copy link
Author

lestoni commented Jun 9, 2014

Wrap any function with a before() and after() logic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment