1.0.5 • Published 3 years ago

blue-pencil v1.0.5

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

blue-pencil

Mask your JSON values as of a given array of not allowed fields.

Build Status Coverage Status license David npm

Usage

The main export of this library is BluePencil, a utility that receives a JSON and an array of elements and returns the same JSON with the given elements with asterisks.

Install

You can install blue-pencil using npm.

npm install --save blue-pencil

API

Exported symbols:

Kind: global class

new BluePencil(options)

Example

const bluePencil = require('blue-pencil');
let myBluePencil = new BluePencil({escapeWildcard: '#####'});

blue-pencil.censor(objectToCensor, valuesToHide) ⇒ Object | Array

Returns the given object but with the given values masked.

Type: static method of blue-pencil
Returns: Object The new object with the values masked.

Example

 const bluePencil = require('blue-pencil');

let myBluePencil = new BluePencil({escapeWildcard: '#####'});

const nestedObj = {
  root: [{
    foo: 'bar',
  }],
};

const valuesToHide = ['foo'];

// censor
const filteredObject = myBluePencil.censor(nestedObj, valuesToHide)

License

MIT @ Angel Muelas Martinez