Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@httpland/accept-ranges-parser

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@httpland/accept-ranges-parser

HTTP Accept-Ranges header field parser

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
16
Maintainers
1
Weekly downloads
 
Created
Source

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> syntax.

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>"));

Serialization

Serialize string of array into string.

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

assertEquals(stringifyAcceptRanges(["bytes"]), "bytes");

Throwing error

Throws TypeError if the element contains invalid <range-unit> syntax.

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

assertThrows(() => stringifyAcceptRanges(["<invalid>", "none"]));

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

Keywords

FAQs

Package last updated on 29 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc