Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ayonli_jsext/http.ts>parseRange

A JavaScript extension package for building strong and modern applications.
Latest
function parseRange
Re-export
import { parseRange } from "https://deno.land/x/ayonli_jsext@v0.9.72/http.ts";

Parses the Range header.

Examples

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 }

Parameters

str: string

Returns

Range