index.d.ts 944 B

12345678910111213141516171819202122
  1. /// <reference types="node" />
  2. /// <reference types="node" />
  3. /// <reference types="node" />
  4. import { Transform, TransformCallback, TransformOptions } from 'stream';
  5. export interface RegexParserOptions extends TransformOptions {
  6. /** The regular expression to use to split incoming text */
  7. regex: RegExp | string | Buffer;
  8. /** Defaults to utf8 */
  9. encoding?: BufferEncoding;
  10. }
  11. /**
  12. * A transform stream that uses a regular expression to split the incoming text upon.
  13. *
  14. * To use the `Regex` parser provide a regular expression to split the incoming text upon. Data is emitted as string controllable by the `encoding` option (defaults to `utf8`).
  15. */
  16. export declare class RegexParser extends Transform {
  17. regex: RegExp;
  18. data: string;
  19. constructor({ regex, ...options }: RegexParserOptions);
  20. _transform(chunk: string, encoding: BufferEncoding, cb: TransformCallback): void;
  21. _flush(cb: TransformCallback): void;
  22. }