range-stream

Receive a byte range from a readable stream

MIT License

Downloads
8
Stars
1
Committers
1

range-stream

Receive a byte range from a readable stream

Fork of range-stream

Use

$ npm install --save range-stream
var rangeStream = require("range-stream")

fs.createReadStream("file.txt").pipe(rangeStream(50, 100))

Doesn't fs.createReadStream have start and end options?

Yes. And range-stream is meant to behave the same way when consuming a stream that doesn't give you those options.

Limitations

range-stream currently only works with Buffer streams. Support for object mode is planned (PR welcome 👍).

API

require("range-stream")(start, end)

start

Type: Number

The byte offset to begin consuming data from the source stream.

end

Type: Number

The byte offset that when hit will end the stream.

License

Copyright (c) 2014 Stephen Sawchuk. Licensed under the MIT license.