fs-minipass
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
minipass | 3.3.6 | 14.98 kB | ISC | prod |
Fs-minipass is a package that provides file system streams based on minipass. It exports four classes namely ReadStream, ReadStreamSync, WriteStream, and WriteStreamSync. For synchronous streams like ReadStreamSync and WriteStreamSync, all of the data is available immediately upon consuming the stream. For ReadStreamSync, nothing is stored in memory when the stream is constructed, it reads the entire file and returns the contents. While WriteStreamSync flushes every write to the file synchronously. The asynchronous versions introduce significantly less Stream machinery overhead, working much like their node built-in counterparts.
The usage of fs-minipass is relatively simple, it works like streams where you can pipe them, read() them, or write() to them. Here is an example of how to use it in your JavaScript code:
const fsm = require('fs-minipass')
const readStream = new fsm.ReadStream('file.txt')
const writeStream = new fsm.WriteStream('output.txt')
writeStream.write('some file header or whatever\n')
readStream.pipe(writeStream)
In this example, we require the fs-minipass module, create a new ReadStream for the targeted file ('file.txt'), and a new WriteStream for the output file ('output.txt'). Then, write some data into the writeStream using the write method, and pipe the readStream into the writeStream using the pipe() method.
The complete documentation for fs-minipass can be found in its package readme content or at its official repository: git+https://github.com/npm/fs-minipass.git. The documentation includes the description of all four classes exported, as well as a detailed explanation of all the options available in both ReadStream and WriteStream, complete with instructions on how to use them in your code.