Registry / http-networking / http-range-parse

http-range-parse

JSON →
library1.0.0jsnpmunverified

Parses HTTP Range headers according to RFC7233. Current version 1.0.0, stable with no recent updates. Converts a range header string into a structured object with unit and range details (first, last, suffix, or multiple ranges). Lightweight, no dependencies. Compared to alternatives like `range-parser`, this library returns a more detailed object and supports multi-range headers.

npm install http-range-parse
INSTALL
IMPORT
SIG · HTTP-RANGE-PARSE
H
http-range-parse
http-networkingjavascriptv1.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

parse
import parse from 'http-range-parse'
const parse = require('http-range-parse')
Package is ESM-only since v1? Actually v1.0.0 uses CommonJS, but for modern code use ESM import. Check your Node version.
parse
const parse = require('http-range-parse')
CommonJS require works as package exports a single function.
parse
import { parse } from 'http-range-parse'
import httpRangeParse from 'http-range-parse'
Default export is the parse function; named import `parse` is also available.

Parses an HTTP Range header and prints the structured result with unit and range objects.

const parse = require('http-range-parse'); const header = 'bytes=0-499,500-999'; const result = parse(header); console.log(result); // { unit: 'bytes', ranges: [{ first: 0, last: 499 }, { first: 500, last: 999 }] }
Debug
Known issues
gotchaInvalid range formats may return unexpected results or throw.
fix
Validate input header string before parsing; handle errors with try/catch.
affects: >=1.0.0
deprecatedPackage is not actively maintained; last release 2015.
fix
Consider using alternatives like `range-parser` or `http-range-parser` for ongoing support.
affects: >=1.0.0
gotchaSuffix range notation (-N) returns suffix property, but combined with other ranges may be misinterpreted.
fix
Check for `suffix` property separately and ensure it's not used with `first`/`last` in same header.
affects: >=1.0.0
gotchaThe package does not validate units; any string before '=' is accepted as unit.
fix
Manually verify the unit is one of the expected values (e.g., 'bytes') if required.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: parse is not a function
Incorrect import in ESM context (using default import for CJS module).
fix
Use `import parse from 'http-range-parse'` or `const parse = require('http-range-parse')` depending on module system.
Cannot find module 'http-range-parse'
Package not installed or not in node_modules.
fix
Run `npm install http-range-parse`.
Range header is malformed
Passing invalid or empty string to parse.
fix
Check header format; ensure it follows RFC7233 (e.g., 'unit=x-y').
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
http-range-parse — npm install http-range-parse · libregistry