//#region src/core.d.ts type NativeBinding = { AhoCorasick: new (patterns: string[], options?: Record) => NativeAhoCorasickInstance; StreamMatcher: new (patterns: string[], options?: Record) => NativeStreamMatcherInstance; }; type NativeAhoCorasickInstance = { patternCount: number; isMatch(haystack: string): boolean; _findIterPacked(haystack: string): Uint32Array; _findOverlappingIterPacked(haystack: string): Uint32Array; replaceAll(haystack: string, replacements: string[]): string; _findIterPackedBuf(haystack: Buffer | Uint8Array): Uint32Array; findIterBuf(haystack: Buffer | Uint8Array): ByteMatch[]; isMatchBuf(haystack: Buffer | Uint8Array): boolean; }; type NativeStreamMatcherInstance = { write(chunk: Buffer | Uint8Array): ByteMatch[]; flush(): ByteMatch[]; reset(): void; }; /** Set the native backend. Must be called once * before any class constructor. */ /** * Which match semantics to use. * * - `"leftmost-first"`: report the first pattern * that matches (insertion order) at each position. * - `"leftmost-longest"`: report the longest match * at each position. */ type MatchKind = "leftmost-first" | "leftmost-longest"; /** Options for constructing an automaton. */ type Options = { /** * Match semantics. * @default "leftmost-first" */ matchKind?: MatchKind; /** * Case-insensitive matching (ASCII only). * @default false */ caseInsensitive?: boolean; /** * Force DFA mode. Uses more memory but can be * faster for large pattern sets. * @default false */ dfa?: boolean; /** * Only match whole words. Uses Unicode * `is_alphanumeric()` for boundary detection * by default (covers all scripts). Set * `unicodeBoundaries: false` for ASCII-only. * @default false */ wholeWords?: boolean; /** * Use Unicode word boundaries for `wholeWords`. * When `true` (default), `is_alphanumeric()` is * used (covers all scripts). When `false`, only * `[a-zA-Z0-9_]` are word characters. * @default true */ unicodeBoundaries?: boolean; }; /** A named pattern entry. */ type PatternEntry = string | { pattern: string; name?: string; }; /** A single match result (string methods). */ type Match = { /** Index into the patterns array. */pattern: number; /** Start UTF-16 code unit offset (compatible * with `String.prototype.slice()`). */ start: number; /** End offset (exclusive). */ end: number; /** The matched text * (`haystack.slice(start, end)`). */ text: string; /** Pattern name (if provided). */ name?: string; }; /** * A single match result (Buffer / streaming * methods). Offsets are **byte** positions, not * UTF-16 code units. */ type ByteMatch = { /** Index into the patterns array. */pattern: number; /** Start byte offset. */ start: number; /** End byte offset (exclusive). */ end: number; }; /** * Aho-Corasick automaton for multi-pattern string * searching. * * @throws {Error} If the automaton cannot be built * (e.g. patterns exceed internal size limits). * * @example * ```ts * const ac = new AhoCorasick(["foo", "bar"]); * ac.findIter("foo bar"); * // [ * // { pattern: 0, start: 0, end: 3, * // text: "foo" }, * // { pattern: 1, start: 4, end: 7, * // text: "bar" }, * // ] * ``` */ declare class AhoCorasick { private _inner; private _names; private _jsWholeWords; constructor(patterns: PatternEntry[], options?: Options); /** Number of patterns in the automaton. */ get patternCount(): number; /** Returns `true` if any pattern matches. */ isMatch(haystack: string): boolean; /** Find all non-overlapping matches. */ findIter(haystack: string): Match[]; /** Find all overlapping matches. */ findOverlappingIter(haystack: string): Match[]; /** * Replace all non-overlapping matches. * `replacements[i]` replaces pattern `i`. * * @throws {Error} If `replacements.length` does * not equal `patternCount`. */ replaceAll(haystack: string, replacements: string[]): string; /** * Find matches in a `Buffer` / `Uint8Array`. * Returns **byte offsets** (not UTF-16). */ findIterBuf(haystack: Buffer | Uint8Array): ByteMatch[]; /** * Check whether any pattern matches in a * `Buffer` / `Uint8Array`. */ isMatchBuf(haystack: Buffer | Uint8Array): boolean; } /** * Streaming matcher that handles chunk boundaries. * * @example * ```ts * const sm = new StreamMatcher(["needle"]); * for await (const chunk of stream) { * for (const m of sm.write(chunk)) { * console.log(`Pattern ${m.pattern} at` * + ` byte ${m.start}..${m.end}`); * } * } * sm.flush(); * ``` */ declare class StreamMatcher { private _inner; constructor(patterns: string[], options?: Options); /** Feed a chunk, get matches with global byte * offsets. */ write(chunk: Buffer | Uint8Array): ByteMatch[]; /** Flush remaining state. */ flush(): ByteMatch[]; /** Reset for reuse. */ reset(): void; } //#endregion export { AhoCorasick, type ByteMatch, type Match, type MatchKind, type NativeBinding, type Options, type PatternEntry, StreamMatcher }; //# sourceMappingURL=index.d.mts.map