Repository navigation
aot: describe the results of util.parseArgs and HTMLRewriter.prototype.transform
#48325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
robobun
wants to merge
6
commits into
main
Choose a base branch
from
robobun/c22a3cbd/describe-results-of-parse-args-and-transform
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+261
−4
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2beefb4
aot: describe what util.parseArgs, Bun.argv and HTMLRewriter.prototyp…
robobun 97b9f92
test/aot: transform a Response of a Blob and of a file in trimmed-is-…
robobun f135bd9
aot: leave the row of Bun.argv as it is
robobun 67d29c0
test/aot: print the body that each conversion of the file section ans…
robobun cee284f
aot: the row of parseArgs says that an element of args comes back as …
robobun 63ee779
test/aot: a program holds what parseArgs hands back of its operands t…
robobun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,12 @@ | ||
| import * as b from "../../../codegen/bindgen-lib.ts"; | ||
| import * as table from "../../../codegen/builtins/lib.ts"; | ||
|
|
||
| export default b.module({ rustPath: "crate::node::util::parse_args" }); | ||
|
|
||
| export const parseArgs = b.fn({ args: { config: b.any }, returns: b.any, capability: "js", throws: true }); | ||
| /** New objects and lists, `values` without a prototype. An element of `args` and a `default` come back as the program handed them in, of whatever class. */ | ||
| export const parseArgs = b.fn({ | ||
| args: { config: b.any }, | ||
| returns: b.any.returning(table.anyMadeOf("Object", "Array").spec), | ||
| capability: "js", | ||
| throws: true, | ||
| }); |
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
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
46 changes: 46 additions & 0 deletions
46
...hat-native-code-answers-is-of-the-class-that-its-row-names/what-parse-args-hands-back.mjs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| // util.parseArgs hands back an element of `args` and a `default` as the program made them: the same object, of whatever class, with its members. | ||
| import { parseArgs } from "node:util"; | ||
| class Path { | ||
| toString() { | ||
| return "a/b"; | ||
| } | ||
| parts() { | ||
| return `${this}`.split("/"); | ||
| } | ||
| } | ||
| class Words extends Array { | ||
| shout() { | ||
| return this.map(word => word.toUpperCase()); | ||
| } | ||
| } | ||
| const said = []; | ||
| for (let turn = 0; turn < 30; turn++) { | ||
| said.length = 0; | ||
| const path = new Path(); | ||
| const url = new URL("http://host/a?b=1"); | ||
| const bytes = new Uint8Array([1, 2, 3]); | ||
| const words = Words.of("p", "q"); | ||
| const operands = [path, url, bytes, turn]; | ||
| const { values, positionals, tokens } = parseArgs({ | ||
| args: [path, "--name", url, "--", bytes, turn], | ||
| options: { name: { type: "string" }, listed: { type: "string", multiple: true, default: words } }, | ||
| strict: false, | ||
| allowPositionals: true, | ||
| tokens: true, | ||
| }); | ||
| said.push( | ||
| positionals[0] === path, | ||
| positionals[0].parts().join(), | ||
| values.name === url, | ||
| values.name.searchParams.get("b"), | ||
| ); | ||
| said.push(positionals[1] === bytes, positionals[1].byteLength, typeof positionals[2], positionals[2] === turn); | ||
| said.push( | ||
| values.listed === words, | ||
| values.listed.shout().join(), | ||
| Object.getPrototypeOf(values) === null, | ||
| Array.isArray(positionals), | ||
| ); | ||
| said.push(tokens.map(token => `${token.kind}:${token.index}:${operands.indexOf(token.value)}`).join(" ")); | ||
| } | ||
| console.log(said.join(" ")); |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.