@darkobits/mask-string
Version:
Mask tokens in a string.
12 lines (11 loc) • 458 B
TypeScript
/**
* Provided a pattern or array of patterns, an input string, and an optional
* mask character, returns a new string modified such that any tokens therein
* matching one of the provided patterns is replaced by a string of mask
* characters of the same length.
*
* @example
*
* mask(/foo/g, 'foo bar') // => '*** bar'
*/
export default function maskString(pattern: string | RegExp | Array<string | RegExp>, str: string, maskChar?: string): string;