UNPKG

json-file-merger

Version:

A Node.js package for merging large JSON files using streams

52 lines (51 loc) 1.35 kB
import { Transform } from 'stream'; import { ProgressInfo } from '../types'; /** * A Transform stream that merges multiple JSON files into a single JSON array */ export declare class JsonStreamMerger extends Transform { private isFirstFile; private processedBytes; totalBytes: number; private startTime; private onProgress; private arrayStartWritten; private isInterrupted; private lastChar; private buffer; constructor(options?: { onProgress?: (info: ProgressInfo) => void; }); /** * Process a chunk of data */ _transform(chunk: Buffer, encoding: string, callback: (error?: Error | null) => void): void; /** * Write the opening array bracket if not already written */ private _writeArrayStart; /** * Process a chunk of text data */ private _processChunk; /** * Check if a line should be skipped */ private _shouldSkipLine; /** * Write a line with proper formatting */ private _writeLine; /** * Report progress information */ private _reportProgress; /** * Flush any remaining data */ _flush(callback: (error?: Error | null) => void): void; /** * Handle stream destruction */ _destroy(err: Error | null, callback: (error: Error | null) => void): void; }