Monday, May 19, 2014

Read Line in [Node.js]

Readline allows reading of a stream (such as process.stdin) on a line-by-line basis.

How to Use:

 var readline = require('readline');  
 var rl = readline.createInterface({  
  input: process.stdin,  
  output: process.stdout  
 });  
 rl.question("What do you think of node.js? ", function(answer) {  
  // TODO: Log the answer in a database  
  console.log("Thank you for your valuable feedback:", answer);  
  rl.close();  
 });  

How to execute:



No comments:

Post a Comment