Get the total number of headers
Symbol
__internal
namespace __internal
interface BunHeadersOverride
Get all headers matching the name
Only supports
"Set-Cookie"
. All other headers are empty arrays.@param nameThe header name to get
@returnsAn array of header values
const headers = new Headers(); headers.append("Set-Cookie", "foo=bar"); headers.append("Set-Cookie", "baz=qux"); headers.getAll("Set-Cookie"); // ["foo=bar", "baz=qux"]
Convert Headers to a plain JavaScript object.
About 10x faster than
Object.fromEntries(headers.entries())
Called when you run
JSON.stringify(headers)
Does not preserve insertion order. Well-known header names are lowercased. Other header names are left as-is.
interface BunRequestOverride
interface BunResponseOverride
- type LibDomIsLoaded = typeof globalThis extends { onabort: any } ? true : false
- type LibEmptyOrBunWebSocket = LibDomIsLoaded extends true ? {} : Bun.WebSocket
- type LibEmptyOrNodeMessagePort = LibDomIsLoaded extends true ? {} : MessagePort
- type LibEmptyOrNodeReadableStream<T> = LibDomIsLoaded extends true ? {} : ReadableStream
- type LibEmptyOrNodeUtilTextDecoder = LibDomIsLoaded extends true ? {} : TextDecoder
- type LibEmptyOrNodeUtilTextEncoder = LibDomIsLoaded extends true ? {} : TextEncoder
- type LibEmptyOrNodeWritableStream<T> = LibDomIsLoaded extends true ? {} : WritableStream
- type LibOrFallbackHeaders = LibDomIsLoaded extends true ? {} : Headers
- type LibOrFallbackRequest = LibDomIsLoaded extends true ? {} : Request
- type LibOrFallbackRequestInit = LibDomIsLoaded extends true ? {} : Omit<RequestInit, 'body' | 'headers'> & { body: Bun.BodyInit | null; headers: Bun.HeadersInit }
- type LibOrFallbackResponse = LibDomIsLoaded extends true ? {} : Response
- type LibOrFallbackResponseInit = LibDomIsLoaded extends true ? {} : ResponseInit
- type LibPerformanceOrNodePerfHooksPerformance = Bun.__internal.UseLibDomIfAvailable<'Performance', Performance>
- type LibWorkerOrBunWorker = Bun.__internal.UseLibDomIfAvailable<'Worker', Bun.Worker>
- type NodeCryptoWebcryptoCryptoKey = webcrypto.CryptoKey
- type NodeCryptoWebcryptoSubtleCrypto = webcrypto.SubtleCrypto
- type NodeWorkerThreadsWorker = Worker
- type UseLibDomIfAvailable<GlobalThisKeyName extends PropertyKey, Otherwise> = LibDomIsLoaded extends true ? typeof globalThis extends { [K in GlobalThisKeyName]: infer T } ? T : Otherwise : Otherwise
Helper type for avoiding conflicts in types.
Uses the lib.dom.d.ts definition if it exists, otherwise defines it locally.
This is to avoid type conflicts between lib.dom.d.ts and @types/bun.
Unfortunately some symbols cannot be defined when both Bun types and lib.dom.d.ts types are loaded, and since we can't redeclare the symbol in a way that satisfies both, we need to fallback to the type that lib.dom.d.ts provides.