diff --git a/README.md b/README.md index 35fad70..e893976 100644 --- a/README.md +++ b/README.md @@ -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? @@ -131,15 +131,6 @@ No, TypedArray index properties should continue to track the state of the underl -
- -Should `transferToImmutable` support a `newByteLength` argument? -
-
-https://github.com/tc39/proposal-immutable-arraybuffer/issues/15 -
- -
Should ArrayBuffers support zero-copy slices (e.g., `arrayBuffer.sliceToImmutable()`)? diff --git a/spec.emu b/spec.emu index b8b6332..3f98c05 100644 --- a/spec.emu +++ b/spec.emu @@ -637,11 +637,11 @@ contributors: Mark S. Miller, Richard Gibson -

ArrayBuffer.prototype.transferToImmutable ( )

+

ArrayBuffer.prototype.transferToImmutable ( [ _newLength_ ] )

This method performs the following steps when called:

1. Let _O_ be the *this* value. - 1. Return ? ArrayBufferCopyAndDetach(_O_, *undefined*, ~immutable~). + 1. Return ? ArrayBufferCopyAndDetach(_O_, _newLength_, ~immutable~).