chopped-stream

0.1.0 • Public • Published

node-chunked-stream

Build Status

Convert any stream into one that gives you data in user-defined sized chunks.

var assert = require('assert')
var chunkedStream = require('../.')
var fs = require('fs')
var path = require('path')
 
var numChunks = 0
fs.createReadStream(path.join(__dirname, 'data/data.txt'))
  .pipe(chunkedStream(1000))
  .on('data', function (chunk) {
    numChunks++
    if (numChunks < 20) {
      assert(chunk.length === 1000,
             'Each chunk except for the last one should be 1000 bytes long')
    } else {
      assert(chunk.length === 660,
             'Last chunk should be 660 bytes long')
    }
  })

Install

npm install chopped-stream

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.0
    7
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.1.0
    7

Package Sidebar

Install

npm i chopped-stream

Weekly Downloads

1

Version

0.1.0

License

MIT

Last publish

Collaborators

  • abi