When called without any options, or with a zero length `paths` array,
`fast-redact` will return `JSON.stringify` or the `serialize` option, if set.
#### `paths` – `Array`
An array of strings describing the nested location of a key in an object.
The syntax follows that of the EcmaScript specification, that is any JavaScript
path is accepted – both bracket and dot notation is supported. For instance in
each of the following cases, the `c` property will be redacted: `a.b.c`,`a['b'].c`,
`a["b"].c`, `a[``b``].c`. Since bracket notation is supported, array indices are also
supported `a[0].b` would redact the `b` key in the first object of the `a` array.
Leading brackets are also allowed, for instance `["a"].b.c` will work.
##### Wildcards
In addition to static paths, asterisk wildcards are also supported.
When an asterisk is place in the final position it will redact all keys within the
parent object. For instance `a.b.*` will redact all keys in the `b` object. Similarly
for arrays `a.b[*]` will redact all elements of an array (in truth it actually doesn't matter
whether `b` is in an object or array in either case, both notation styles will work).
When an asterisk is in an intermediate or first position, the paths following the asterisk will
be redacted for every object within the parent.
For example:
```js
const fastRedact = require('fast-redact')
const redact = fastRedact({paths: ['*.c.d']})
const obj = {
x: {c: {d: 'hide me', e: 'leave me be'}},
y: {c: {d: 'and me', f: 'I want to live'}},
z: {c: {d: 'and also I', g: 'I want to run in a stream'}}
}
console.log(redact(obj))
// {"x":{"c":{"d":"[REDACTED]","e":"leave me be"}},"y":{"c":{"d":"[REDACTED]","f":"I want to live"}},"z":{"c":{"d":"[REDACTED]","g":"I want to run in a stream"}}}
```
Another example with a nested array:
```js
const fastRedact = require('..')
const redact = fastRedact({paths: ['a[*].c.d']})
const obj = {
a: [
{c: {d: 'hide me', e: 'leave me be'}},
{c: {d: 'and me', f: 'I want to live'}},
{c: {d: 'and also I', g: 'I want to run in a stream'}}
]
}
console.log(redact(obj))
// {"a":[{"c":{"d":"[REDACTED]","e":"leave me be"}},{"c":{"d":"[REDACTED]","f":"I want to live"}},{"c":{"d":"[REDACTED]","g":"I want to run in a stream"}}]}
```
#### `remove` - `Boolean` - `[false]`
The `remove` option, when set to `true` will cause keys to be removed from the
serialized output.
Since the implementation exploits the fact that `undefined` keys are ignored
by `JSON.stringify` the `remove` option may *only* be used when `JSON.stringify`
is the serializer (this is the default) – otherwise `fast-redact` will throw.
If supplying a custom serializer that has the same behavior (removing keys
with `undefined` values), this restriction can be bypassed by explicitly setting
the `censor` to `undefined`.
#### `censor` –`<Any type>` – `('[REDACTED]')`
This is the value which overwrites redacted properties.
Setting `censor` to `undefined` will cause properties to removed as long as this is
the behavior of the `serializer`– which defaults to `JSON.stringify`, which does
remove `undefined` properties.
Setting `censor` to a function will cause `fast-redact` to invoke it with the original
value. The output of the `censor` function sets the redacted value.
Please note that asynchronous functions are not supported.