javascript-proxy-aop

    0.0.2 • Public • Published

    javascript-proxy-aop Build Status Coverage Status

    Uses ES6 Proxy to instrument JS in an (unfortunately too verbose) aspect-oriented way

    Install

    $ npm install --save javascript-proxy-aop
    

    Usage

    const javascriptProxyAop = require('javascript-proxy-aop');
     
    // pubSub may be any object that supports trigger
    const instrument = javascriptProxyAop(pubSub);
     
    const obj = instrument({
        method: function() {},
        anotherMethod: function fooBar() {}
    });
     
    obj.method(['hello', 'world']);
    // => pubSub.on('onBeforeMethod', method, args) is called
    // => method: 'anonymous<method>'
    // => args: [['hello', 'world']]
    // => pubSub.on('onAfterMethod', method, args) is called
    // => method: 'anonymous<method>'
    // => args: [['hello', 'world']]
    // => result: undefined
     
    obj.anotherMethod(); // method is 'fooBar'

    TODO

    • enable to instrument functions directly

    License

    MIT © Daniel Schmidt

    Keywords

    none

    Install

    npm i javascript-proxy-aop

    DownloadsWeekly Downloads

    0

    Version

    0.0.2

    License

    MIT

    Last publish

    Collaborators

    • dschmidt