Registry / http-networking / http-content-range-format

http-content-range-format

JSON →
library1.0.0jsnpmunverified

Format HTTP Content-Range headers according to RFC 7233. Version 1.0.0 is the latest and stable. This package provides a simple function to construct Content-Range header strings from numeric components. It is minimal, dependency-free, and focused on server-side use cases. No significant breaking changes or known vulnerabilities as of the release.

npm install http-content-range-format
INSTALL
IMPORT
SIG · HTTP-CONTENT-RANGE
H
http-content-range-format
http-networkingjavascriptv1.0.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
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 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

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

default
✓ import format from 'http-content-range-format'
✗ const { format } = require('http-content-range-format')
default (CommonJS)
✓ const format = require('http-content-range-format')
✗ const { format } = require('http-content-range-format')

Demonstrates formatting Content-Range headers with different range types: first-last, suffix, and unsatisfied.

import format from 'http-content-range-format'; // Format a Content-Range header for bytes 0-499/1234 const header = format({ first: 0, last: 499, length: 1234 }); console.log(header); // 'bytes 0-499/1234' // Format a suffix range (last N bytes) const suffixHeader = format({ length: 100, last: 99, total: 1000 }); console.log(suffixHeader); // 'bytes -99/1000' // Format an unsatisfied range (length only) const unsatisfiedHeader = format({ length: 0, total: 500 }); console.log(unsatisfiedHeader); // 'bytes */500'
Debug
Known issues
gotchaThe library expects object properties 'first', 'last', 'length', and 'total' exactly as documented; missing required fields will cause errors.
fix
Ensure all required fields are provided: for a standard range, include 'first' and 'last'; for suffix range, include 'length' and 'last'; for unsatisfied, include 'length' (or 'total' without 'first'/'last').
affects: >=1.0.0
gotchaThe 'total' field must be provided for a complete range; if omitted, the header will use '*' for total length.
fix
Provide 'total' when the total size is known; otherwise, it's optional.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Cannot read property 'first' of undefined
Calling format() without arguments or with undefined/null.
fix
Pass an object with required properties: format({ first: 0, last: 499, length: 1234 })
TypeError: format is not a function
Incorrect import (e.g., destructuring default export in CommonJS).
fix
Use default import: const format = require('http-content-range-format')
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
http-content-range-format — npm install http-content-range-format · libregistry