JsBinaryData Class

Access to the bytes of the buffer sources (ArrayBuffer, SharedArrayBuffer, DataView and the typed arrays), without running JavaScript code.

public static class JsBinaryData

Methods

NameDescription
DetachArrayBuffer(JsValue, JsValue)Detaches an ArrayBuffer (DetachArrayBuffer(buffer, key)); the key is its [[ArrayBufferDetachKey]].
GetSharedDataBlock(JsValue)Gets the Shared Data Block of a SharedArrayBuffer, which JsRealm.CreateSharedArrayBuffer can share with a buffer of another engine (on another thread); null for the other values.
IsResizable(JsValue)Gets whether a buffer source is backed by a resizable ArrayBuffer or a growable SharedArrayBuffer: the buffer itself, or the buffer that a typed array or a DataView views (IsFixedLengthArrayBuffer is false). Returns false for the other values.
TryGetBufferSource(JsValue, JsBufferKind, bool, Memory<byte>)Gets the kind and the bytes of a buffer source. bytes is a view of the data block of the buffer (the writes are visible to JavaScript); it is empty when the buffer is detached or the view is out of bounds. Returns false for the other values.

DetachArrayBuffer(JsValue, JsValue)

JsBinaryData.cs

Detaches an ArrayBuffer (DetachArrayBuffer(buffer, key)); the key is its [[ArrayBufferDetachKey]].

public static void DetachArrayBuffer(JsValue arrayBuffer, JsValue key = default)

Parameters

arrayBuffer JsValue
key JsValue

Exceptions

ArgumentException
The value is not an ArrayBuffer.
JsException
The key is not the detach key of the buffer (a TypeError).

GetSharedDataBlock(JsValue)

JsBinaryData.cs

Gets the Shared Data Block of a SharedArrayBuffer, which JsRealm.CreateSharedArrayBuffer can share with a buffer of another engine (on another thread); null for the other values.

public static JsSharedDataBlock? GetSharedDataBlock(JsValue value)

Parameters

value JsValue

Returns

JsSharedDataBlock?

IsResizable(JsValue)

JsBinaryData.cs

Gets whether a buffer source is backed by a resizable ArrayBuffer or a growable SharedArrayBuffer: the buffer itself, or the buffer that a typed array or a DataView views (IsFixedLengthArrayBuffer is false). Returns false for the other values.

public static bool IsResizable(JsValue value)

Parameters

value JsValue

Returns

bool

TryGetBufferSource(JsValue, JsBufferKind, bool, Memory<byte>)

JsBinaryData.cs

Gets the kind and the bytes of a buffer source. bytes is a view of the data block of the buffer (the writes are visible to JavaScript); it is empty when the buffer is detached or the view is out of bounds. Returns false for the other values.

public static bool TryGetBufferSource(JsValue value, out JsBufferKind kind, out bool isShared, out Memory<byte> bytes)

Parameters

value JsValue
kind JsBufferKind
isShared bool
bytes Memory<byte>

Returns

bool