3 ms·
Proxy has already been standardised (in ES6) so it should be coming into browsers soon. It's a little harder to polyfill than O.o though.
by thomasfoster96 11y ago
Proxy has already been standardised (in ES6) so it should be coming into browsers soon. It's a little harder to polyfill than O.o though.
- AnkhMorporkian 11y agoAs far as I know Proxy is impossible to polyfill. There are some patches which make old browser versions of Proxy meet the spec, but I just don't think you can close the Proxy gap with pure javascript.
- pipeep 11y agoIt's possible if you also translate all of the code that uses the polyfilled object by converting every MemberExpression to a function call, but that's probably a nightmare for performance.
- bcherny 11y agowhat happens when i add a property to the object that i'm proxying after the Proxy is already instantiated? you wouldn't be able to detect the addition and add getters/setters for the property unless you use some sort of O.o or dirty checking on the underlying object. see https://github.com/bcherny/auditable https://github.com/bcherny/auditable for an implementation, sans O.o.
- pipeep 11y agoIf you intercept every MemberExpression on every object, you can solve this (with the exception of eval), but as I said, it would be incredibly slow.