0.0.1 • Published 4 years ago

json-shape v0.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

json-shape

Tiny JSON util that deeply overwrites values with metadata. 250 bytes gzipped.

Install

npm i json-shape --save

What is this?

When reporting errors, it's sometimes useful to send along data associated with the broken UI, HTTP request, or acting user. To avoid revealing Personal Identifying Information (PII), you need to redact certain values. Or, instead of keeping track of which values are PII and which aren't, you could just redact all values, returning metadata about the value that can then be used to debug.

Usage

Here's an example from the tests:

import redact from "redact";

const o = shape({
  a: {
    b: 'b',
    c: [
      '',
      {
        b: 1,
      }
    ]
  }
});

t.deepEqual(o, {
  a: {
    b: ['string', { length: 1, truthy: true }],
    c: [
      ['string', { length: 0, truthy: false }],
      {
        b: ['number', { truthy: true }]
      }
    ]
  }
});

License

MIT License © Truework