Skip to content

Instantly share code, notes, and snippets.

View hhamilto's full-sized avatar
🎯
Focusing

Hurricane Hamilton hhamilto

🎯
Focusing
View GitHub Profile
@angus-c
angus-c / advice.js
Created June 3, 2012 20:12
an advice functional mixin
//usage
withAdvice.call(targetObject);
//mixin augments target object with around, before and after methods
//method is the base method, advice is the augmenting function
withAdvice: function() {
['before', 'after', 'around'].forEach(function(m) {
this[m] = function(method, advice) {
if (typeof this[method] == 'function') {
return this[method] = fn[m](this[method], advice);