{"id":18428,"library":"http-content-range-format","title":"http-content-range-format","description":"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.","status":"active","version":"1.0.0","language":"javascript","source_language":"en","source_url":"git://github.com/purposeindustries/node-http-content-range-format","tags":["javascript","http","range","content-range","format"],"install":[{"cmd":"npm install http-content-range-format","lang":"bash","label":"npm"},{"cmd":"yarn add http-content-range-format","lang":"bash","label":"yarn"},{"cmd":"pnpm add http-content-range-format","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"wrong":"const { format } = require('http-content-range-format')","symbol":"default","correct":"import format from 'http-content-range-format'"},{"wrong":"const { format } = require('http-content-range-format')","symbol":"default (CommonJS)","correct":"const format = require('http-content-range-format')"}],"quickstart":{"code":"import format from 'http-content-range-format';\n\n// Format a Content-Range header for bytes 0-499/1234\nconst header = format({ first: 0, last: 499, length: 1234 });\nconsole.log(header); // 'bytes 0-499/1234'\n\n// Format a suffix range (last N bytes)\nconst suffixHeader = format({ length: 100, last: 99, total: 1000 });\nconsole.log(suffixHeader); // 'bytes -99/1000'\n\n// Format an unsatisfied range (length only)\nconst unsatisfiedHeader = format({ length: 0, total: 500 });\nconsole.log(unsatisfiedHeader); // 'bytes */500'","lang":"typescript","description":"Demonstrates formatting Content-Range headers with different range types: first-last, suffix, and unsatisfied."},"warnings":[{"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').","message":"The library expects object properties 'first', 'last', 'length', and 'total' exactly as documented; missing required fields will cause errors.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Provide 'total' when the total size is known; otherwise, it's optional.","message":"The 'total' field must be provided for a complete range; if omitted, the header will use '*' for total length.","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":"Pass an object with required properties: format({ first: 0, last: 499, length: 1234 })","cause":"Calling format() without arguments or with undefined/null.","error":"TypeError: Cannot read property 'first' of undefined"},{"fix":"Use default import: const format = require('http-content-range-format')","cause":"Incorrect import (e.g., destructuring default export in CommonJS).","error":"TypeError: format is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}