Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

minipass

Package Overview
Dependencies
Maintainers
6
Versions
94
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

minipass

minimal implementation of a PassThrough stream

  • 3.3.3
  • Source
  • npm
  • Socket score

Version published
Maintainers
6
Created

What is minipass?

The minipass npm package is a small, simple stream.PassThrough class. It is designed to be a minimal implementation of a streaming PassThrough, which is a type of Duplex stream that reads from a readable source and writes to a writable destination with minimal overhead. It is useful for cases where you want to collect stream data, transform it, or simply pass it through unmodified.

What are minipass's main functionalities?

Basic Stream Collection

This feature allows you to collect data from a stream. The 'data' event is emitted whenever the stream has data available. The 'write' method is used to send data into the stream, and 'end' is used to signal that no more data will be written.

const MiniPass = require('minipass')
const stream = new MiniPass()
stream.on('data', chunk => {
  console.log('Got some data:', chunk.toString())
})
stream.write('hello')
stream.end('world')

Piping Data

This feature demonstrates how to pipe data from a MiniPass stream to another writable stream. In this example, data is piped to a file stream, which writes the data to 'output.txt'.

const MiniPass = require('minipass')
const fs = require('fs')
const stream = new MiniPass()
const writable = fs.createWriteStream('output.txt')
stream.pipe(writable)
stream.write('hello')
stream.end('world')

Transforming Stream Data

This feature shows how to extend MiniPass to create a custom transform stream. In this example, an Uppercase class is created that converts all incoming data to uppercase before passing it through.

const MiniPass = require('minipass')
class Uppercase extends MiniPass {
  write (chunk, encoding, callback) {
    super.write(chunk.toString().toUpperCase(), encoding, callback)
  }
}
const ucStream = new Uppercase()
ucStream.on('data', chunk => {
  console.log(chunk.toString())
})
ucStream.write('hello')
ucStream.end('world')

Other packages similar to minipass

Keywords

FAQs

Package last updated on 20 Jun 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc