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

@rushstack/stream-collator

Package Overview
Dependencies
Maintainers
3
Versions
396
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rushstack/stream-collator

Display intelligible realtime output from concurrent processes

  • 4.1.78
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
281K
decreased by-0.91%
Maintainers
3
Weekly downloads
 
Created

What is @rushstack/stream-collator?

@rushstack/stream-collator is a Node.js library that allows you to manage and collate multiple streams of output, ensuring that the output from different streams is properly interleaved and displayed in a coherent manner. This is particularly useful for managing the output of concurrent processes, such as build tools or test runners.

What are @rushstack/stream-collator's main functionalities?

Collating Multiple Streams

This feature allows you to register multiple streams and collate their output. The collator ensures that the output from different streams is properly interleaved and displayed in a coherent manner.

const { StreamCollator } = require('@rushstack/stream-collator');

const collator = new StreamCollator();

const stream1 = collator.registerStream('stream1');
const stream2 = collator.registerStream('stream2');

stream1.write('Output from stream 1\n');
stream2.write('Output from stream 2\n');

stream1.end();
stream2.end();

collator.on('data', (data) => {
  process.stdout.write(data);
});

Handling Stream Completion

This feature allows you to handle the completion of all registered streams. The 'end' event is emitted when all streams have finished writing.

const { StreamCollator } = require('@rushstack/stream-collator');

const collator = new StreamCollator();

const stream1 = collator.registerStream('stream1');
const stream2 = collator.registerStream('stream2');

stream1.write('Output from stream 1\n');
stream2.write('Output from stream 2\n');

stream1.end();
stream2.end();

collator.on('end', () => {
  console.log('All streams have completed');
});

Error Handling

This feature allows you to handle errors from any of the registered streams. The 'error' event is emitted when an error occurs in any of the streams.

const { StreamCollator } = require('@rushstack/stream-collator');

const collator = new StreamCollator();

const stream1 = collator.registerStream('stream1');
const stream2 = collator.registerStream('stream2');

stream1.write('Output from stream 1\n');
stream2.write('Output from stream 2\n');

stream1.emit('error', new Error('Stream 1 error'));

collator.on('error', (err) => {
  console.error('Error:', err.message);
});

Other packages similar to @rushstack/stream-collator

FAQs

Package last updated on 09 Dec 2024

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