Big update!Announcing Socket for GitHub 1.0. Learn more
Socket
BlogLoveFAQ
Install
Log in

range-parser

Package Overview
Dependencies
0
Maintainers
4
Versions
11
Issues
File Explorer

Advanced tools

range-parser

Range header field string parser

    1.2.1latest

Version published
Maintainers
4
Weekly downloads
26,063,739
increased by1.59%

Weekly downloads

Readme

Source

range-parser

NPM Version NPM Downloads Node.js Version Build Status Test Coverage

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.

  • -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 }) }
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

MIT

Keywords

FAQs

What is range-parser?

Range header field string parser

Is range-parser popular?

The npm package range-parser receives a total of 21,323,957 weekly downloads. As such, range-parser popularity was classified as popular.

Is range-parser well maintained?

We found that range-parser demonstrated a not healthy version release cadence and project activity. It has 4 open source maintainers collaborating on the project.

Last updated on 11 May 2019
Socket

Product

Subscribe to our newsletter

Get open source security insights delivered straight into your inbox. Be the first to learn about new features and product updates.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc