/// /// /// import stream from "stream"; type Encoding = BufferEncoding | "buffer"; type ChunkData = Buffer | string; type Chunk = { chunk: ChunkData; encoding: Encoding; }; type Callback = (error?: Error) => void; /** * This streams accumulate chunks data into a buffer until the amount of data is equal or exceed the buffer size. * Then, it emits a single chunk with the accumulated data. * * This stream is useful when you want to reduce the amount of chunk produced by a stream. * This can helps reducing the number of syscall made by the stream consumer. */ export declare class BufferedPassThrough extends stream.Duplex { private bufferSize; private buffer; private offset; constructor(options?: stream.DuplexOptions); /** * Writes a string or buffer to the internal buffer starting at the internal buffer offset. * Data will be copied from the given start to the end position. * * @param data * @param start Where to start copying/writing data from * @param end Where to end copying/writing data from * @param encoding Type of encoding to use * @returns How many bytes have been copied / written to the internal buffer. */ private writeToBuffer; private writeChunks; /** * Writes a chunk of data to the internal buffer. * If the internal buffer is full, it will be pushed to the stream. * @param chunk * @param encoding */ private writeChunkData; /** * @override from stream.Duplex * Internal method called when data needs to be written. * @param chunkData * @param encoding * @param callback */ _write(chunkData: ChunkData, encoding: Encoding, callback: Callback): void; /** * @override from stream.Duplex * Internal method called when multiple chunks were stored and needs to be written. * @param chunks * @param callback */ _writev(chunks: Chunk[], callback: Callback): void; /** * @override from stream.Duplex * Internal method called when the stream is drained, to resume pushing data. * @param size */ _read(): void; /** * @override from stream.Duplex * Internal method called when the stream is ended. * @param callback */ _final(callback: Callback): void; /** * @override from stream.Duplex * Internal method called when stream is destroyed. * @param err * @param callback */ _destroy(err: Error, callback: Callback): void; } export {};