Node.js process on events
#!/usr/bin/env node/*from ww w . j av a 2 s. com*/ // This experiment shows which stdin events are fired // with a 'data' event handler. var num = 0; function logEvent(message) { console.log(++num + '. ' + message); } console.log( "stdin events with 'data' event handler:" ); process.stdin.on('open', function () { logEvent('stdin open'); }); process.stdin.on('end', function () { logEvent('stdin end'); }); process.stdin.on('close', function () { logEvent('stdin close'); }); process.stdin.on('data', function () { logEvent('stdin data'); }); process.stdin.on('readable', function () { logEvent('stdin readable'); });