@hugoalh/http-header-link v1.0.1
HTTP Header Link (ES)
An ES (JavaScript & TypeScript) module to handle HTTP header Link
according to RFC 8288 standard.
đ¯ Target
- Bun ^ v1.0.0
- Cloudflare Workers
- Deno >= v1.34.0 / >= v1.41.1 (For JSR Only)
đĄī¸ Require Permission
N/A
- NodeJS >= v16.13.0
đ° Usage
Via JSR With node_modules
đ¯ Supported Target
- Bun
- Cloudflare Workers
- NodeJS
- Install via:
- Bun
bunx jsr add @hugoalh/http-header-link[@${Tag}]
- NPM
npx jsr add @hugoalh/http-header-link[@${Tag}]
- PNPM
pnpm dlx jsr add @hugoalh/http-header-link[@${Tag}]
- Yarn
yarn dlx jsr add @hugoalh/http-header-link[@${Tag}]
- Bun
- Import at the script:
import ... from "@hugoalh/http-header-link";
âšī¸ Note
- Although it is recommended to import the entire module, it is also able to import part of the module with sub path if available, please visit file
jsr.jsonc
propertyexports
for available sub paths.- It is recommended to import the module with tag for immutability.
Via JSR With Specifier
đ¯ Supported Target
- Deno
- Import at the script:
import ... from "jsr:@hugoalh/http-header-link[@${Tag}]";
âšī¸ Note
- Although it is recommended to import the entire module, it is also able to import part of the module with sub path if available, please visit file
jsr.jsonc
propertyexports
for available sub paths.- It is recommended to import the module with tag for immutability.
Via NPM With node_modules
đ¯ Supported Target
- Cloudflare Workers
- NodeJS
- Install via:
- NPM
npm install @hugoalh/http-header-link[@${Tag}]
- PNPM
pnpm add @hugoalh/http-header-link[@${Tag}]
- Yarn
yarn add @hugoalh/http-header-link[@${Tag}]
- NPM
- Import at the script:
import ... from "@hugoalh/http-header-link";
âšī¸ Note
- Although it is recommended to import the entire module, it is also able to import part of the module with sub path if available, please visit file
jsr.jsonc
propertyexports
for available sub paths.- It is recommended to import the module with tag for immutability.
Via NPM With Specifier
đ¯ Supported Target
- Bun
- Deno
- Import at the script:
import ... from "npm:@hugoalh/http-header-link[@${Tag}]";
âšī¸ Note
- Although it is recommended to import the entire module, it is also able to import part of the module with sub path if available, please visit file
jsr.jsonc
propertyexports
for available sub paths.- It is recommended to import the module with tag for immutability.
Via Remote Import
đ¯ Supported Target
- Deno
- Import at the script:
/* Via GitHub Raw (Require Tag) */ import ... from "https://raw.githubusercontent.com/hugoalh-studio/http-header-link-es/${Tag}/mod.ts";
âšī¸ Note
Although it is recommended to import the entire module with the main path
mod.ts
, it is also able to import part of the module with sub path if available, but do not import if:
- it's file path has an underscore prefix (e.g.:
_foo.ts
,_util/bar.ts
), or- it is a benchmark or test file (e.g.:
foo.bench.ts
,foo.test.ts
), or- it's symbol has an underscore prefix (e.g.:
export function _baz() {}
).These elements are not considered part of the public API, thus no stability is guaranteed for them.
Although there have 3rd party services which provide enhanced, equal, or similar methods/ways to remote import the module, beware these services maybe inject unrelated elements and thus affect the security.
𧊠API
class HTTPHeaderLink { constructor(value?: string | Headers | HTTPHeaderLink | HTTPHeaderLinkEntry[] | Response): HTTPHeaderLink; add(value: string | Headers | HTTPHeaderLink | HTTPHeaderLinkEntry[] | Response): this; entries(): HTTPHeaderLinkEntry[]; getByParameter(key: string, value: string): HTTPHeaderLinkEntry[]; getByRel(value: string): HTTPHeaderLinkEntry[]; hasParameter(key: string, value: string): boolean; toString(): string; static parse(value: string | Headers | HTTPHeaderLink | Response): HTTPHeaderLink; static stringify(value: HTTPHeaderLinkEntry[]): string; }
type HTTPHeaderLinkEntry = [ uri: string, parameters: { [key: string]: string; } ];
âšī¸ Note
For the prettier documentation, can visit via:
âī¸ Example
new HTTPHeaderLink(`<https://example.com>; rel="preconnect"`); /*=> HTTPHeaderLink [ ["https://example.com", { rel: "preconnect" }] ] */
new HTTPHeaderLink(`<https://example.com/%E8%8B%97%E6%9D%A1>; rel="preconnect"`); /*=> HTTPHeaderLink [ ["https://example.com/čæĄ", { rel: "preconnect" }] ] */