redos-detector
Version:
A CLI and library which tests helps score how vulnerable a regex pattern is to ReDoS attacks. Supported in the browser, Node and Deno.
23 lines (22 loc) • 1.09 kB
TypeScript
import { CharacterReader } from './character-reader-level-0';
export type JoinGetAction = (index: number, emittedSomething: number) => 'continue' | 'fork' | 'stop';
/**
* Join multiple `CharacterReader`'s together.
*
* It has understanding of the `split` type.
*
* `getAction` should return
* - `continue`: This results in `getReader` being called with the next index
* and a new `CharacterReader` should be returned
* - `fork`: This results in the reader splitting, with the split reader being empty,
* and then `getReader` is called with the next index and a new `CharacterReader`
* should be returned
* - `stop`: This means the reader will end
*/
export declare function join(getAction: JoinGetAction, getReader: (index: number) => CharacterReader): CharacterReader;
/**
* Joins an array of `CharacterReader`'s together, with understanding
* of the `split` type. If a reader splits, when the split reader ends,
* the next `CharacterReader` in the array will follow.
*/
export declare function joinArray(input: readonly (() => CharacterReader)[]): CharacterReader;