UNPKG

node-profanity-filter

Version:

A Node.js profanity filter with support for exact matching, obfuscated word detection, and customizable replacement.

34 lines (33 loc) 1.03 kB
import { AhoCorasick, Match } from './aho-corasick.js'; export interface FilterOptions { words?: string[]; wordBoundaries?: boolean; normalize?: boolean; replaceWith?: string; strict?: boolean; } interface QueryOptions { normalize?: boolean; replaceWith?: string; strict?: boolean; } export declare class Filter { readonly matcher: AhoCorasick; readonly wordBoundaries: boolean; readonly normalize: boolean; readonly replaceWith: string; readonly strict: boolean; private static readonly charMap; constructor({ words, wordBoundaries, normalize, replaceWith, strict }?: FilterOptions); sanitize(input: string, strict?: boolean): string; search(input: string, options?: QueryOptions): Match[]; isProfane(input: string, options?: QueryOptions): boolean; replace(input: string, options?: QueryOptions): { text: string; matches: Match[]; }; private _normalizeToMap; private resolveMatches; private isBoundary; } export {};