node.js: readSync from stdin?
问题 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. I tried this: const fs = require('fs'); var c = fs.readSync(0,1,null,'utf-8'); console.log('character: '+c+' ('+c.charCodeAt(0)+')'); But this only produces this output: fs:189 var r = binding.read(fd, buffer, offset, length, position); ^ Error: EAGAIN, Resource