mask-json

1.0.3 • Public • Published

mask-json

Redacts values in objects. Useful when sending data to external logging services such as Sentry.

Status

npm version npm downloads build status

Installation

Install the package via npm:

$ npm install mask-json

Usage

Arguments

  1. collection (Array): An array of keys to redact.
  2. [options] (Object): An optional object with the following options:
Option Default value Description
ignoreCase false Whether to ignore case sensitivity when matching keys
replacement --REDACTED-- The default value to replace

Returns

(Function): Returns a function that will redact values from a given object.

Example

var blacklist = ['password', 'username'];
var maskJson = require('mask-json')(blacklist);
 
maskJson({ foo: 'bar', biz: { username: 'myusername', password: 'mypassword' } });
 
// => { foo: 'bar', biz: { username: '--REDACTED--', password: '--REDACTED--' } }

Tests

$ npm test

Release

npm version [<new version> | major | minor | patch] -m "Release %s"

License

MIT

Package Sidebar

Install

npm i mask-json

Weekly Downloads

10,495

Version

1.0.3

License

SEE LICENSE IN LICENSE

Unpacked Size

8.27 kB

Total Files

8

Last publish

Collaborators

  • nunofgs