You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

пре 3 година
123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # stdout-stream
  2. Non-blocking stdout stream
  3. npm install stdout-stream
  4. [![build status](http://img.shields.io/travis/mafintosh/level-filesystem.svg?style=flat)](http://travis-ci.org/mafintosh/stdout-stream)
  5. ![dat](http://img.shields.io/badge/Development%20sponsored%20by-dat-green.svg?style=flat)
  6. ## Rant
  7. Try saving this example as `example.js`
  8. ``` js
  9. console.error('start');
  10. process.stdout.write(new Buffer(1024*1024));
  11. console.error('end');
  12. ```
  13. And run the following program
  14. ```
  15. node example.js | sleep 1000
  16. ```
  17. The program will never print `end` since stdout in node currently is blocking - even when its being piped (!).
  18. stdout-stream tries to fix this by being a stream that writes to stdout but never blocks
  19. ## Usage
  20. ``` js
  21. var stdout = require('stdout-stream');
  22. stdout.write('hello\n'); // write should NEVER block
  23. stdout.write('non-blocking\n')
  24. stdout.write('world\n');
  25. ```
  26. `stdout-stream` should behave in the same way as `process.stdout` (i.e. do not end on pipe etc)
  27. ## License
  28. MIT