The Proxy object was included in the ES2015 iteration of the standard and is available in all evergreen browsers and Node.js v6. Unfortunately as it is a big language semantic change, it cannot be polyfilled through transpilers such as Babel.
Know of any brilliant resources? Let us know and we'll create a vast collection of awesomeness.
Proxies are a common pattern in both programming and networking. It often entails something interfacing with something else. Usually a proxy takes the role of the original contstruct and intercepts calls made to that construct and in some cases altering it's original behaviour. This allows you to enrich functions with more actions or operations in a transitive manner, or even intercept and cancel an action.
A proxy can be looked at as a decorator function, but with you can intercept default language semantics also, in a meta-level of programming instead of at the base-level.
- Slides: Metaprogramming SUPERPOWERS by Nickolay Ribal
- Slides: Diving into ES2015 proxy performance in V8 by Maya Lekova
- Use ES6 Proxies by Kent C. Dodds
- Metaprogramming in ES6: Part 3 - Proxies by Keith Cirkel
- Exploring JS chapter 28. Metaprogramming with proxies by Dr. Axel Rauschmayer
- ES6 Proxies in Depth by Nicolás Bevacqua
- Introducing ES2015 Proxies by Addy Osmani
- ES6 In Depth: Proxies by Jason Orendorff
- Object Path resolver by Hemanth.HM
- Using ES2015 Proxy for fun and profit by Alon Niv
- negative-array: Negative array index support
array[-1]using ES2015 Proxy
- known: Allow only access to known object properties using ES2015 Proxy
- proxy-observe: A Proxy based implementation of Object.observe
- stroxy: A simple streaming wrapper for native event functions (e.g.
addEventListener) using ES2015 proxies.
- Declaraoids: Declarative programming on steroids.
- Promiser: Promise combination resolver by get accessor pattern.
- React Easy State: A transparent state management library for React.
- The Observer Utility: A general purpose transparent reactivity library (React Easy State is just a thin wrapper of it). It uses ES6 Proxies to achieve a 100% language coverage for reactivity.
- The Compiler Utility: A 'sandboxed' code evaluation library. It uses ES6 Proxies (has traps) in conjuction with the
withkeyword to 'sandbox' code.
- mewt: Array and object immutability implemented in under one kilobyte using Proxies.
- objecthistory: Object undo, redo & change history using Proxies.
- hoopy: Circular array type
- emmis: Chaining API where you reduce over payload and operators, like redux
- rus_roulette: Bringing runtime errors back to fashion
- Echo: Write a line of code that starts with
Echo, and Echo will print it back to the console.
- Comlink: Uses proxies to hide the fact that you're using Web Workers.
Meta-programming in general
- Metaprogramming in ES6: Symbols and why they're awesome by Keith Cirkel
- Metaprogramming in ES6: Part 2 - Reflect by Keith Cirkel
Examples in this repo
Run all examples in this repo by using
$ node ./examples/<example-file>.js
Examples using tracing and tests can be run using
$ npm test
Remember to install all example dependencies by doing