title: node.js: readSync from stdin?
body: <p>Is it possible to synchronously read from stdin in node.js? Because I'm writing a brainfuck to JavaScript compiler in JavaScript (just for fun). Brainfuck supports a read operation which needs to be implemented synchronously.</p>
  
  <p>I tried this:</p>
  
  <pre><code>const fs = require('fs');
  var c = fs.readSync(0,1,null,'utf-8');
  console.log('character: '+c+' ('+c.charCodeAt(0)+')');
  </code></pre>
  
  <p>But this only produces this output:</p>
  
  <pre><code>fs:189
    var r = binding.read(fd, buffer, offset, length, position);
                ^
  Error: EAGAIN, Resource temporarily unavailable
      at Object.readSync (fs:189:19)
      at Object.&lt;anonymous&gt; (/home/.../stdin.js:3:12)
      at Module._compile (module:426:23)
      at Module._loadScriptSync (module:436:8)
      at Module.loadSync (module:306:10)
      at Object.runMain (module:490:22)
      at node.js:254:10
  </code></pre>