JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1003305
  • Score
    100M100P100Q185199F
  • License MIT

File writer

Package Exports

  • steno

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (steno) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

steno

Super fast non-blocking file writer for Node.

var steno = require('steno')

for (var i = 0; i < 10000; i++) {
  steno('file.txt').write(i)
}

This code runs in 2ms versus ~5500ms with fs.writeFileSync.

API

steno(filename)

Returns writer for filename.

writer.write(data)

Writes data to file. If file is already being written, data is buffered until it can be written.

writer.setCallback(cb)

Use it to set a callback that will be executed between two writes. Useful for atomic writing, logging, delaying, ...

steno('tmp-file.txt').setCallback(function(data, next) {
  console.log(data + ' has been written to ' + this.filename)
  fs.rename('tmp-file.txt', 'file.txt', function(err) {
    if (err) throw err
    next() // next must be called
  })
})