0.0.0 • Published 9 years ago

advice.js v0.0.0

Weekly downloads
7
License
-
Repository
github
Last release
9 years ago

advice.js

Build Status

Simple AOP library for both Node.js and browsers.

function base() {}

// compose a new function which calls a function after base returns
var fn = advice.after(base, function() {
  console.log('base was called');
});


var obj = {
  foo: function() {}
};

// redefine a method which calls a function after obj.foo returns
advice.after(obj, 'foo', function() {
  console.log('obj.foo was called');
});

Documentation

advice.before(base, fn)

advice.before(obj, method, fn)

advice.after(base, fn)

advice.after(obj, method, fn)

advice.around(base, fn)

advice.around(obj, method, fn)

License

MIT