getCookies
import { getCookies } from "jsr:@ende/http";function
function getCookies(headers: Headers): Partial<Record<string, string>>Parse cookies of a header
The returned object has a null prototype (so it does not inherit from
Object.prototype — properties like toString or hasOwnProperty will be
undefined rather than the inherited methods). The return type is
Partial<Record<string, string>> to reflect that arbitrary key access may
yield undefined when no cookie of that name was set.
headers: HeadersThe headers instance to get cookies from
Returns
Object with cookie names as keys (null-prototype). Values are
typed as string | undefined so missing-key access is caught at compile
time.
Example: Usage
import { getCookies } from "@ende/http/cookie";
import { assertEquals } from "@ende/assert";
const headers = new Headers();
headers.set("Cookie", "full=of; tasty=chocolate");
const cookies = getCookies(headers);
assertEquals(cookies.full, "of");
assertEquals(cookies.tasty, "chocolate");
assertEquals(cookies.missing, undefined);