
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
harmony-reflect
Advanced tools
The harmony-reflect package is a library for ECMAScript 2015 (also known as ES6) that provides a full implementation of the ES6 Reflect API and Proxy handlers. It allows developers to intercept and define custom behavior for fundamental language operations (e.g., property lookup, assignment, enumeration, function invocation, etc.) using the Proxy API. It also provides utility functions that mirror the standard Reflect API, which provides methods for interceptable JavaScript operations.
Proxying an object
This code demonstrates how to create a proxy for an object that returns the property value if it exists, or 42 if it does not.
{"handler": {"get": function(target, name) { return name in target ? target[name] : 42; }}, "proxy": new Proxy({}, handler)}
Reflecting property access
This code uses the Reflect API to access the property 'foo' on the target object.
{"target": {"foo": 1}, "status": Reflect.get(target, 'foo')}
Defining a property on an object
This code snippet uses Reflect.defineProperty to define a new property 'foo' on the target object with the value 123.
{"target": {}, "status": Reflect.defineProperty(target, 'foo', {value: 123})}
Observing function invocations
This code shows how to create a proxy for a function that intercepts the call and returns the result multiplied by 2.
{"handler": {"apply": function(target, thisArg, argumentsList) { return target.apply(thisArg, argumentsList) * 2; }}, "proxy": new Proxy(function(x) { return x; }, handler)}
The proxy-polyfill package provides a very limited polyfill for the Proxy object, which allows you to use a subset of the Proxy API features in environments that do not support it natively. It does not support the full range of metaprogramming capabilities that harmony-reflect offers.
The reflect-metadata package is a polyfill for the experimental metadata reflection API. It allows developers to add and read metadata on classes and properties. While it deals with reflection, it is more focused on metadata than the general proxy and reflection capabilities provided by harmony-reflect.
FAQs
ES5 shim for ES6 (ECMAScript 6) Reflect and Proxy objects
The npm package harmony-reflect receives a total of 5,510,623 weekly downloads. As such, harmony-reflect popularity was classified as popular.
We found that harmony-reflect demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.