Constructor
new Redactor(patternsopt)
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
patterns |
Array:.<string:> |
<optional> |
Redaction patterns from |
- Source:
Members
applied :boolean
True once a value has actually been withheld. A trace that declares rules but never matched one is not a redacted trace.
Type:
- boolean
- Source:
isEmpty
Whether this redactor has any rules at all. Hot paths check this first, so an unconfigured recorder pays nothing for the feature.
- Source:
matchedPaths :Set:.<string:>
Type:
- Source:
matchers :Array:.<RegExp:>
Type:
- Source:
patterns :Array:.<string:>
The patterns as written, kept so an exported trace can declare what was withheld from it.
Type:
- Source:
withheldValues :Set:.<string:>
String values a rule actually withheld.
Kept so the same value can be scrubbed out of recorded source text. A trace records the verbatim body of every action it ran — that is what lets it name the code responsible — and an action with a literal in it would otherwise carry a value the path rules just withheld. These are values already resident in the application's own memory; nothing new is retained, and the set dies with the recorder.
Type:
- Source:
Methods
add(pattern) → {Redactor}
Registers an additional pattern.
Parameters:
| Name | Type | Description |
|---|---|---|
pattern |
string | The pattern source. |
- Source:
Returns:
This redactor, for chaining.
- Type
- Redactor
guard(path, value) → {any}
Returns the value to record for a path: the value itself, or the redaction placeholder when a rule matched.
Parameters:
| Name | Type | Description |
|---|---|---|
path |
string | The property path the value sits at. |
value |
any | The candidate value. |
- Source:
Returns:
What may be recorded.
- Type
- any
markApplied(path, valueopt)
Notes that a rule fired for a path.
Separate from Redactor#matches because capture cannot detect a
redaction by comparing values: NaN !== NaN would make every NaN look
like a withheld value.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
path |
string | The path a rule matched. |
|
value |
any |
<optional> |
The withheld value, remembered so it can also be scrubbed out of recorded source text. |
- Source:
matches(path) → {boolean}
Whether a property path must be withheld.
Parameters:
| Name | Type | Description |
|---|---|---|
path |
string | A dotted property path, e.g. |
- Source:
Returns:
- Type
- boolean
scrub(text) → {string}
Removes any withheld value from a piece of recorded source text.
Applied when a trace is serialized rather than when a node is recorded: an action's source is captured before its writes run, so the value it contains is not yet known to be a secret at that point.
Parameters:
| Name | Type | Description |
|---|---|---|
text |
string | Recorded source text. |
- Source:
Returns:
The text, with withheld values replaced.
- Type
- string