minipass
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
Minipass is a lightweight Node.js library that provides a very minimal implementation of a PassThrough stream. It's optimized for performance, handling objects, strings, and buffers quite effectively. The central function of Minipass is to pass data right through – it does not perform any transformation of the data. Minipass supports standard stream operations such as pipe()
, buffering data until a data
event handler or pipe()
is added, and the transmission of backpressure. It also includes an efficient read()
method, though it's typically more efficient to consume data from this stream via 'data'
events or by calling pipe()
into another stream.
To use Minipass, you'll need to incorporate it into your Node.js code after installing the package from npm. Here's a simple code snippet showcasing basic usage.
import { Minipass } from 'minipass';
const mp = new Minipass(); // Creates a new instance of Minipass.
mp.write('foo'); // Write data into the stream.
mp.pipe(someOtherStream); // Pipe that data into another stream.
mp.end('bar'); // Signal that you have no more data to write.
You can also extend the base Minipass class to implement more complex use-cases such as customized write methods, error handling, or data transformation. Minipass provides a variety of other methods, properties, and options for controlling stream behavior, including setting encoding, working in object mode, and controlling data emission.
You can find Minipass documentation within the readme
file at its GitHub repository, https://github.com/isaacs/minipass. This file provides detailed information on Minipass usage, including TypeScript usage, the differences from Node.js streams, and a comprehensive documentation of the API. This includes methods, options, event types, and even examples of different ways to use and extend the Minipass class.