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

streamx

Package Overview
Dependencies
Maintainers
1
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

streamx

An iteration of the Node.js core streams with a series of improvements

  • 2.16.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8.2M
decreased by-5.1%
Maintainers
1
Weekly downloads
 
Created

What is streamx?

The streamx npm package provides a modern, lightweight, and highly performant stream implementation for Node.js. It is designed to be a drop-in replacement for the native Node.js streams with improved performance and consistency. It offers a simpler API and better error handling, and it is compatible with both modern and legacy Node.js versions.

What are streamx's main functionalities?

Creating a Readable Stream

This code sample demonstrates how to create a readable stream using streamx that pushes a 'Hello, World!' message and then ends the stream.

const { Readable } = require('streamx');

const readable = new Readable({
  read(cb) {
    this.push('Hello, World!');
    this.push(null); // End the stream
    cb();
  }
});

readable.on('data', (chunk) => {
  console.log(chunk.toString());
});

Creating a Writable Stream

This code sample shows how to create a writable stream using streamx that writes data to the standard output (stdout).

const { Writable } = require('streamx');

const writable = new Writable({
  write(data, cb) {
    process.stdout.write(data);
    cb();
  }
});

writable.write('Hello, World!', () => {
  console.log('\nWrite completed');
});

Creating a Transform Stream

This code sample illustrates how to create a transform stream using streamx that converts all incoming data to uppercase and then pipes it to the standard output.

const { Transform } = require('streamx');

const transform = new Transform({
  transform(data, cb) {
    this.push(data.toString().toUpperCase());
    cb();
  }
});

process.stdin.pipe(transform).pipe(process.stdout);

Piping Streams

This code sample demonstrates how to pipe data from a readable stream to a writable stream using streamx.

const { Readable, Writable } = require('streamx');

const readable = new Readable({
  read(cb) {
    this.push('Hello, World!');
    this.push(null); // End the stream
    cb();
  }
});

const writable = new Writable({
  write(data, cb) {
    process.stdout.write(data);
    cb();
  }
});

readable.pipe(writable);

Other packages similar to streamx

FAQs

Package last updated on 17 Feb 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