Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Generated on May 20, 2024 via pnpm

range-parser 1.2.1

Range header field string parser
Package summary
Share
0
issues
1
license
1
MIT
Package created
11 Jun 2012
Version published
11 May 2019
Maintainers
4
Total deps
1
Direct deps
0
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
range-parser@1.2.1
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of range-parser 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does range-parser do?

The range-parser is a Node.js module that is specifically designed for parsing Range header field strings. With its efficient algorithm, it can parse given header strings and return an array of ranges or negative numbers that signal an error during parsing. This makes the range-parser an incredibly valuable tool for any programmer working with HTTP range requests. The ability to discern the type of range, if it's 'bytes' for instance, and properly index the start and end points of the range is a key feature of this module.

How do you use range-parser?

To use the range-parser module, it first has to be installed via npm with the command $ npm install range-parser. After it's been added to your project, you begin by requiring it in your JavaScript file with var parseRange = require('range-parser'). Then you can parse headers from your request using var range = parseRange(size, req.headers.range). If you need to work with the actual ranges, you can use them like this:

if (range.type === 'bytes') {
  // the ranges
  range.forEach(function (r) {
    // do something with r.start and r.end
  })
}

The range-parser also provides an option to combine overlapping & adjacent ranges. Check out this example on how to use it:

parseRange(100, 'bytes=50-55,0-10,5-10,56-60', 
  { combine: true })
// Outputs: 
// [
//    { start: 0,  end: 10 },
//    { start: 50, end: 60 }
// ]

Where are the range-parser docs?

The official documentation of the range-parser, which include details of its API and options, can be found in the readme content of the package published at the official GitHub repository: https://github.com/jshttp/range-parser. You can always refer back to this readme for advanced usage examples and the latest updates.