Skip to content

Commit

Permalink
fixup! util: add isArrayBufferDetached method
Browse files Browse the repository at this point in the history
  • Loading branch information
anonrig committed Nov 21, 2022
1 parent 82d44f4 commit 320ce8b
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions doc/api/util.md
Original file line number Diff line number Diff line change
Expand Up @@ -2034,15 +2034,18 @@ added: REPLACEME
* Returns: {boolean}
Returns `true` if the value is a built-in [`ArrayBuffer`][] and
is detached. Detached arrays have a byte length of 0, which prevents
JavaScript from ever accessing underlying backing store.
For example, we can end up with a detached buffer when using a BYOB
(bring your own buffer) on a ReadableStream.
is detached. For example, we can end up with a detached buffer
when using a BYOB (bring your own buffer) on a ReadableStream.
Detached arrays have a `byteLength` of 0, and their contents can
not be accessed in JavaScript.
```js
util.types.isArrayBufferDetached(null); // Returns false
util.types.isArrayBufferDetached(new ArrayBuffer()); // Returns false

const { buffer } = new Uint8Array([1, 2, 3]);
new MessageChannel().port1.postMessage('', [buffer]);
util.types.isArrayBufferDetached(buffer); // Returns true
```
### `util.types.isArrayBufferView(value)`
Expand Down

0 comments on commit 320ce8b

Please sign in to comment.