arnaucode 112745d6fa | 7 years ago | |
---|---|---|
.. | ||
HISTORY.md | 7 years ago | |
LICENSE | 7 years ago | |
README.md | 7 years ago | |
index.js | 7 years ago | |
package.json | 7 years ago |
Range header field parser.
$ npm install range-parser
var parseRange = require('range-parser')
Parse the given header
string where size
is the maximum size of the resource.
An array of ranges will be returned or negative numbers indicating an error parsing.
-2
signals a malformed header string-1
signals an invalid range// parse header from request
var range = parseRange(req.headers.range)
// the type of the range
if (range.type === 'bytes') {
// the ranges
range.forEach(function (r) {
// do something with r.start and r.end
})
}