Socket
Socket
Sign inDemoInstall

accessed

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    accessed

Only JSON.stringify the properties that we're accessed on the object.


Version published
Weekly downloads
6
increased by500%
Maintainers
1
Install size
4.48 kB
Created
Weekly downloads
 

Readme

Source

accessed

Accessed is a simple module that allows you to track property access of a given object to ensure that only the data that is used (or not used) is included when you JSON.stringify the data.

Install

The module is published in the public npm registry and can be installed by running:

npm install --save accessed

Usage

const accessed = require('accessed');

const data = accessed({
  foo: 'bar',
  bar: 'wat',
  key: 'value'
});

console.log(data.foo);
console.log(JSON.stringify(data)); // {"foo":"bar"}

console.log(data.bar);
console.log(JSON.stringify(data)); // {"foo":"bar", "bar": "wat"}

The module exposes the accessed function as default export. The function accepts 2 arguments.

  • data The object that needs to be tracked.
  • options Additional configuration
    • keys An array of keys that should be included, even when they are not accessed by the code.
    • exclude Instead of returning an object on JSON.stringify that represents the keys that were accessed, return the data that was not accesed.
const data = accessed({ foo: 'bar', hello: 'world' }, {
  keys: ['hello']
});

console.log(JSON.stringify(data)); // {"hello":"world"}

License

MIT

Keywords

FAQs

Last updated on 15 Aug 2019

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc