• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..20-Sep-2020-

node_modules/H20-Sep-2020-649542

.travis.ymlH A D26-Oct-198569 76

LICENSEH A D26-Oct-19851.1 KiB2217

README.mdH A D26-Oct-19851.1 KiB6040

package.jsonH A D20-Sep-20201.7 KiB6160

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