šŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.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
Version published
Weekly downloads
40M
3.35%
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