Skip to content

Instantly share code, notes, and snippets.

@marcossouz
Created July 5, 2021 03:45
Show Gist options
  • Select an option

  • Save marcossouz/bbd409aed26fe983283ea331c5c54626 to your computer and use it in GitHub Desktop.

Select an option

Save marcossouz/bbd409aed26fe983283ea331c5c54626 to your computer and use it in GitHub Desktop.
interface de entrada de dados javascript
var readline = require('readline');
var fs = require('fs');
var myInterface = readline.createInterface({
input: fs.createReadStream('input.in') // file input data
});
myInterface.on('line', function (line) {
console.log(line); // input data
});
myInterface.on('close', function() {
console.log('close'); // end input data
});
myInterface.on('error', function(err) {
console.log(err); // if error
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment