• Home
Name Date Size #Lines LOC

..--

node_modules/12-May-2024-3,2492,177

.travis.ymlD12-May-202469 76

LICENSED12-May-20241.1 KiB2217

README.mdD12-May-20241.1 KiB6040

example.jsD12-May-2024390 2315

index.jsD12-May-20241.5 KiB5543

package.jsonD12-May-20241.7 KiB5857

test.jsD12-May-20241.6 KiB8668

README.md

1# flush-write-stream
2
3A write stream constructor that supports a flush function that is called before `finish` is emitted
4
5```
6npm install flush-write-stream
7```
8
9[![build status](http://img.shields.io/travis/mafintosh/flush-write-stream.svg?style=flat)](http://travis-ci.org/mafintosh/flush-write-stream)
10
11## Usage
12
13``` js
14var writer = require('flush-write-stream')
15
16var ws = writer(write, flush)
17
18ws.on('finish', function () {
19  console.log('finished')
20})
21
22ws.write('hello')
23ws.write('world')
24ws.end()
25
26function write (data, enc, cb) {
27  // i am your normal ._write method
28  console.log('writing', data.toString())
29  cb()
30}
31
32function flush (cb) {
33  // i am called before finish is emitted
34  setTimeout(cb, 1000) // wait 1 sec
35}
36```
37
38If you run the above it will produce the following output
39
40```
41writing hello
42writing world
43(nothing happens for 1 sec)
44finished
45```
46
47## API
48
49#### `var ws = writer([options], write, [flush])`
50
51Create a new writable stream. Options are forwarded to the stream constructor.
52
53#### `var ws = writer.obj([options], write, [flush])`
54
55Same as the above except `objectMode` is set to `true` per default.
56
57## License
58
59MIT
60