Nanobots Producing Megastructures

writify

1.0.0 • Public • Published

writify

Write stream wrapper that supports async initialization and flush function.

Build Status

npm install writify

var ws = writify(init, [flush], [opts])

var ws = writify.obj(init, [flush], [opts])

Wraps a new writable stream (or object stream) by passing init callback function. Supports optional flush function that is called before 'finish' emitted.

var writify = require('writify')
...
 
var ws = writify((cb) => {
  // async initialization, error handling
  mkdirp('/tmp/foo/', (err) => {
    if (err) return cb(err)
    cb(null, fs.createWriteStream('/tmp/foo/bar.txt'))
  })
}, (cb) => {
  // flush before finish
  fs.rename('/tmp/foo/bar.txt', './dest.txt', cb)
})
 
fs.createReadStream('loremipsum.txt').pipe(ws)
 

License

MIT

Keywords

none

install

npm i writify

Downloadsweekly downloads

0

version

1.0.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability