createMasker
Factory function that returns a configured masker instance.
Usage
import { createMasker } from '@pii-mask/core';
const masker = createMasker({
mode: 'mask',
disable: ['person-name'],
});Options
| Option | Type | Default | Description |
|---|---|---|---|
mode | MaskMode | 'mask' | Masking mode to use |
disable | string[] | [] | Detector IDs to disable |
only | string[] | undefined | Run only these detectors |
extend | PIIDetector[] | [] | Additional custom detectors |
keyNameOnly | boolean | false | Skip regex detection, use key heuristics only |
Return value
The returned masker exposes four methods:
maskString(input, key?)— mask a single string valuemaskObject(input)— deep-walk an object and mask all string valuesmaskArray(input)— deep-walk an array and mask all string valuesrestore(masked, tokenMap)— reverse tokenization
Each masking method returns a MaskResult:
interface MaskResult {
result: string;
tokenMap: Record<string, string>;
detections: string[];
}