Skip to content

emilbayes/tail-bytes-stream

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tail-bytes-stream

Build Status

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

License

ISC

About

Read `n` bytes from the end of a stream

Resources

License

Stars

Watchers

Forks

Packages

No packages published