fork download
  1. var StringDecoder = require('string_decoder').StringDecoder
  2. var decoder = new StringDecoder('utf8')
  3. var stdin = process.stdin
  4. var sbuf = ''
  5.  
  6. pull()
  7.  
  8. function pull() {
  9. setImmediate(pull)
  10. var buf = stdin.read()
  11. if (!buf) return
  12. sbuf += decoder.write(buf)
  13. var i = sbuf.indexOf('\n')
  14. if (i == -1) return
  15. onLine(sbuf.slice(0,i))
  16. sbuf = sbuf.slice(i+1)
  17. }
  18.  
  19. function onLine(line) {
  20. console.log(line)
  21. }
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty