UNPKG

text-stream-search

Version:

Searches for occurrences of a given search term in Node.js text streams

25 lines (24 loc) 1.15 kB
import { TextAccumulator } from "../text-accumulator.js"; import { RejectFunction } from "../types/reject-function.js"; import { ResolveFunction } from "../types/resolve-function.js"; import { Search } from "../types/search.js"; /** * RegexSearch looks for the given regex in the text stream. */ export declare class RegexSearch implements Search { /** the resolve function to call when the searchText is found */ resolve: ResolveFunction; /** the reject function to call when the search expires */ reject: RejectFunction; /** time after which this search expires and should be aborted, in milliseconds */ timeoutDuration?: number; /** the stream content that has accumulated so far */ text: TextAccumulator; /** the regular expression to look for in the stream text */ searchRegexp: RegExp; constructor(regex: RegExp, resolve: ResolveFunction, reject: RejectFunction, text: TextAccumulator, timeoutDuration?: number); /** Scan checks the stream text for occurrences of the searchRegexp. */ scan(): void; /** OnTimeOut is called after this subscription times out. */ private onTimeout; }