UNPKG

redact-object

Version:
22 lines (21 loc) 1.01 kB
export type ReplaceFunction = (value: any, key: string) => string; export interface ConfigOptions { partial?: boolean; strict?: boolean; ignoreUnknown?: boolean; } /** * Parses an object and redacts any keys listed in keywords * * @param target The target object to scan for redactable items * @param keywords A list of members to redact * @param replaceVal Optional custom replace value or function replacer * @param config Optional config * { * partial: boolean, do partial matches, default false * strict: boolean, do strict key matching, default true * ignoreUnknown: boolean, ignore unknown types instead of error, default false * } * @return the new redacted object */ export default function redact(target: any, keywords: string[], replaceVal?: string | ReplaceFunction, config?: ConfigOptions): typeof target;