Skip to content

Instantly share code, notes, and snippets.

@A
Last active December 29, 2015 19:59
Show Gist options
  • Save A/7720516 to your computer and use it in GitHub Desktop.
Save A/7720516 to your computer and use it in GitHub Desktop.
JS Functions wrappers.
/**
* Abstract
*/
var obj = {
wrapped: function(a,b) {
console.log('this:', this);
console.log('a:', a);
console.log('b:', b);
}
}
var wrapper = function () {
obj.wrapped.apply(obj, arguments);
}
obj.wrapped(1,2);
wrapper(3,4);
/**
* Wrapper for express res.send() method.
*/
module.export = {
send: function () {
return function (req,res) {
res.send.apply(res, arguments);
};
}
};
/**
* Wrapper for Array.push() method;
*/
var arr = new Array();
arr.push = function() {
console.log('push');
return arr.__proto__.push.apply(arr, arguments);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment