Skip to content

Instantly share code, notes, and snippets.

@tomasperezv
Last active November 13, 2016 12:03
Show Gist options
  • Select an option

  • Save tomasperezv/67c65a6232302bb72fd4b2289c6b30b7 to your computer and use it in GitHub Desktop.

Select an option

Save tomasperezv/67c65a6232302bb72fd4b2289c6b30b7 to your computer and use it in GitHub Desktop.
/**
* Encapsulate the operation of creating a Proxy object assuring compatibility
* across different versions of Node.js and browsers.
*/
initializeProxy(handler: ProxyHandler, proto: Object): Proxy {
let proxy;
if (typeof Proxy.create !== 'undefined') {
proxy = Proxy.create(handler, proto);
} else {
proxy = new Proxy(proto, handler);
}
return proxy;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment