Home / Companies / Snyk / Blog / Post Details
Content Deep Dive

Using ES2015 Proxy for fun and profit

Blog post from Snyk

Post Details
Company
Date Published
Author
Alon Niv
Word Count
1,147
Company Posts That Month
3
Language
English
Hacker News Points
2
Post removed?
No
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.

Trends Found in this Post

No tracked trend matches for this post yet.

Use This Data

Use this post, company, and trend context to find content marketing opportunities, perform competitive analysis, or address product feature gaps via the Plushcap MCP server or the Plushcap API.