multibuffer-stream
A streaming version of multibuffer
This is useful for packaging your buffers to cross transport layers that may alter the stream frame boundaries (e.g. combine chunks or break in the middle of them) so they can be re-assembled into the original buffers.
var mbstream = var through2 = var spigot = // encode // re-assemble into original buffers /*MyDearAuntSally */ // Convert a stream into a multibuffer stream with `wrap`// **NOTE** You **MUST** know the full length of the stream first!var fs = var file = "./README.md"var size = fssizefs // convert to multibuffer-stream // convert back to regular stream
API
.packStream()
Create a stream.Transform
instance that will convert buffers written to it into multibuffers
.unpackStream()
Create a stream.Transform
instance that will re-assemble the original packed stream.
.wrap(byteLength)
Creates a Transform
stream that will wrap a known length stream as a multibuffer (i.e. prefix the first chunk with the length).
This means it is not suitable for never-ending streams.
LICENSE
MIT