{"id":18434,"library":"http-range-parse","title":"http-range-parse","description":"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.","status":"active","version":"1.0.0","language":"javascript","source_language":"en","source_url":"git://github.com/purposeindustries/node-http-range-parse","tags":["javascript","http","range","parse"],"install":[{"cmd":"npm install http-range-parse","lang":"bash","label":"npm"},{"cmd":"yarn add http-range-parse","lang":"bash","label":"yarn"},{"cmd":"pnpm add http-range-parse","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package is ESM-only since v1? Actually v1.0.0 uses CommonJS, but for modern code use ESM import. Check your Node version.","wrong":"const parse = require('http-range-parse')","symbol":"parse","correct":"import parse from 'http-range-parse'"},{"note":"CommonJS require works as package exports a single function.","wrong":null,"symbol":"parse","correct":"const parse = require('http-range-parse')"},{"note":"Default export is the parse function; named import `parse` is also available.","wrong":"import httpRangeParse from 'http-range-parse'","symbol":"parse","correct":"import { parse } from 'http-range-parse'"}],"quickstart":{"code":"const parse = require('http-range-parse');\n\nconst header = 'bytes=0-499,500-999';\nconst result = parse(header);\nconsole.log(result);\n// { unit: 'bytes', ranges: [{ first: 0, last: 499 }, { first: 500, last: 999 }] }","lang":"javascript","description":"Parses an HTTP Range header and prints the structured result with unit and range objects."},"warnings":[{"fix":"Validate input header string before parsing; handle errors with try/catch.","message":"Invalid range formats may return unexpected results or throw.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Consider using alternatives like `range-parser` or `http-range-parser` for ongoing support.","message":"Package is not actively maintained; last release 2015.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Check for `suffix` property separately and ensure it's not used with `first`/`last` in same header.","message":"Suffix range notation (-N) returns suffix property, but combined with other ranges may be misinterpreted.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Manually verify the unit is one of the expected values (e.g., 'bytes') if required.","message":"The package does not validate units; any string before '=' is accepted as unit.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use `import parse from 'http-range-parse'` or `const parse = require('http-range-parse')` depending on module system.","cause":"Incorrect import in ESM context (using default import for CJS module).","error":"TypeError: parse is not a function"},{"fix":"Run `npm install http-range-parse`.","cause":"Package not installed or not in node_modules.","error":"Cannot find module 'http-range-parse'"},{"fix":"Check header format; ensure it follows RFC7233 (e.g., 'unit=x-y').","cause":"Passing invalid or empty string to parse.","error":"Range header is malformed"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}