title: How to add a timeout when reading from `stdin`
body: <p>I need to check if the user took more than 3000ms to give input on <code>stdin</code>.</p>
  
  <p>Is there a way to add a timeout when waiting for user input? Something like</p>
  
  <pre><code>if (timeout) {
    // do something
  } else {
    // do something else
  }
  </code></pre>