Redacts values in objects. Useful when sending data to external logging services such as Sentry.
Install the package via npm
:
$ npm install mask-json
collection
(Array): An array of keys to redact.[options]
(Object): An optional object with the following options:
Option | Default value | Description |
---|---|---|
replacement | --REDACTED-- | The default value to replace |
(Function): Returns a function that will redact values from a given object.
var blacklist = ['password', 'secret'];
var maskJson = require('mask-json')(blacklist);
maskJson({ foo: 'bar', biz: { username: 'myusername', password: 'mypassword' } });
// => { foo: 'bar', biz: { username: '--REDACTED--', password: '--REDACTED--' } }
$ npm test
MIT