Parser and formatter for the HTTP/1.1 Content-Range header field. Current stable version is 2.0.2, released periodically via npm. Provides two functions: format() to build the header string from object parameters (unit, start, end, size) and parse() to parse the header string into an object with unit, start, end, and length. Ships TypeScript definitions. Key differentiator: lightweight (no dependencies) and focuses solely on Content-Range, unlike larger HTTP libraries.
npm install content-rangeNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to format a Content-Range header object into a string and parse a string back into an object.
Access the parsed object's 'length' property instead of 'size'.
Use 'size' when calling format() and expect 'length' when using parse().
Ensure the input to parse has no extra spaces. For example, 'bytes 10-20/100' (single space between 'bytes' and range).
Ensure the argument to format() includes 'unit', 'start', 'end', and 'size'.
Use named import: import { parse } from 'content-range'Pass a valid HTTP Content-Range header string like 'bytes 0-499/1000'.
No dependency data recorded yet.