Node.js: STDIN

From delarco wiki
Revision as of 19:06, 25 August 2022 by 200.201.163.25 (talk) (Created page with "<pre> var stdin = process.openStdin(); stdin.addListener("data", function(d) { // note: d is an object, and when converted to a string it will // end with a linefeed. so we (rather crudely) account for that // with toString() and then trim() console.log("you entered: [" + d.toString().trim() + "]"); }); </pre>")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
var stdin = process.openStdin();

stdin.addListener("data", function(d) {
// note:  d is an object, and when converted to a string it will
// end with a linefeed.  so we (rather crudely) account for that  
// with toString() and then trim() 
	console.log("you entered: [" + d.toString().trim() + "]");
});