Class WrakerHeaders

A class that extends the native Map to handle HTTP headers with case-insensitive keys.

const headers = new WrakerHeaders({
"Content-Type": "application/json",
});

headers.get("content-type"); // "application/json"
headers.has("content-type"); // true
headers.has("Content-Type"); // true

Hierarchy

  • Map<string, string>
    • WrakerHeaders

Constructors

  • Creates an instance of WrakerHeaders.

    Parameters

    • Optionalentries: null | Record<string, string>

      An optional record of key-value pairs to initialize the headers.

    Returns WrakerHeaders

Properties

[toStringTag]: string
size: number

the number of elements in the Map.

[species]: MapConstructor

Methods

  • Returns an iterable of entries in the map.

    Returns MapIterator<[string, string]>

  • Returns void

  • Deletes a header with the given name.

    Parameters

    • name: string

      The name of the header.

    Returns boolean

    True if the header was deleted, false otherwise.

  • Returns an iterable of key, value pairs for every entry in the map.

    Returns MapIterator<[string, string]>

  • Executes a provided function once per each key/value pair in the Map, in insertion order.

    Parameters

    • callbackfn: ((value: string, key: string, map: Map<string, string>) => void)
        • (value, key, map): void
        • Parameters

          • value: string
          • key: string
          • map: Map<string, string>

          Returns void

    • OptionalthisArg: any

    Returns void

  • Retrieves the value associated with the given header name.

    Parameters

    • name: string

      The name of the header.

    Returns any

    The value of the header, or undefined if the header does not exist.

  • Checks if a header with the given name exists.

    Parameters

    • name: string

      The name of the header.

    Returns boolean

    True if the header exists, false otherwise.

  • Returns an iterable of keys in the map

    Returns MapIterator<string>

  • Serializes the headers into a plain object.

    Returns Record<string, string>

    A record containing all headers as key-value pairs.

  • Sets the value for a given header name.

    Parameters

    • name: string

      The name of the header.

    • value: any

      The value to set for the header.

    Returns this

    The WrakerHeaders instance.

  • Returns an iterable of values in the map

    Returns MapIterator<string>