proxy-target is a JavaScript utility library designed to simplify the use of native Proxies, particularly when dealing with primitive values, `null`, `undefined`, and functions. It addresses common `Proxy` limitations, such as the inability to directly proxy primitives or the 'Array.isArray shenanigans' by wrapping values in an object structure that can be consistently proxied and then unwrapped. The current stable version is 3.0.2. It appears to follow a release cadence driven by feature enhancements and bug fixes, rather than strict time-based intervals. Key differentiators include its ability to uniformly proxy almost any JavaScript value (primitives, objects, functions, etc.) by converting them into a structured `{ type, value }` pair, and its explicit mechanisms (`wrap`, `unwrap`, `bound`, `unbound`) for managing `this` context and value retrieval within a proxy chain. This makes it particularly useful for advanced metaprogramming scenarios where uniform proxy behavior across diverse value types is crucial.
npm install proxy-targetVerified import paths — ran on the pinned version, not inferred.
Demonstrates wrapping and unwrapping various JavaScript values (objects, primitives, functions) and using `bound`/`unbound` to manage function context within a proxy.
Always use `unwrap(proxiedValue)` before performing type checks, comparisons, or operations that expect the original primitive value.
For new projects or when upgrading, use `import { SymbolName } from 'proxy-target';`. For CommonJS in modern Node.js, consider dynamic `import()` or stick to `const { SymbolName } = require('proxy-target');` if available.Refer to the documentation for custom `wrap` callbacks. Ensure the callback returns a structure (`target(type, value)`) that `proxy-target` can properly interpret, or the original value if you intend it to bypass the wrapping logic.
Be aware of the specific wrapping behavior for arrays and functions. If you need arrays to be explicitly wrapped into a `{type: 'array', value: [...]}` structure, you may need to import `proxy-target/array` and use its specific `wrap` function, or provide a custom `wrap` callback.Do not attempt to mutate the internal `type` or `value` properties of wrapped primitives. If you need a different representation, unwrap the value, modify it, and re-wrap if necessary.
Ensure that any value passed to `wrap` (or returned by a custom `wrap` callback that is then passed to `Proxy`) is either an object/function, or is correctly transformed into the `{ type, value }` object structure by `proxy-target`'s internal logic or your custom callback.No dependency data recorded yet.