jsonarrayfs
Version:
Specialized Node.js library for memory-efficient operations on JSON arrays. Stream individual elements from large JSON arrays (files, network responses etc.) and append elements to array files without loading the entire array into memory. Perfect for proc
29 lines (25 loc) • 968 B
text/typescript
import { Transform, TransformCallback } from 'node:stream';
declare class JsonArrayStream<T> extends Transform {
/**
* Special value to distinguish between JSON null and stream EOF.
* Use this to check if a streamed element is null:
*
* ```typescript
* if (element === JsonArrayStream.NULL) {
* console.log('Found null in JSON');
* }
* ```
*/
static readonly NULL: unique symbol;
private state;
constructor(sourceEncoding?: BufferEncoding);
private resetParser;
private parseElement;
private parseStringElement;
private parsePrimitiveElement;
private parseContainerElement;
_transform(chunk: Buffer, encoding: BufferEncoding, callback: TransformCallback): void;
_flush(callback: TransformCallback): void;
}
declare const appendToJsonArrayFile: (filePath: string, encoding: BufferEncoding, ...data: any[]) => Promise<void>;
export { JsonArrayStream, appendToJsonArrayFile };