Skip to main content

Interface: ExternalArrayBuffer

A zero-copy ArrayBuffer that aliases native memory, returned by NativePointer.toArrayBuffer (and backing the Uint8Array from NativePointer.toUint8Array). It is a real ArrayBuffer — accepted anywhere one is — with one extra method.

Extends​

  • ArrayBuffer

Properties​

[toStringTag]​

readonly [toStringTag]: "ArrayBuffer"

Inherited from​

ArrayBuffer.[toStringTag]


byteLength​

readonly byteLength: number

Read-only. The length of the ArrayBuffer (in bytes).

Inherited from​

ArrayBuffer.byteLength

Methods​

detach()​

detach(): void

Detach the buffer, invalidating it and every view over it: afterwards its byteLength is 0, detached is true, and any TypedArray backed by it reads as empty.

Use this to make a view safe to keep after you free the native memory it aliased — it turns a potential use-after-free into a harmless empty buffer. Unlike ArrayBuffer.prototype.transfer(), it does not read or copy the underlying bytes, so it is safe to call once the memory is gone.

Returns​

void


slice()​

slice(begin?, end?): ArrayBuffer

Returns a section of an ArrayBuffer.

Parameters​

begin?​

number

end?​

number

Returns​

ArrayBuffer

Inherited from​

ArrayBuffer.slice