Nighttime Possum Meandering

    io-buffer

    1.1.0 • Public • Published

    io-buffer

    Build Status

    A dead-simple stream that buffers I/O. Data is made available in chunks of your specified size.

    Examples

    var fs = require('fs');
    var ioBuf = require('io-buffer');
     
    // Write data to a file in 256 byte chunks
    var buffered = ioBuf.createBufferedStream(256);
    buffered.pipe(fs.createWriteStream('/some/file'));
     
    buffered.write(new Buffer(200)); // No data is provided to the fs.WriteStream
    buffered.write(new Buffer(100)); // 256 bytes sent to the fs.WriteStream
    buffered.end();                  // Remaining 44 bytes sent to the fs.WriteStream
     
    // Read data in 4MB chunks
    buffered = ioBuf.createBufferedStream(4 * 1024 * 1024);
    var readable = fs.createReadStream('/some/big/file');
    readable.pipe(buffered)
      .on('readable', function() {
        var data = buffered.read(); // read 4MB of data
      });

    Keywords

    none

    Install

    npm i io-buffer

    DownloadsWeekly Downloads

    3

    Version

    1.1.0

    License

    ISC

    Last publish

    Collaborators

    • rclark