/** * Constructor options for Filter class. * * @property {boolean} emptyList - Instantiate filter with no blocklist * @property {array} list - Instantiate filter with custom list * @property {string} placeHolder - Character used to replace profane words. * @property {string} regex - Regular expression used to sanitize words before comparing them to blocklist. * @property {string} replaceRegex - Regular expression used to replace profane words with placeHolder. * @property {string} splitRegex - Regular expression used to split a string into words. */ export interface FilterOptions { emptyList?: boolean; list?: string[]; exclude?: string[]; placeHolder?: string; regex?: RegExp; replaceRegex?: RegExp; splitRegex?: RegExp; } /** * Local list of profane words. * * @property {array} words - List of profane words. */ export type LocalList = { words: string[]; }; /** * Profanity Filter class. * @public */ export declare class Filter { /** * List of words to filter. * @type {array} list - List of words to filter. */ list: string[]; /** * List of words to exclude from filter. * @type {array} exclude - List of words to exclude from filter. */ exclude: string[]; /** * Character used to replace profane words. * @type {string} placeHolder - Character used to replace profane words. */ placeHolder: string; /** * Regular expression used to sanitize words before comparing them to blocklist. * @type {string} regex - Regular expression used to sanitize words before comparing them to blocklist. */ regex: RegExp; /** * Regular expression used to replace profane words with placeHolder. * @type {string} replaceRegex - Regular expression used to replace profane words with placeHolder. */ replaceRegex: RegExp; /** * Regular expression used to split a string into words. * @type {string} splitRegex - Regular expression used to split a string into words. */ splitRegex: RegExp; /** * Filter constructor. * * @param {FilterOptions} options - Constructor options for Filter class. */ constructor(options?: FilterOptions); /** * Determine if a string contains profane language. * @param {string} string - String to evaluate for profanity. */ isProfane(string: string): boolean; /** * Replace a word with placeHolder characters; * @param {string} string - String to replace. */ replaceWord(string: string): string; /** * Evaluate a string for profanity and return an edited version. * @param {string} input - String to filter. */ clean(input: string): string; /** * Add word(s) to blocklist filter / remove words from whitelist filter * @param {...string} words - Word(s) to add to blocklist */ addWords(...words: string[]): void; /** * Add words to allowlist filter * @param {...string} words - Word(s) to add to allowlist. */ removeWords(...words: string[]): void; }