rl.close()
This
method closes the readline.Interface instance and relinquishes control over the
input and output streams. This method emits the close event.
HelloWorld.js
/* Import readline module */ var readline = require('readline'); /* * create a new readline.Interface instance that reads data from standard input * and write data to standard output */ var rl = readline.createInterface({ input: process.stdin, output: process.stdout }); rl.on('close', () => { console.log("Close event received"); }); rl.question("Enter some thing to close the readline interface instance.", () => { rl.close(); });
Output
Enter
some thing to close the readline interface instance.Hello
Close
event received
No comments:
Post a Comment