fs-capacitor2.0.1 • Public • Published
FS Capacitor is a filesystem buffer for finite node streams. It supports simultaneous read/write, and can be used to create multiple independent readable streams, each starting at the beginning of the buffer.
This is useful for file uploads and other situations where you want to avoid delays to the source stream, but have slow downstream transformations to apply:
It is especially important to use cases like
graphql-upload where server code may need to stash earler parts of a stream until later parts have been processed, and needs to attach multiple consumers at different times.
FS Capacitor creates its temporary files in the directory ideneified by
os.tmpdir() and attempts to remove them:
readStream.destroy()has been called and all read streams are fully consumed or destroyed
- before the process exits
Please do note that FS Capacitor does NOT release disk space as data is consumed, and therefore is not suitable for use with infinite streams or those larger than the filesystem.
WriteStream inherets all the methods of
Create a new
Create a new
ReadStream instance attached to the
WriteStream is fully destroyed, calling
.createReadStream() will throw a
As soon as a
ReadStream ends or is closed (such as by calling
readStream.destroy()), it is detached from its
.destroy(error?: ?Error): void
WriteStreams still attached are destroyed with the same error.
erroris null or undefined, destruction of underlying resources is delayed until no
ReadStreams are attached the
ReadStream inherets all the methods of