rotate-file-stream

a file write stream that rotates with time

rotate-file-stream

This is a really simple stream that pipes data into fs.WriteStream, and rotates the files after some time.

npm install --save rotate-file-stream
var rotateFileStream = require('rotate-file-stream');
var rfs = rotateFileStream(__dirname+'/parts', { // returns a regular stream.Writable 
  interval: 10000, // rotation interval 
  appendFileNamefunction (i) {
    return '_part'+i+'.txt'; // how to name the new files 
  }
});
 
someOtherStream.pipe(rfs);

The default interval is 36e5 (1 hour), and the default appendFileName function is function (part) { return '_part'+part; }

MIT