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

concat-stream

Package Overview
Dependencies
Maintainers
2
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

concat-stream

writable stream that concatenates strings or binary data and calls a callback with the result

  • 1.6.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
19M
decreased by-8.79%
Maintainers
2
Weekly downloads
 
Created

What is concat-stream?

The concat-stream npm package is a writable stream that concatenates data and calls a callback with the result. It can be used to collect stream data and concatenate it into a single buffer, string, or array. It is useful for collecting stream data from sources like HTTP requests, file reads, and other stream sources.

What are concat-stream's main functionalities?

Concatenate stream data into a buffer

This code sample demonstrates how to use concat-stream to read data from a file and concatenate it into a buffer. The buffer is then converted to a string and logged to the console.

const concat = require('concat-stream');
const fs = require('fs');

const readStream = fs.createReadStream('file.txt');
const concatStream = concat(function(buffer) {
  console.log(buffer.toString());
});

readStream.pipe(concatStream);

Concatenate stream data into a string

This code sample shows how to use concat-stream to collect HTTP response data and concatenate it into a string. The string is then logged to the console.

const concat = require('concat-stream');
const http = require('http');

http.get('http://example.com', function(response) {
  response.pipe(concat(function(data) {
    console.log(data.toString());
  }));
});

Concatenate stream data into an array

This example demonstrates how to use concat-stream to collect data from a readable stream and concatenate it into an array. The resulting array is then logged to the console.

const concat = require('concat-stream');
const { Readable } = require('stream');

const arrayStream = Readable.from(['hello', ' ', 'world']);
const concatStream = concat({ encoding: 'array' }, function(array) {
  console.log(array);
});

arrayStream.pipe(concatStream);

Other packages similar to concat-stream

FAQs

Package last updated on 21 Mar 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