Bun

class

CookieMap

class CookieMap

A Map-like interface for working with collections of cookies.

Implements the Iterable interface, allowing use with for...of loops.

  • readonly size: number

    The number of cookies in the map.

  • [Symbol.iterator](): IterableIterator<[string, string]>;

    Returns the default iterator for the CookieMap. Used by for...of loops to iterate over all entries.

    @returns

    An iterator for the entries in the map

  • name: string
    ): void;

    Removes a cookie from the map.

    @param name

    The name of the cookie to delete

    ): void;

    Removes a cookie from the map.

    @param options

    The options for the cookie to delete

    name: string,
    options: Omit<CookieStoreDeleteOptions, 'name'>
    ): void;

    Removes a cookie from the map.

    @param name

    The name of the cookie to delete

    @param options

    The options for the cookie to delete

  • entries(): IterableIterator<[string, string]>;

    Returns an iterator of [name, value] pairs for every cookie in the map.

    @returns

    An iterator for the entries in the map

  • callback: (value: string, key: string, map: CookieMap) => void
    ): void;

    Executes a provided function once for each cookie in the map.

    @param callback

    Function to execute for each entry

  • name: string
    ): null | string;

    Gets the value of a cookie with the specified name.

    @param name

    The name of the cookie to retrieve

    @returns

    The cookie value as a string, or null if the cookie doesn't exist

  • name: string
    ): boolean;

    Checks if a cookie with the given name exists.

    @param name

    The name of the cookie to check

    @returns

    true if the cookie exists, false otherwise

  • keys(): IterableIterator<string>;

    Returns an iterator of all cookie names in the map.

    @returns

    An iterator for the cookie names

  • name: string,
    value: string,
    options?: CookieInit
    ): void;

    Adds or updates a cookie in the map.

    @param name

    The name of the cookie

    @param value

    The value of the cookie

    @param options

    Optional cookie attributes

    options: CookieInit
    ): void;

    Adds or updates a cookie in the map using a cookie options object.

    @param options

    Cookie options including name and value

  • toJSON(): Record<string, string>;

    Converts the cookie map to a serializable format.

    @returns

    An array of name/value pairs

  • toSetCookieHeaders(): string[];

    Gets an array of values for Set-Cookie headers in order to apply all changes to cookies.

    @returns

    An array of values for Set-Cookie headers

  • values(): IterableIterator<string>;

    Returns an iterator of all cookie values in the map.

    @returns

    An iterator for the cookie values