tail-bytes-stream
v1.0.1
Published
Read `n` bytes from the end of a stream
Downloads
3
Readme
tail-bytes-stream
Read
n
bytes from the end of a stream
Usage
var tailBytes = require('tail-bytes-stream')
dataStream.pipe(tailBytes(32, function (bytes, done) {
if(Buffer.compare(bytes, Buffer.from('...')) === 0) return done()
return done(new Error('Mismatch'))
}))
API
var stream = tailBytes(n, ontail)
Read n
bytes from the end of the stream and call ontail(bytes, done)
when
they're available. bytes
might be shorter than n
if the source stream wasn't
long enough. You can rewrite bytes
or other data to any subsequent streams.
Returns a Transform
stream so you can pipe it to other streams.
Install
npm install tail-bytes-stream