blue-pencil

1.0.5 • Public • Published

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)

Create an BluePencils that hide the give keys in a given object.

Param Type Description
options object
options.wildcard string

Wildcard we would like to use for the mask (e.g.: #####)

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.

Param Type Description
objectToCensor Object | Array Input data to be filtered
valuesToHide Array

Elements to mask in the given object

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

Dependencies (2)

Dev Dependencies (8)

Package Sidebar

Install

npm i blue-pencil

Weekly Downloads

0

Version

1.0.5

License

MIT

Unpacked Size

134 kB

Total Files

37

Last publish

Collaborators

  • myolnir