Repository navigation
node:buffer: define Buffer.of as an own static that never reads this
#45865
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
9
commits into
main
Choose a base branch
from
robobun/a0a8b7bd/buffer-of-own-static
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.
+204
−2
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f71a953
node:buffer: define Buffer.of as an own static that never reads `this`
robobun 7574761
ci: retrigger
robobun f12288f
Merge remote-tracking branch 'origin/main' into robobun/a0a8b7bd/buff…
robobun 20744b6
codegen: list Buffer.of in own-properties.txt
robobun 71a1c5a
test(aot): Buffer.of is a member of Buffer in the program about locke…
robobun 3ba4afe
codegen: declare Buffer.of in the table of built-ins
robobun 6b3e5b5
Merge branch 'main' into robobun/a0a8b7bd/buffer-of-own-static
robobun 72391dc
Merge branch 'main' into robobun/a0a8b7bd/buffer-of-own-static
robobun 367f42f
Merge branch 'main' into robobun/a0a8b7bd/buffer-of-own-static
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
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
25 changes: 25 additions & 0 deletions
25
test/aot/parallel/builtin-modules/buffer-of-with-every-sort-of-operand-and-receiver.js
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,25 @@ | ||
| // Buffer.of makes a Buffer of its operands whatever its receiver is: it converts each operand in order, ends at the first conversion that throws, and constructs nothing through the receiver. | ||
| const show = made => `${made instanceof Buffer} ${Object.getPrototypeOf(made) === Buffer.prototype} ${made.length} ${made.toString("hex")}`; | ||
| const ran = []; | ||
| const counted = (name, value) => ({ valueOf() { ran.push(name); return value; } }); | ||
| console.log(show(Buffer.of()), show(Buffer.of(1, 2, 3)), show(Buffer.of(1.9, -1, 300, NaN, "16", "0x10", true, null, undefined))); | ||
| const hinted = { [Symbol.toPrimitive](hint) { ran.push(hint); return 3; } }; | ||
| const spelled = { valueOf: undefined, toString() { ran.push("toString"); return "4"; } }; | ||
| console.log(show(Buffer.of(counted("a", 1), counted("b", 2), hinted, spelled)), ran.join()); | ||
| const { of } = Buffer; | ||
| console.log(show(of(5, 6)), show(Buffer.of.call(Uint8Array, 7)), show(Buffer.of.call(null, 8)), show(Reflect.apply(Buffer.of, undefined, [9]))); | ||
| console.log([65, 66].map(Buffer.of).map(show).join(", "), Object.hasOwn(Buffer, "of"), Buffer.of === Uint8Array.of, Buffer.of.length, Buffer.of.name); | ||
| let constructed = 0; | ||
| class Packet extends Buffer { constructor(...operands) { constructed++; super(...operands); } } | ||
| console.log(show(Packet.of(1, 2)), Packet.of === Buffer.of, constructed); | ||
| for (const refused of [Symbol("s"), 1n, { valueOf() { throw new RangeError("thrown by valueOf"); } }]) { | ||
| ran.length = 0; | ||
| try { console.log(show(Buffer.of(counted("before", 1), refused, counted("after", 2)))); } catch (error) { console.log(error.name, ran.join()); } | ||
| } | ||
| function total() { | ||
| let sum = 0; | ||
| for (let i = 0; i < 300; i++) { const made = Buffer.of(i, i >> 1, counted("in the loop", i)); sum += made[0] + made[1] + made[2] + made.length; } | ||
| return sum; | ||
| } | ||
| ran.length = 0; | ||
| console.log(total(), ran.length, total(), ran.length); |
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.