hypercore-byte-stream
A Readable stream wrapper around Hypercore that supports reading byte ranges.
When provided with optional start/end block heuristics, this module will efficiently sync only those blocks which contain the specified range.
Supports asynchronously specifying stream options, as well as the input feed, to remove the need for additional stream management modules like duplexify
.
Most of the code has been extracted from Hyperdrive.
Usage
The following example will return a byte stream of the entire input feed.
const ram = require('random-access-memory')
const hypercore = require('hypercore')
const createByteStream = require('hypercore-byte-stream')
let core = hypercore(ram)
let stream = createByteStream({
feed: core
})
API
stream = createStream([options])
Creates a new byte stream.
If specified, options can include:
{
feed: core,
byteOffset: 0,
byteLength: 10,
blockOffset: 0,
blockLength: 10
}
stream.start([options])
Starts downloading and streaming according to the specified options.
Options are the same as in createStream
. If a feed
was specified in the stream constructor, then one should not provide
another stream in the start
options.
License
MIT