Node stream storage
Simple duplex streams for cache large data in memory and files.
Installing
npm install stream-storage
Usage
import { StreamStorage } from 'stream-storage';
const streamStorage = new StreamStorage();
streamStorage.clear();
stream-storage
StreamStorage extends the standard stream.Duplex interface. All writes data to this stream will accumulate in internal Buffers. Data exceeding the maxMemorySize of the size will be saved to a file.
You can change default options:
const streamStorage = new StreamStorage({
maxMemorySize: (32 * 1024),
tmpDir: '.',
pushMsec: 1,
chunkSize: (8 * 1024),
});
For rereading data you can move current stream to new by StreamStorage.move()
.
More using cases and examples you can see in test.
Contributors
Thanks to the node-stream-buffer for inspiration!
dev
test
For run test:
npm run test
versions
- 0.0.1 - init
- 0.0.2
- 0.0.3
- 0.0.4
- 0.0.5 - fix pause
- 1.0.0 - .mjs, impl StreamStorage.move()