https://github.com/abi/node-chopped-stream
Convert any stream into one that gives you data in user-defined sized chunks
https://github.com/abi/node-chopped-stream
Last synced: 4 months ago
JSON representation
Convert any stream into one that gives you data in user-defined sized chunks
- Host: GitHub
- URL: https://github.com/abi/node-chopped-stream
- Owner: abi
- License: mit
- Created: 2013-08-16T21:01:47.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2013-08-17T05:20:01.000Z (almost 13 years ago)
- Last Synced: 2025-10-07T01:37:43.120Z (8 months ago)
- Homepage:
- Size: 121 KB
- Stars: 3
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
node-chopped-stream
===================
[](https://travis-ci.org/abi/node-chopped-stream)
Convert any stream into one that gives you data in user-defined sized chunks.
```javascript
var assert = require('assert')
var choppedStream = require('../.')
var fs = require('fs')
var path = require('path')
var numChunks = 0
fs.createReadStream(path.join(__dirname, 'data/data.txt'))
.pipe(choppedStream(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`