range-parser (1.2.1)
Published 2026-02-24 14:03:52 +00:00 by atheaadmin
Installation
registry=npm install range-parser@1.2.1"range-parser": "1.2.1"About this package
range-parser
Range header field parser.
Installation
This is a Node.js module available through the
npm registry. Installation is done using the
npm install command:
$ npm install range-parser
API
var parseRange = require('range-parser')
parseRange(size, header, options)
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.
-2signals a malformed header string-1signals 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
})
}
Options
These properties are accepted in the options object.
combine
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 }
// ]
License
Dependencies
Development Dependencies
| ID | Version |
|---|---|
| deep-equal | 1.0.1 |
| eslint | 5.16.0 |
| eslint-config-standard | 12.0.0 |
| eslint-plugin-import | 2.17.2 |
| eslint-plugin-markdown | 1.0.0 |
| eslint-plugin-node | 8.0.1 |
| eslint-plugin-promise | 4.1.1 |
| eslint-plugin-standard | 4.0.0 |
| mocha | 6.1.4 |
| nyc | 14.1.1 |
Keywords
range
parser
http