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

accept-ranges-parser

deno land deno doc GitHub release (latest by date) codecov GitHub

test NPM

HTTP Accept-Ranges header field parser.

Compliant with RFC 9110, 14.3. Accept-Ranges.

Deserialization

Parses string into AcceptRanges.

import { parseAcceptRanges } from "https://deno.land/x/accept_ranges_parser@$VERSION/parse.ts";
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";

assertEquals(parseAcceptRanges(`none`), ["none"]);
assertEquals(parseAcceptRanges(`bytes, unknown`), ["bytes", "unknown"]);

Throwing error

Throws SyntaxError if the input is invalid <Accept-Ranges>.

import { parseAcceptRanges } from "https://deno.land/x/accept_ranges_parser@$VERSION/parse.ts";
import { assertThrows } from "https://deno.land/std/testing/asserts.ts";

assertThrows(() => parseAcceptRanges("<invalid>"));

AcceptRanges

AcceptRanges is a subtype of array with the following characteristics.

  • It has one or more elements.
  • The elements are Token.

Token

Represents a character set that compliant with RFC 9110, 5.6.2. Tokens as much as possible.

API

All APIs can be found in the deno doc.

License

Copyright © 2023-present httpland.

Released under the MIT license