
Research
/Security News
Compromised npm Packages in the AsyncAPI Namespace Deliver Miasma Botnet Loader
3 compromised asyncapi packages deliver miasma botnet loader on macOS, Linux and Windows.
proxy-extend
Advanced tools
Transparently extend any JS object, using ES6 Proxy.
Given some existing JS value, you may want to add some information to this value without actually modifying the original. The simplest way to do so is to create a wrapper around the value:
const someValue = getValue();
const someValueAnnotated = {
value: someValue,
status: 'ready',
};
One drawback of using a wrapper object, is that the newly annotated value now has a different interface from the original. That means that any consuming code will need to know about the wrapper and "unwrap" it do anything with it.
Using ES6 Proxy, we can make the wrapper have the same interface as the original value, allowing us to pass the wrapped value to any consuming code without the consumer needing to know whether it has been proxied or not.
import ProxyExtend from 'proxy-extend';
const user = { name: 'John' }; // Some value to be extended
const userExtended = ProxyExtend(user, { status: 'ready' });
// The extended value has the same interface as the original
userExtended.name; // 'John'
({ ...userExtended }); // { name: 'John' }
// But we can also access our annotation, if we know the name of the key
userExtended.status; // { status: 'ready' }
To make sure that we do not conflict with any existing properties on the original value, it is useful to use a Symbol as the key of the annotation:
import ProxyExtend from 'proxy-extend';
const user = { name: 'John' };
const meta = Symbol('meta'); // Private symbol
const userExtended = ProxyExtend(user, { [meta]: 'some metadata' });
userExtended.name; // 'John'
userExtended[meta]; // 'some metadata'
Due to the nature of Proxy, we can only use an object as target value. This library supports any JS object, including plain objects, arrays, functions, and class constructors. We also support a few kinds of primitives by emulating them using objects:
null (using an empty object with null prototype)String)Number)Checking reference equality will no longer work. That includes primitives as well:
const value = { x: 42 };
const proxy = ProxyExtend(value);
value !== proxy; // Reference equality does not hold
const proxyString = ProxyExtend('foo');
proxyString !== 'foo'; // Won't work
String(proxyString) === 'foo'; // Cast to string first instead
FAQs
Transparently extend a JS object with additional properties (using ES6 Proxy)
The npm package proxy-extend receives a total of 63 weekly downloads. As such, proxy-extend popularity was classified as not popular.
We found that proxy-extend 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.

Research
/Security News
3 compromised asyncapi packages deliver miasma botnet loader on macOS, Linux and Windows.

Research
/Security News
A compromised jscrambler npm release added a malicious preinstall hook that runs hidden native binaries on Linux, macOS, and Windows.

Research
/Security News
A malicious .NET package is typosquatting the Braintree SDK to steal live payment card data, merchant API keys, and host secrets from production apps.