The `http-range` package provides a Node.js-specific parser and creator for HTTP/1.1 `Content-Range` and `Range` header fields. It offers dedicated classes `ContentRange` and `Range` for handling these headers, allowing developers to parse incoming header strings into structured objects and construct valid header strings from component parts. Additionally, it exposes a `RangeSpec` class for granular control over individual range specifications. The package is currently at version 1.0.0, indicating a stable and mature API. Its primary focus is on strict adherence to RFC2616 specifications for range headers, differentiating it by offering distinct classes for both Content-Range and Range headers rather than a single generic utility function. Release cadence is not explicitly defined but the project appears to be stable with a specific and limited scope.
npm install http-rangeVerified import paths — ran on the pinned version, not inferred.
Demonstrates parsing and creating HTTP `Content-Range` and `Range` headers using the `ContentRange` and `Range` classes, including handling multiple range specifications and direct `RangeSpec` usage.
Wrap calls to constructors and `parse` methods (e.g., `new ContentRange().parse(input)`) in `try...catch` blocks to handle malformed header strings or invalid arguments gracefully.
Ensure all arguments passed to `ContentRange`, `Range`, or `RangeSpec` constructors conform to their expected types and formats (e.g., `length` must be a number or `'*'`). Consult the API documentation for each class's constructor signature.
Validate the input string against RFC2616 for `Content-Range` (e.g., `bytes 0-49/50`) or `Range` (e.g., `bytes=0-49,100-199`) before attempting to parse, or wrap the parse call in a `try...catch` block to handle parsing errors.
No dependency data recorded yet.