Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

accessed

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

accessed

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

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
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

Package last updated on 15 Aug 2019

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc