feat(codemode): add the Headers built-in - #49280
Open
rekram1-node wants to merge 3 commits into
Open
rekram1-node wants to merge 3 commits into
rekram1-node wants to merge 3 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First of the fetch types (
Headers, thenResponse, thenRequest), each its own PR. A program object wrapping the host'sHeaders, the same wayURLandURLSearchParamswrap theirs: Bun validates, normalizes, folds case, combines values, and orders iteration; the runtime only converts at the edges.src/stdlib/ + headers.ts 118 lines: constructor, methods, host TypeError → program TypeError url.ts readPairs(ctx, init, label) shared with URLSearchParams (was inline) src/interpreter/ objects.ts HeadersObj, isWrapper intrinsics.ts Headers prototype interpreter.ts iterate / yield* over Headers extensions.ts toHost / fromHost src/stdlib/console.ts, value.ts, data.ts, references.ts printing, coercion, JSON, describeLeft out on purpose:
Symbol.iterator(no custom Symbols), iterator objects fromkeys()/values()/entries()(arrays, as withURLSearchParams).Tests
test/stdlib.test.ts: construction, mutation, iteration everywhere, serialization, every error path.test/extensions.test.ts: Headers cross as copies in both directions.test/web-wpt.test.ts: sixfetch/api/headers/*.any.jsfiles adapted near-verbatim over a smalltestharness.jsshim, attributed in the header. Two set-cookie cases dropped because Bun's ownHeaderssortsset-cookie2ahead ofset-cookie.packages/codemodebun testbun run checkinterpreter-support.mdupdated;Request,Response,Bloblisted as open.README
Second commit. The
Valuessection described an export that no longer exists; it is now anExtension.makesection, which thehooksparagraph already referred to without introducing. The "differs from JavaScript" bullet no longer saysfetchis unavailable, since a host may add it.