blob: fa6b5dab25578c42124753daf9383cf135c32355 [file] [log] [blame]
Leo Repp58b9f112021-11-22 11:57:47 +01001var writer = require('./')
2
3var ws = writer(write, flush)
4
5ws.on('finish', function () {
6 console.log('finished')
7})
8
9ws.write('hello')
10ws.write('world')
11ws.end()
12
13function write (data, enc, cb) {
14 // i am your normal ._write method
15 console.log('writing', data.toString())
16 cb()
17}
18
19function flush (cb) {
20 // i am called before finish is emitted
21 setTimeout(cb, 1000) // wait 1 sec
22}