Questions tagged [node.js-stream]

A stream is an abstract interface for working with streaming data in Node.js. The stream module provides a base API that makes it easy to build objects that implement the stream interface.

There are many stream objects provided by Node.js. For instance, a request to an HTTP server and process.stdout are both stream instances.

Streams can be readable, writable, or both. All streams are instances of EventEmitter.

The stream module can be accessed using:

const stream = require('stream');

There are four fundamental stream types within Node.js:

  • Readable - streams from which data can be read (for example fs.createReadStream()).
  • Writable - streams to which data can be written (for example fs.createWriteStream()).
  • Duplex - streams that are both Readable and Writable (for example net.Socket).
  • Transform - Duplex streams that can modify or transform the data as it is written and read (for example zlib.createDeflate()).
205 questions
0
votes
1 answer

Synchronous Emitted Events With csv-parser

I'm trying to use the npm package csv-parser for parsing my csv files and have run into an issue with the order of events occurring. Events are emitted in this order 'headers': Want to insert metadata about the csv into a database and return an…
Daniel
  • 1,364
  • 1
  • 19
  • 34
0
votes
1 answer

Meteor and Azure Blob storage

I am looking for a way to uploading files to Azure Blob Storage. I found azure-storage npm package. But I'm having a problem with 'createBlockBlobFromStream' method. I dont know how create stream from Uint8Array. xhr.onload = function (e) { …
0
votes
1 answer

HTML video tag content as video stream to MPV player - node.js

I have a little node.js application. On it, I have a video tag that get its content from a canvas (via the captureStream()-method). Now I'd like to somehow send this video stream to a MPV player (on the same device) to play it as a real live…
nameless
  • 1,483
  • 5
  • 32
  • 78
0
votes
1 answer

Node.js Stream on Typescript: supplied parameters do not match any signature of call target

In typescript I was trying to implement custom transform stream. But it was giving me typescript error supplied parameters do not match any signature of call target when I call super contructor with options. var Transform =…
0
votes
1 answer

Node.js: how to save uploaded file from browser form?

What is the best way to save uploaded to node.js files without express?
Dmytro Nalyvaiko
  • 1,664
  • 4
  • 16
  • 27
0
votes
1 answer

How to use CLI application from node.js child process?

I am wordering how to use application with command line interface from node.js. Here is node.js code: var spawn = require('child_process').spawn; var child = spawn('java',…
Dmytro Nalyvaiko
  • 1,664
  • 4
  • 16
  • 27
0
votes
1 answer

How to make a NodeJS Server that emits a string file line by line with a time interval when connected?

I am trying to implement a simple NodeJS server that reads a file and then emits line by line to the requester with a time interval between emissions. The problem is the timeout which is not working as intended. var http = require('http'); var…
Ortharios
  • 610
  • 1
  • 5
  • 10
0
votes
1 answer

node.js: implementing a stream which ignores 'end'

I'm implementing some writable stream and use it like this: const consumer = new MyStream() // stream which I implementing // producer1 and producer2 are just instances of any Readable stream producer1.pipe(consumer, {end:…
kharandziuk
  • 12,020
  • 17
  • 63
  • 121
0
votes
2 answers

Node - Abstracting Pipe Steps into Function

I'm familiar with Node streams, but I'm struggling on best practices for abstracting code that I reuse a lot into a single pipe step. Here's a stripped down version of what I'm writing…
AdamPat
  • 101
  • 1
  • 10
0
votes
2 answers

How to read contents of html textbox and saving it to txt file using node js

I am learning Node.js scripting. I want to read input-text from textbox in html page with an option submit, it should save the content to .txt file using node.js (using POST/GET)
user2985956
  • 1
  • 1
  • 1
0
votes
1 answer

node.js - how to modiffy response headers

Platform: node.js + express and request modules (beginner). HI, I got simply router.get followed by a request and I want to modify the headers it get from external server, and send it to the user that requested the specific data. router.get('/',…
webmasternewbie
  • 167
  • 1
  • 2
  • 16
0
votes
1 answer

Check if a stream is process.stdout

Is there an elegant way to determine if a stream is process.stdout I am working with streams and will like to end the stream, but found out that if the stream is process.stdout an error is thrown because process.stdout is a special stream that…
hisabimbola
  • 196
  • 3
  • 14
0
votes
1 answer

NodeJS Stream splitting

I have an infinite data stream from a forked process. I want this stream to be processed by a module and sometimes I want to duplicate the data from this stream to be processed by a different module (e.g. monitoring a data stream but if anything…
András
  • 693
  • 5
  • 17
0
votes
1 answer

Use only one write stream in parent process for multiple child processes

Say I have multiple node.js child processes, and I want their stdout/stderr to all write to the same file. In the parent process, ideally I could create one stream to the file, something like so: const cp = require('child_process'); const strm =…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
0
votes
1 answer

How do you create a node.js style Readable Stream in a browser using native JS?

You can read a Readable Stream that is produced by a browserified lib. You can also create a Readable Stream using a lib like highland.js. Is there then a way to create Node.js style Readable Streams in a browser that doesnt rely on an external lib?
Fergie
  • 5,933
  • 7
  • 38
  • 42