Tuesday 2 October 2018

node.js: Readline: pause method

rl.pause()
pause methog is used to pause the input stream, you can resume the stream by calling resume() method.

HelloWorld.rs
/* 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('pause', () => {
 console.log("Pause event is received");
});

rl.question("Enter some thing to pause the readline interface instance.", () => {
 rl.pause();
});


Output
Enter some thing to pause the readline interface instance.Hello
Pause event is received



Previous                                                 Next                                                 Home

No comments:

Post a Comment