@types/http-link-header
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

Installation

npm install --save @types/http-link-header

Summary

This package contains type definitions for http-link-header (https://github.com/jhermsmeier/node-http-link-header).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/http-link-header.

index.d.ts

/// <reference types="node" />

export = Link;

/**
 * Parse & format HTTP link headers according to RFC 8288
 */
declare class Link {
    /**
     * Creates a new Link by parsing a link header beginning at the provided
     * offset
     * @param value The header to parse
     * @param offset The offset to start at. Defaults to 0.
     * @return A new Link
     */
    static parse(value: string, offset?: number): Link;
    /**
     * Determines whether an encoding can be
     * natively handled with a `Buffer`
     */
    static isCompatibleEncoding(value: string): boolean;
    static isSingleOccurenceAttr(attr: string): boolean;
    static isTokenAttr(attr: string): boolean;
    static escapeQuotes(value: string): string;
    static formatExtendedAttribute(attr: string, data: Link.LinkData): string;
    /**
     * Format a given attribute and it's value
     */
    static formatAttribute(attr: string, value: string | Buffer | Array<string | Buffer>): string;
    /**
     * Link
     * @param value Link header to parse
     */
    constructor(value?: string);
    refs: Link.Reference[];
    has(attribute: string, value: string): boolean;
    /**
     * Get refs where the given attribute has a given value
     * @param attribute Attribute name
     * @param value Value to match
     * @return An array of references
     */
    get(attribute: string, value: string): Link.Reference[];
    /**
     * Get refs with given relation type
     * @param value The rel value
     * @return An array of references
     */
    rel(value: string): Link.Reference[];
    set(ref: Link.Reference): Link;
    /**
     * Parse a link header beginning at the provided offset
     * @param value The header to parse
     * @param offset The offset to start at. Defaults to 0.
     * @return The calling instance
     */
    parse(value: string, offset?: number): Link;
}

declare namespace Link {
    interface Reference {
        uri: string;
        rel: string;
        [index: string]: string;
    }

    interface LinkData {
        /** @default 'utf-8' */
        encoding?: string | undefined;
        /** @default 'en' */
        language?: string | undefined;
        value: string | Buffer;
    }
}

Additional Details

  • Last updated: Tue, 07 Nov 2023 03:09:37 GMT
  • Dependencies: @types/node

Credits

These definitions were written by Christian Rackerseder, Noah Loomans, Harris Lummis, and Piotr Błażejewicz.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/http-link-header

Weekly Downloads

29,905

Version

1.0.5

License

MIT

Unpacked Size

7.76 kB

Total Files

5

Last publish

Collaborators

  • types