minipass-sized
A Minipass stream that raises an error if you get a different number of bytes than expected.
USAGE
Use just like any old minipass stream, but
provide a size
option to the constructor.
The size
option must be a positive integer, smaller than
Number.MAX_SAFE_INTEGER
.
const MinipassSized = // figure out how much data you expect to getconst expectedSize = +headers'content-length'const stream = size: expectedSize streamresponse
Caveats: this does not work with objectMode
streams, and will throw a
TypeError
from the constructor if the size argument is missing or
invalid.