
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
@knighttower/js-object-proxy-helper
Advanced tools
Convert Object to proxy to protect the objects
Convert object to proxy to protect the object's properties and the object itself.
Allows to declare _private, _protected and _mutable all arrays with prop names.
npm i @knighttower/js-utility-functions
yarn add @knighttower/js-utility-functions
import ProxyHelper from '@knighttower/js-utility-functions';
It loads as a 'window' object --> window.ProxyHelper
<script src=" https://cdn.jsdelivr.net/npm/@knighttower/js-utility-functions@latest/dist/browser/ProxyHelper.min.js"></script>
// ---> Also available as ESM, UMD, CJS, JS // ESM
<script src="https://esm.run/@knighttower/js-utility-functions@latest/index.mjs"></script>
// UMD
<script src="https://cdn.jsdelivr.net/npm/@knighttower/js-utility-functions@latest/dist/umd/ProxyHelper.min.js"></script>
// CJS
<script src="https://cdn.jsdelivr.net/npm/@knighttower/js-utility-functions@latest/dist/cjs/ProxyHelper.min.js"></script>
Here is how you can use the ProxyHelper
function:
const proxy = ProxyHelper({
objectProps: 'your object properties here',
_protected: ['prop1', 'prop2'],
_private: ['prop3'],
_mutable: ['prop4'],
});
/**
* @example ProxyHelper({objectProps..., _protected: array(...)})
* @param {Object} object
* @return {Proxy}
* @usage const proxy = ProxyHelper({objectProps..., _protected: array(...), _private: array(...), _mutable: array(...)})
* @usage _protected: array(...) -> Cannot be modified
* @usage _private: array(...) -> Cannot be accessed
* @usage _mutable: array(...) -> Can be modified
*/
const myObject = {
prop1: 'This is a public property',
prop2: 'This is a protected property',
prop3: 'This is a private property',
};
const proxy = ProxyHelper({
...myObject,
_protected: ['prop2'],
_private: ['prop3'],
});
console.log(proxy.prop1); // Output: "This is a public property"
console.log(proxy.prop2); // Output: Error
console.log(proxy.prop3); // Output: Error
const myObject = {
prop1: 'This is a public property',
prop2: 'This is a protected property',
prop3: 'This is a private property',
};
const proxy = ProxyHelper(myObject);
object: ProxyHelperConfig
An object of type ProxyHelperConfig
. This object can have the following optional fields:
_private?: string[]
: An array of property names that should be made private._protected?: string[]
: An array of property names that should be made protected._mutable?: string[]
: An array of property names that can be modified.[key: string]: any
: Any additional properties.Returns a Proxy object that wraps the original object
and applies the privacy, protection, and mutability rules.
This project is licensed under the MIT License.
FAQs
Convert Object to proxy to protect the objects
The npm package @knighttower/js-object-proxy-helper receives a total of 0 weekly downloads. As such, @knighttower/js-object-proxy-helper popularity was classified as not popular.
We found that @knighttower/js-object-proxy-helper 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
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.