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