O'Reilly logo

Node Cookbook Second Edition by David Mark Clements

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Streaming across Node processes

Streams are about facilitating efficient, low memory data transfer, and processing; not just to and from the filesystem, but also to other processes and across network sockets.

In this recipe, we're going to write some simple command-line stream apps, then mix and match them with the common stream processing apps written in other languages.

Getting ready

Let's create two files: text_stream.js and uppercaser.js. Both of these need to be executable files as we're going to run them directly as command-line apps:

touch text_stream.js && chmod +x text_stream.js
touch uppercaser.js && chmod + x uppercaser.js

How to do it…

Let's start by making a readable stream that randomly pushes lowercase alphabetical letters to its reader ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required