blob-slicer
Read all or part of the content in a Blob or File as a Buffer or Stream
Install
npm install blob-slicer
Usage
var BlobSlicer = var reader = // Read as Bufferreader // Read as Streamreader
blob-slicer depends on buffer v4.x . Therefore, if you are using browserify v14 and higher, you must include buffer v4 instead of the default v5 by either doing :
browserify -r buffer/:buffer main.js -o bundle.js
or
API
Class: BlobSlicer
new BlobSlicer(blob)
Throws error if blob is not an instance of Blob or File.
blobSlicer.read([start], [end], callback)
Read a range of bytes delimited by start(inclusive) and end(exclusive).
If end is not specified, it reads all bytes from start to the end of blob.
If start and end are not specified, it reads all data in the blob.
The callback is passed two arguments (err: Error, buf: Buffer)
.
blobSlicer.createReadStream([options])
options
may be omitted, the default is {highWaterMark: 64 * 1024, start: 0, end: blob.size}
.
options.start
is inclusive, options.end
is exclusive.
Return an instance of ReadStream
.
Class: ReadStream
An implementation of Readable Streams.
readStream.readableLength: number
same as in stream_readable_readablelength
readStream.ended: boolean
true
if reached the end of blob (there may be still some bytes in the queue ready to be consumed).
License
MIT. Copyright (c) Hoummad Merzouqi.