# accessed

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

Latest version **1.0.0** (published 2019-08-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install accessed
pnpm add accessed
yarn add accessed
bun add accessed
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2019-08-15 |
| First published | 2019-08-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Arnout Kazemier |
| Maintainers | 3rdeden |
| Keywords | prop, get, access, accessed, json, stringify, performance, reduce, used |

## Links

- npm: https://www.npmjs.com/package/accessed
- Repository: https://github.com/3rd-Eden/accessed
- Homepage: https://github.com/3rd-Eden/accessed#readme
- Issues: https://github.com/3rd-Eden/accessed/issues
- npm.io page: https://npm.io/package/accessed

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.0 (latest) — 2019-08-15

## README

# 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

```js
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.

```js
const data = accessed({ foo: 'bar', hello: 'world' }, {
  keys: ['hello']
});

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

### License

[MIT](LICENSE)

---
_Source: https://npm.io/package/accessed · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
