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

through

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

through

simplified stream contruction

  • 2.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
35M
increased by10.19%
Maintainers
1
Weekly downloads
 
Created

What is through?

The 'through' npm package is a simple wrapper around Node.js streams.Transform to create readable/writable streams easily using simple functions for the 'write' and 'end' parts of a stream. It is often used to transform or manipulate data in a stream.

What are through's main functionalities?

Stream Transformation

This code sample demonstrates how to create a simple stream transformation that converts all incoming data to uppercase. The 'write' function is called for every chunk of data, and 'end' is called when there is no more data.

var through = require('through');
var tr = through(function write(data) {
  this.queue(data.toString().toUpperCase());
}, function end() { // optional
  this.queue(null);
});
process.stdin.pipe(tr).pipe(process.stdout);

Stream Filtering

This code sample shows how to filter the stream to only pass through data chunks longer than 10 characters. It uses the 'write' function to decide whether to pass the data along or not.

var through = require('through');
var tr = through(function write(data) {
  if (data.length > 10) {
    this.queue(data);
  }
});
process.stdin.pipe(tr).pipe(process.stdout);

Other packages similar to through

Keywords

FAQs

Package last updated on 28 Nov 2012

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