How can I write blocking in stdout with node.js?
If you really really want synchronous writes to stdout you can do:
var fs = require('fs');
fs.writeSync(1, "Foo\n");
fs.fsyncSync(1);
Write using process.stdout.write
, the return value is whether data got buffered. If it's true, continue writing when process.stdout
emits the drain
event.
If you want your code to look sync, use streamlinejs as described here: Node.js stdout flush