Skip to content

[immutable-arraybuffer] ArrayBuffer.prototype.transferToImmutable #4542

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
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gibson042
Copy link
Contributor

Ref #4509

New ArrayBuffer.prototype properties

  • ArrayBuffer.prototype.transferToImmutable
    • verifyPrimordialCallableProperty(ArrayBuffer.prototype, "transferToImmutable", "transferToImmutable", 0);
    • brand-checking (throws TypeError unless receiver is an ArrayBuffer and not a SharedArrayBuffer), before coercing newLength
    • defaults newLength to [[ArrayBufferByteLength]]
    • if newLength is not undefined, casts it to an index (integral number from 0 to 2**53 - 1 inclusive) or throws a RangeError for out-of-range values, after brand-checking
    • throws TypeError if receiver is detached or immutable, after processing newLength (note the unusual receiver-after-argument order)
    • detaches the receiver
    • returns an immutable ArrayBuffer with the correct length
    • if newLength ≤ [[ArrayBufferByteLength]], returns an ArrayBuffer with contents matching the appropriate prefix of the receiver up to exclusive index newLength
    • if newLength > [[ArrayBufferByteLength]], returns an ArrayBuffer with contents matching those of the receiver, followed by the appropriate count of zeros

@gibson042 gibson042 requested a review from a team as a code owner July 18, 2025 22:28
@gibson042 gibson042 force-pushed the 2025-07-immutable-arraybuffer-transfertoimmutable branch from 397f433 to 1178b37 Compare July 31, 2025 16:32
@gibson042 gibson042 force-pushed the 2025-07-immutable-arraybuffer-transfertoimmutable branch 2 times, most recently from 54d4221 to 973e13e Compare August 1, 2025 01:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants