stream-accelerator
v0.1.4
Published
Node stream with in-memory buffering
Downloads
3
Readme
Stream Accelerator
Node stream with in-memory buffering of text content.
If stream is fragmented to many small chunks, the write operation is slow. Buffering decreases number of IO operations, and so can dramatically increase the write throughput.
The stream-accelerator is a Transform stream and uses Node Buffer for temporary in-memory buffer that "defragments" the stream. No dependencies to external libraries.
The buffer has static up-front static memory allocation by stream-accelerator instantiation to achieve the best performance. Buffer size is not changed during the whole lifetime.
Quick Start
Install stream-accelerator
npm install --save stream-accelerator
Import the library in JavaScript code
const accelerate = require('stream-accelerator');
Use the stream accelerator for buffering before write operation or before calling OS commands with pipe stream.
In the example code the buffering minimizes the number of IO operations and speeds up writing.
The static buffer size of stream-accelerator expects 2 configuration parameters (in bytes): buffer total size, and reserve = maximum size of a chunk that is written into the buffer.
License
stream-accelerator is free and unencumbered public domain software. For more information, see the accompanying UNLICENSE file.