chopshop
chopshop takes a node readable stream and yields a series of fixed-length streams. This is particularly useful if you need to convert a file into multiple files of size N.
Install
In your project, run:
npm install chopshop --save
or install from the GitHub repo:
npm install ludios/chopshop --save
API
const chunk = chunk;;
chunk
returns an iterable of readable streams, all maxBytes
in size
except for the last chunk, which may be smaller. You must finish reading
a chunk before you start reading the next chunk. If your input stream
has 0 bytes, you still get one chunk with 0 bytes.
Example
"use strict"; const chunk = chunk;const fs = ;const co = ; ;
Be careful: you must not start reading from the next chunk before you finish
reading from the current chunk. That's why we use co
and a Promise
above
to wait for the chunk to finish.