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

Node.js http chat server

I try create chat server, which will be conncted to Android clients. 1 Client send some data on server, server receive it and send to rest of Clients. So I tried use 'net', but that didn't works. On server i'm listening 1490 port and 192.168.3.XX…
Pasha Shkaran
  • 1,433
  • 2
  • 23
  • 41
0
votes
0 answers

How can I access file system from an external javascript file?

I have a file named server.js which reads an HTML file named "game.html". That HTML file is linked with an external javascript file named "game.js". In server.js file if(request.url.indexOf('.html') != -1) { fs.readFile("game" + request.url,…
0
votes
1 answer

How to get the data from a node read stream to use it for a HTTP post request?

I'd like to send an HTTP post request using the scoped-http-client, like this: client('http://url-to-post-to.com/').post({filedata: }) How would I pass in the data of a node stream?
thasmo
  • 9,159
  • 6
  • 27
  • 32
0
votes
1 answer

Detecting end of stream on streams2

I just read that if a stream uses 'data' or 'end' listeners it switches to "classic" mode and stream-handbook says: Note that whenever you register a "data" listener, you put the stream into compatability mode so you lose the benefits of the new…
iLemming
  • 34,477
  • 60
  • 195
  • 309
0
votes
1 answer

how to make gulp.dest dynamic

I am learning to use gulp.I took a eg scenario in which I tried to copy the files based on the name if it is odd move it to odd folder otherwise move it to even. But some where destination folder is messed up. here is the folder structure and…
coool
  • 8,085
  • 12
  • 60
  • 80
0
votes
1 answer

As lines are added to a file, how do I detect and read them in using a single file descriptor or stream?

Background - I'm trying to use node.js and the fs module to accomplish an end goal of monitoring a file, and detecting the lines that have been appended to it. Current Implementation - I'm currently using fs.watch to monitor the changes to the…
jfaghihnassiri
  • 523
  • 1
  • 4
  • 16
0
votes
1 answer

ForEachLine() in node.js

Referring to slide no 35 in ppt on slideshare When I run this code var server = my_http.createServer(); server.on("request", function(request,response){ var chunks = []; output =…
alwaysLearn
  • 6,882
  • 7
  • 39
  • 67
-2
votes
1 answer

Node.Js I can't run the server

This is what it supposed to do on Node.Js I am stuck at 6:16 where it said "node server.js" where it supposed to open up 127.0.0.1:3000, but all I get is this error. on my browser it says "ERR_CONNECTION_REFUSED" There is nothing wrong with XAMMP…
-3
votes
1 answer

Use node.js to idle games on a webserver?

I have no experience with programming (besides making simple HTML contact information websites) so I want to know if an idea I have is possible. An article caught my eye where someone was using a Raspberry Pi running node.js to idle Steam games and…
-3
votes
1 answer

How to deploy a node.js app to heroku?? It is possible or not?

The problem was with git add.I had forgotten to add the node_modules files.I closed the terminal and ran the set of commands given in the Getting started with Heroku and NodeJs[1] again.The application was successfully pushed onto the stack.
1 2 3
13
14