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

stream-chopper

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stream-chopper

Chop a single stream of data into a series of readable streams

  • 3.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is stream-chopper?

The stream-chopper npm package is designed to split or 'chop' streams into smaller chunks based on specified criteria, such as time intervals or size limits. This can be particularly useful for logging, data processing, or any scenario where managing large streams in smaller, more manageable pieces is beneficial.

What are stream-chopper's main functionalities?

Chop by Time Interval

This feature allows you to chop a stream into smaller chunks based on a specified time interval. In this example, the stream is chopped every 1000 milliseconds (1 second).

const StreamChopper = require('stream-chopper');
const fs = require('fs');

const chopper = StreamChopper({ interval: 1000 }); // Chop every 1000 milliseconds
const inputStream = fs.createReadStream('largefile.log');

inputStream.pipe(chopper).pipe(fs.createWriteStream('output.log'));

Chop by Size

This feature allows you to chop a stream into smaller chunks based on a specified size limit. In this example, the stream is chopped every 1MB.

const StreamChopper = require('stream-chopper');
const fs = require('fs');

const chopper = StreamChopper({ size: 1024 * 1024 }); // Chop every 1MB
const inputStream = fs.createReadStream('largefile.log');

inputStream.pipe(chopper).pipe(fs.createWriteStream('output.log'));

Custom Chop Conditions

This feature allows you to define custom conditions for chopping the stream. In this example, the stream is chopped whenever the string 'ERROR' is found in the chunk.

const StreamChopper = require('stream-chopper');
const fs = require('fs');

const chopper = StreamChopper({
  custom: (chunk) => chunk.includes('ERROR') // Chop when 'ERROR' is found in the chunk
});
const inputStream = fs.createReadStream('largefile.log');

inputStream.pipe(chopper).pipe(fs.createWriteStream('output.log'));

Other packages similar to stream-chopper

Keywords

FAQs

Package last updated on 08 Nov 2018

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