foxts
Version:
Opinionated collection of common TypeScript utils by @SukkaW
21 lines (19 loc) • 633 B
TypeScript
interface TextLineStreamOptions {
/** Allow splitting by solo \r */
allowCR?: boolean;
skipEmptyLines?: boolean;
}
/** Transform a stream into a stream where each chunk is divided by a newline,
* be it `\n` or `\r\n`. `\r` can be enabled via the `allowCR` option.
*
* ```ts
* const res = await fetch('https://example.com');
* const lines = res.body!
* .pipeThrough(new TextDecoderStream())
* .pipeThrough(new TextLineStream());
* ```
*/
declare class TextLineStream extends TransformStream<string, string> {
constructor({ allowCR, skipEmptyLines }?: TextLineStreamOptions);
}
export { TextLineStream };