Company
Date Published
Author
Alon Niv
Word count
1147
Language
English
Hacker News points
2

Summary

ES2015 Proxy` allows developers to trap and manipulate property access, setting, has, and deleteProperty events on objects in a controlled manner, providing useful applications for testing, mocking, and monkeypatching, as well as abstractions over complicated concepts. A package `snykwire` is created to safely require modules by limiting their access to specific modules, utilizing the `Proxy` constructor with two parameters: `target` (the object being proxied) and a handler object containing spec for traps to handle. The `get`, `set`, `has`, and `deleteProperty` traps can be used to intercept and control property access, allowing developers to implement features like blacklisting modules and preventing corrupting of the module cache.