Skip to content

Commit 109fbd1

Browse files
authored
Add a newLength parameter to transferToImmutable (#17)
1 parent 366052a commit 109fbd1

File tree

2 files changed

+3
-12
lines changed

2 files changed

+3
-12
lines changed

README.md

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ The [OCapN](https://ocapn.org/) network protocol treats strings and byte-arrays
5454
## Solution
5555

5656
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
57-
- `transferToImmutable() :ArrayBuffer` -- move the contents of the original buffer into a new immutable buffer, detach the original buffer, and return the new buffer.
57+
- `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.
5858

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

133133

134-
<dt>
135-
136-
Should `transferToImmutable` support a `newByteLength` argument?
137-
</dt>
138-
<dd>
139-
https://github.com/tc39/proposal-immutable-arraybuffer/issues/15
140-
</dd>
141-
142-
143134
<dt>
144135

145136
Should ArrayBuffers support zero-copy slices (e.g., `arrayBuffer.sliceToImmutable()`)?

spec.emu

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -637,11 +637,11 @@ contributors: Mark S. Miller, Richard Gibson
637637
<ins class="block">
638638

639639
<emu-clause id="sec-arraybuffer.prototype.transfertoimmutable">
640-
<h1>ArrayBuffer.prototype.transferToImmutable ( )</h1>
640+
<h1>ArrayBuffer.prototype.transferToImmutable ( [ _newLength_ ] )</h1>
641641
<p>This method performs the following steps when called:</p>
642642
<emu-alg>
643643
1. Let _O_ be the *this* value.
644-
1. Return ? ArrayBufferCopyAndDetach(_O_, *undefined*, ~immutable~).
644+
1. Return ? ArrayBufferCopyAndDetach(_O_, _newLength_, ~immutable~).
645645
</emu-alg>
646646
</emu-clause>
647647
</ins>

0 commit comments

Comments
 (0)