archives

« Bugzilla Issues Index

#3146 — Please add EnsureNonNeuteredArrayBuffer() common abstract operation


Many places in the spec want to check that something is a usable array buffer. We also want to do so for binary streams [1].

Currently this involves

1. If Type(O) is not Object, throw a TypeError exception.
2. If O does not have an [[ArrayBufferData]] internal slot throw a TypeError exception.
3. If the value of O’s [[ArrayBufferData]] internal slot is undefined, then throw a TypeError exception.
4. If IsNeuteredBuffer(O) is true, then throw a TypeError exception.

It would be great to abstract this into

1. ReturnIfAbrupt(EnsureNonNeuteredArrayBuffer(O))

(or, in promise-using specs, RejectIfAbrupt(EnsureNonNeuteredArrayBuffer(O), capability).)

[1]: https://github.com/whatwg/streams/pull/173


Step 3 is no longer necessary and a routine doing this would still require two steps to call it and check for the exception, and the difference between two and three steps isn't that great.

Plus, it turns out that now there aren't very many (3-5) places that need to use this exact sequence.

So, I'm not going to bother with it this time around.