0.0.2 • Published 7 years ago

thin-trap v0.0.2

Weekly downloads
4
License
BSD-2-Clause
Repository
github
Last release
7 years ago

npm Bower

thin-trap

Thin ES6 Proxy Wrapper for Better Transparency (experimental)

window.XMLHttpRequest = trap(window.XMLHttpRequest,
  function loggerForwarder(trapName, args, target, outerProxy, thisArg, proxyForThis) {
    console.log('trap:', trapName, args,
      'for', (typeof target === 'function' ? target.name : target),
      'thisArg', (thisArg && thisArg.name ? thisArg.name : thisArg));
    return Reflect[trapName](...args);
  }
);

Install

Browsers

  bower install --save thin-trap

NodeJS

  npm install --save thin-trap

Import

Browsers

  <script src="path/to/bower_components/thin-trap/trap.js"></script>

NodeJS

const trap = require('thin-trap/trap.js');

API

TBD

License

BSD-2-Clause