streaming
Version:
Transforms and other streaming helpers
57 lines (53 loc) • 2.58 kB
TypeScript
import { Transform } from 'stream';
/**
Stringify all written objects into a single proper JSON array,
surrounded by [ and ] delimiters, and separated by commas.
* `replacer` - If a function, transforms values and properties
encountered while stringifying; if an array, specifies the set of
properties included in objects in the final string. Details on
[MDN](https://developer.mozilla.org/En/Using_native_JSON#The_replacer_parameter).
* `space` - Causes the resulting string to be pretty-printed
(by some number of spaces or literal space).
*/
export declare class ArrayStringifier extends Transform {
protected replacer?: any;
protected space?: string | number;
protected _seenFirstItem: boolean;
constructor(replacer?: any, space?: string | number);
_transform(chunk: any, encoding: BufferEncoding, callback: (error?: Error, outputChunk?: any) => void): void;
_flush(callback: (error?: Error) => void): void;
}
/** streaming.json.Stringifer expects objects and outputs strings / buffers
_writableState.objectMode = true
_readableState.objectMode = false
* `replacer` Function If a function, transforms values and properties
encountered while stringifying; if an array, specifies the set of
properties included in objects in the final string. Details on
[MDN](https://developer.mozilla.org/En/Using_native_JSON#The_replacer_parameter).
* `space` Number | String Causes the resulting string to be pretty-printed
(by some number of spaces or literal space).
*/
export declare class Stringifier extends Transform {
protected replacer?: any;
protected space?: string | number;
constructor(replacer?: any, space?: string | number);
_transform(chunk: any, encoding: BufferEncoding, callback: (error?: Error, outputChunk?: any) => void): void;
}
/** streaming.json.Parser expects Buffer input with universal newlines
dividing JSON objects. You shouldn't put a Splitter() in front of it.
*/
export declare class Parser extends Transform {
protected replacer?: any;
protected space?: string | number;
protected _buffer: Buffer;
constructor(replacer?: any, space?: string | number);
_line(lineBuffer: Buffer): void;
/** Find the split points */
_processBuffer(eof: boolean): void;
/**
chunk will be a Buffer, and either one is fine by JSON.parse, but to
appease TypeScript, type assert that it's <any>
*/
_transform(chunk: any, encoding: BufferEncoding, callback: (error?: Error, outputChunk?: any) => void): void;
_flush(callback: (error?: Error) => void): void;
}