The first post was about dnode - the freestyle rpc library for node, the second was about optimist - the lightweight options parser for node, the third was about lazy - lazy lists for node, the fourth was about request - the swiss army knife of HTTP streaming, the fifth was about hashish - hash combinators library.

This time I'll introduce you to a brand new module called read. Read was created just yesterday by Isaac Z. Schlueter, the author of npm. Read is basically read(1) for node. You can read input from stdin with it easily.

Nesting functions like this is ugly, so you better use seq, the asynchronous flow combinators library, by James Halliday. (I'll introduce you to this module some time soon.) Here is how it looks with seq:

prompt - What to write to stdout before reading input.
silent - Don't echo the output as the user types it.
num - Max number of chars to read from terminal.
delim - The char that means we're done. Default: "\n"
timeout - Number of ms to wait for user input before giving up.

Note: If silent is true, or num is set, or delim is something other than "\n", then read will set raw mode, and read character by character.

You can install read through npm as always:

npm install read

Sponsor this blog series!

Doing a node.js company and want your ad to appear in the series? The ad will go out to 14,000 rss subscribers, 7,000 email subscribers, and it will get viewed by thousands of my blog visitors! Email me and we'll set it up!

Comments

I just wanted to note that I am really enjoying this series. Unfortunately, my real job does not provide the excuse to monitor the plethora of modules that are out there, so it's nice to read through your brief overviews. Thanks a lot!