import { parseRange } from "https://deno.land/x/ayonli_jsext@v0.9.72/esm/http/util.js";
Parses the Range
header.
Examples
Example 1
Example 1
import { parseRange } from "@ayonli/jsext/http";
const range = parseRange("bytes=0-499");
console.log(range);
// { unit: "bytes", ranges: [{ start: 0, end: 499 }] }
const range2 = parseRange("bytes=0-499,1000-1499");
console.log(range2);
// { unit: "bytes", ranges: [{ start: 0, end: 499 }, { start: 1000, end: 1499 }] }
const range3 = parseRange("bytes=2000-");
console.log(range3);
// { unit: "bytes", ranges: [{ start: 2000 }] }
const range4 = parseRange("bytes=-500");
console.log(range4);
// { unit: "bytes", ranges: [], suffix: 500 }