UNPKG

@jsonlines/core

Version:

parse and stringify jsonlines files through streams

20 lines (19 loc) 739 B
/// <reference types="node" /> import { Transform, TransformCallback } from "stream"; import { LineSepOption } from "./util/line-sep"; export declare type LineParser<V> = (line: string) => V | Promise<V>; export interface ReadLineStreamOptions<V = string> { lineSep?: LineSepOption; encoding?: BufferEncoding; parse?: LineParser<V>; } export declare class ReadLineStream<V = string> extends Transform { #private; constructor(options?: ReadLineStreamOptions<V>); private _emitLines; private _writeStrAsync; private _writeChunkAsync; _transform(chunk: Buffer | string, encoding: BufferEncoding, callback: TransformCallback): void; private _flushAsync; _flush(callback: TransformCallback): void; }