Why is process.stdout.on('data' not firing until I press enter (node.js)?

Viewed 68

My code:

process.stdout.on('data',function(){
    process.stdout.write('hello world detected');
    process.exit();
})


process.stdout.write('hello world')

When I run this script, I just see "hello world". Then if I press enter, I see "hello world detected".

I would expect that writing to stdout would trigger the "data" event. What triggers the data event exactly?

0 Answers
Related