(u: unknown): unknownReturns a redacted value if it implements Redactable, otherwise returns it unchanged.
When to use
Use as the general-purpose entry point for redaction when the input may or may not implement the redaction protocol.
Details
This function calls isRedactable and, when it returns true,
delegates to getRedacted.
Gotchas
Redaction is not recursive. Nested redactable values inside the returned object are not automatically redacted.
export function function redact(u: unknown): unknownReturns a redacted value if it implements
Redactable
, otherwise returns it
unchanged.
When to use
Use as the general-purpose entry point for redaction when the input may
or may not implement the redaction protocol.
Details
This function calls
isRedactable
and, when it returns true,
delegates to
getRedacted
.
Gotchas
Redaction is not recursive. Nested redactable values inside the returned
object are not automatically redacted.
redact(u: unknownu: unknown): unknown {
if (const isRedactable: (
u: unknown
) => u is Redactable
Type guard that checks whether a value implements the
Redactable
interface.
When to use
Use to narrow an unknown value before calling redaction-specific helpers.
isRedactable(u: unknownu)) return function getRedacted(
redactable: Redactable
): unknown
Returns the result of calling [symbolRedactable] on a value that is
already known to be
Redactable
.
When to use
Use when you need to read the redacted representation from a value already
verified as Redactable.
Details
This function reads the current fiber's Context from the global fiber
reference and passes it to the redaction method.
Gotchas
If no fiber is active, an empty Context is passed to the redaction method.
getRedacted(u: Redactableu)
return u: unknownu
}