A Proxy handler maker that drastically simplifies making and using Harmony Proxies by combining traps and normalizing their arguments.

Easy Proxy

Shims in Direct-Proxies and then builds a simplified handler on top of that. The traps are abstracted down into a smaller set of traps with normalized parameters and simple to use forwarding.

npm install easy-proxy


var EasyProxy = require('easy-proxy');
var proxied = EasyProxy(target, {
  list:   function(reflecttargettypeownhidden)              { return reflect() },
  has:    function(reflecttargetnameown)                      { return reflect() },
  get:    function(reflecttargetnameownreceivernormalize) { return reflect() },
  set:    function(reflecttargetnamevalreceivernormalize) { return reflect() },
  unset:  function(reflecttargetname)                           { return reflect() },
  fix:    function(reflecttargettype)                           { return reflect() },
  invokefunction(reflecttargettypeargsreceiver)           { return reflect() },


Any traps not provided in the handler will default to reflecting normally onto the target.

The first parameter is always a function that when called with no arguments will execute the default forwarding action. This allows for easy interception and modification. It also accepts a single object passed that specified overrides on the default action.

  • trap: Direct Proxies traps name name to execute instead of the default
  • target: Redirect the action to another target
  • name: Change the name that actual is executed again for traps that are for specific properties
  • value: Change the value for set
  • receiver: Change the receiver for get, set, and invoke
// redirect all set operations to global instead; 
var redirected = EasyProxy({}, {
    return reflect({ target: global });

For get and set, normalize is a function provided as the last parameter. Its pupose is normalize the difference between a descriptor and normal value since these traps are set+defineProperty and get+getOwnPropertyDescriptor.

var typeofWrap = EasyProxy(global, {
    return normalize(typeof target[name]);