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

fs-minipass

Package Overview
Dependencies
Maintainers
5
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fs-minipass

fs read and write streams based on minipass

  • 3.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
35M
increased by1.28%
Maintainers
5
Weekly downloads
 
Created

What is fs-minipass?

The fs-minipass npm package is a minimalistic implementation of a readable and writable stream for file system operations. It is designed to be lightweight and efficient, making it suitable for scenarios where you need to handle file streams with minimal overhead.

What are fs-minipass's main functionalities?

Reading from a file

This feature allows you to read data from a file using a Minipass stream. The code demonstrates how to create a readable stream from a file and pipe it through a Minipass instance to handle the data chunks.

const fs = require('fs');
const Minipass = require('fs-minipass');

const mp = new Minipass();
const readStream = fs.createReadStream('example.txt');

readStream.pipe(mp).on('data', (chunk) => {
  console.log('Read chunk:', chunk.toString());
});

Writing to a file

This feature allows you to write data to a file using a Minipass stream. The code demonstrates how to create a writable stream to a file and pipe data through a Minipass instance to write to the file.

const fs = require('fs');
const Minipass = require('fs-minipass');

const mp = new Minipass();
const writeStream = fs.createWriteStream('output.txt');

mp.pipe(writeStream);
mp.write('Hello, world!');
mp.end();

Transforming data

This feature allows you to transform data as it passes through a Minipass stream. The code demonstrates how to create a custom transform stream that converts data to uppercase before passing it along.

const Minipass = require('fs-minipass');

class UpperCaseTransform extends Minipass {
  write(chunk) {
    super.write(chunk.toString().toUpperCase());
  }
}

const mp = new UpperCaseTransform();
mp.on('data', (chunk) => {
  console.log('Transformed chunk:', chunk.toString());
});

mp.write('hello');
mp.write('world');
mp.end();

Other packages similar to fs-minipass

FAQs

Package last updated on 14 Aug 2023

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