To read file content using readline module, you need to create the same interface using createInterface() command, but instead of connecting the input option to the process.stdin object, you connect it to the fs.createReadStream() method. Accepts an options Object that takes the following values: input - the readable stream to listen to (Required). Note that once youve invoked this module, your node program will not terminate. ![]() Optionally, interface specifies a readline.Interface instance for which autocompletion is disabled when copy-pasted input is detected. An example of a web server written with Node. interface readline.InterfaceConstructor The readline.emitKeypressEvents() method causes the given Readable stream to begin emitting 'keypress' events corresponding to received input. The rl.close() method is replaced with process.exit() method because the readline interface will still wait for the abort signal to close the interface if you use the rl.close() method. Readline allows reading of a stream (such as STDIN) on a line-by-line basis. node options V8 options script.js -e 'script' - arguments Please see the Command-line options document for more information. The Readline module provides a way of reading a datastream, one line at a time. ![]() ![]() Const readline = require ( 'readline' ) const rl = readline. The node:readline module provides an interface for reading data from a Readable stream (such as process.stdin ) one line at a time.
0 Comments
Leave a Reply. |