This is a shim for the ECMAScript-Harmony reflection module.
In a browser, after loading
<script src="reflect.js"></script>
a global object Reflect
is defined that contains the functions from the ES-Harmony reflect
module (see below).
The Proxy
object is also updated to follow the latest direct proxies spec. To create such a proxy, call:
var proxy = Proxy(target, handler)
If you are using node.js (>= v0.7.8), you can install via npm:
npm install harmony-reflect
Then:
node --harmony
> require('harmony-reflect');
This module exports a single object named Reflect
.
The ECMAScript 6 Proxy API allows one to intercept various operations on Javascript objects: overview of all supported traps.
See the Reflect API and Handler API docs for further details.
The Reflect
API, with support for proxies, was tested on:
- Firefox 12 (should work since Firefox 4)
- Chrome 19, under an experimental flag
- spidermonkey shell
v8 --harmony
(on 3.11.0, should work since at least v3.6)node --harmony
(in node v0.7.8)
After loading reflect.js
into your page or other JS environment, be aware that the following globals are patched to be able to recognize emulated direct proxies:
Object.{freeze,seal,preventExtensions}
Object.{isFrozen,isSealed,isExtensible}
Object.getPrototypeOf
Object.prototype.valueOf
Object.getOwnPropertyDescriptor
Function.prototype.toString
Date.prototype.toString
Proxy
See the list of open issues.
- Provide fallback behavior for part of the API, for environments without Proxy or WeakMap support.
- More tests.
- Switch to qunit or other unit testing framework.
- Add example uses of proxies (e.g. membranes)