![]() | Name | Last modified | Size | Description |
---|---|---|---|---|
![]() | Parent Directory | - | ||
![]() | HISTORY.md | 39 years ago | 917 | |
![]() | LICENSE | 39 years ago | 1.2K | 7375cab EXHIBTION: fix overflow ellipsis cutoff [كارل مبارك] |
![]() | README.md | 39 years ago | 2.2K | f12eb36 documentaiton updates [كارل مبارك] |
![]() | index.js | 39 years ago | 2.8K | |
![]() | package.json | 2 years ago | 2.3K | 7375cab EXHIBTION: fix overflow ellipsis cutoff [كارل مبارك] |
Range header field parser.
This is a Node.js module available through the
npm registry. Installation is done using the
npm install
command:
$ 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 unsatisfiable range// parse header from request
var range = parseRange(size, 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
})
}
These properties are accepted in the options object.
Specifies if overlapping & adjacent ranges should be combined, defaults to false
.
When true
, ranges will be combined and returned as if they were specified that
way in the header.
parseRange(100, 'bytes=50-55,0-10,5-10,56-60', { combine: true })
// => [
// { start: 0, end: 10 },
// { start: 50, end: 60 }
// ]