Skip to content

Add a newLength parameter to transferToImmutable #17

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

Merged
merged 2 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ The [OCapN](https://ocapn.org/) network protocol treats strings and byte-arrays
## Solution

This proposal introduces additional methods and read-only accessor properties to `ArrayBuffer.prototype` that fit naturally into those explained above. Just as a buffer can be resizable or not, and detached or not, this proposal enables buffers to be immutable or not. Just as `transferToFixedSize` moves the contents of a original buffer into a newly created non-resizable buffer, this proposal provides a transfer operation that moves the contents of an original original buffer into a newly created immutable buffer. Altogether, this proposal only adds to `ArrayBuffer.prototype` one method
- `transferToImmutable() :ArrayBuffer` -- move the contents of the original buffer into a new immutable buffer, detach the original buffer, and return the new buffer.
- `transferToImmutable(newByteLength?: number) :ArrayBuffer` -- move the contents of the original buffer into a new immutable buffer, detach the original buffer, and return the new buffer.

and one read-only accessor
- `immutable: boolean` -- is this buffer immutable, or can its contents be changed?
Expand Down Expand Up @@ -131,15 +131,6 @@ No, TypedArray index properties should continue to track the state of the underl
</dd>


<dt>

Should `transferToImmutable` support a `newByteLength` argument?
</dt>
<dd>
https://github.com/tc39/proposal-immutable-arraybuffer/issues/15
</dd>


<dt>

Should ArrayBuffers support zero-copy slices (e.g., `arrayBuffer.sliceToImmutable()`)?
Expand Down
4 changes: 2 additions & 2 deletions spec.emu
Original file line number Diff line number Diff line change
Expand Up @@ -637,11 +637,11 @@ contributors: Mark S. Miller, Richard Gibson
<ins class="block">

<emu-clause id="sec-arraybuffer.prototype.transfertoimmutable">
<h1>ArrayBuffer.prototype.transferToImmutable ( )</h1>
<h1>ArrayBuffer.prototype.transferToImmutable ( [ _newLength_ ] )</h1>
<p>This method performs the following steps when called:</p>
<emu-alg>
1. Let _O_ be the *this* value.
1. Return ? ArrayBufferCopyAndDetach(_O_, *undefined*, ~immutable~).
1. Return ? ArrayBufferCopyAndDetach(_O_, _newLength_, ~immutable~).
</emu-alg>
</emu-clause>
</ins>
Expand Down
Loading