title: How to get synchronous readline, or "simulate" it using async, in nodejs?
body: <p>I am wondering if there is a simple way to get "synchronous" readline or at least get the appearance of synchronous I/O in node.js</p>
  
  <p>I use something like this but it is quite awkward</p>
  
  <pre><code>var readline = require('readline');
  var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
    terminal: false
  });
  
  var i = 0;
  var s1 = '';
  var s2 = '';
  
  rl.on('line', function(line){
      if(i==0) { s1 = line; }
      else if(i==1) { s2 = line; }
      i++;
  })
  
  rl.on('close', function() {
      //do something with lines
  })'
  </code></pre>
  
  <p>Instead of this I would prefer if it were as easy as something like</p>
  
  <pre><code>var s1 = getline(); // or "await getline()?"
  var s2 = getline(); // or "await getline()?"
  </code></pre>
  
  <p>Helpful conditions:</p>
  
  <p>(a) Prefer not using external modules or /dev/stdio filehandle, I am submitting code to a code submission website and these do not work there</p>
  
  <p>(b) Can use async/await or generators</p>
  
  <p>(c) Should be line based</p>
  
  <p>(d) Should not require reading entire stdin into memory before processing</p>