• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1var 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}
23