Node Js process.stdin
<p>I'm just now getting into node.js and reading input from the command line. </p>

<p>I'm a bit confused on the following code example.</p>

<pre><code>process.stdin.setEncoding('utf8');

process.stdin.on('readable', () =&gt; {
  var chunk = process.stdin.read();
  if (chunk !== null) {
    process.stdout.write(`data: ${chunk}`);
  }
});

process.stdin.on('end', () =&gt; {
  process.stdout.write('end');
});
</code></pre>

<p>First, in <em>old</em> mode, <code>process.stdin.resume()</code> was needed to make it begin to listen. Doesn't using <code>resume()</code> make more sense for performance? Doesn't this continually listen, using up processing power that it doesn't need to use up?</p>

<p>Also, I read the docs but I'm not understanding what <code>'end'</code> does here.</p>

<p>The docs say:</p>

<blockquote>
  <p>This event fires when there will be no more data to read.</p>
</blockquote>

<p>But <code>'readable'</code> is always listening so we never get to the <code>'end'</code>?</p>