Package Exports
- rdct
- rdct/dist/rdct.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (rdct) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
redact( obj [, options] ) 
Deeply redact all the things
Installation
npm install --save rdct
Usage
redact(object)
import redact from 'rdct';
let obj = {
nested: {
arr: ['with', 'strings', 'in', 'the', 'array'],
mixed: ['with', false, ['and', 'deeply', 'nested', {stuff: 2}]],
num: -17772.11,
str: 'some long string',
blank: null,
missing: void 0,
regex: /test/i,
func: () => {}
}
};
console.log(redact(obj, {includeType: true, min: 3}));
// {
// nested: {
// arr: [
// 'w**h [String]',
// 's*****s [String]',
// '*** [String]',
// 't*e [String]',
// 'a***y [String]'
// ],
// mixed: [
// 'w**h [String]',
// '******* [Boolean]',
// [
// 'a*d [String]',
// 'd****y [String]',
// 'n****d [String]',
// {
// stuff: '*** [Number]'
// }
// ]
// ],
// num: '-1****.*1 [Number]',
// str: 's**************g [String]',
// blank: null
// }
// }
Options
includeType
redact('lorem ipsum', {includeType: true}) // l*********m [String]
redact(123.4222, {includeType: true}) // 1**.***2 [Number]
redact(false, {includeType: true}) // ******* [Boolean]char
redact('lorem ipsum', {char: '?'}) // l?????????m
redact(123.4222, {char: '^'}) // 1^^.^^^2
redact(false, {char: '!'}) // !!!!!!!min
redact('lorem ipsum', {min: 15}) // ***************
redact(123, {min: 3}) // 1*3
redact(true, {min: 2}) // ******* (Boolean disallows `min` less than 7)