JSPM

http-range-parse

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 320
  • Score
    100M100P100Q94294F
  • License MIT

Parse HTTP Range header, based on RFC7233

Package Exports

  • http-range-parse

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (http-range-parse) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

http-range-parse

Parse HTTP Range headers, RFC7233 compilant.

Install

Install the package with npm

$ npm install http-range-parse

Usage

var parse = require('http-range-parse');

console.log(parse('items=1-2,995-,-1'))

API

.parse(str)

Parse the given Range header. The returned object contains the range unit, and the requested range.

parse('items=1-2')
// { unit: 'items', first: 1, last: 2 }

parse('items=-5')
// { unit: 'items', suffix: 5 }

parse('items=1-')
// { unit: 'items', first: 1 }

parse('items=1-2,3-4')
// { unit: 'items', ranges: [{ first: 1, last: 2 }, { first: 3, last: 4 }] }

License

MIT