1.1.0 • Published 9 years ago

disk-buffer v1.1.0

Weekly downloads
1
License
MIT
Repository
github
Last release
9 years ago

disk-buffer

Disk buffer as a writable stream, which after n bytes written and/or m writes finishes the file, emits an event and starts writing to a new one.

build status

Example

var DiskBuffer = require('disk-buffer');

var b = new DiskBuffer('/tmp/artifacts', {
  flushBytes: 1024,
  flushWrites: 20
});

b.on('flush', function(flush){
  // do something with the file at
  // `flush.path`
});

someData().pipe(b);

Installation

$ npm install disk-buffer

API

DiskBuffer(path, opts)

Create a new DiskBuffer. The path given is used for the base of the filenames created, which append ".{pid}.{id}.{fid}".

Options:

  • .flushBytes: flush after this many bytes written
  • .flushWrites: flush after this many writes

flush event

For every flush, an event with the following properties is emitted:

  • path: the file's location
  • opened: a date object of the file's creation

Kudos

This is inspired by tj/go-disk-buffer.

License

MIT

1.1.0

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago