Binary Data APIs

Ashley's avatar
Medal
Construct Team Founder
Published 12 Apr, 2019
164 words
<1 min

The built-in Array plugin SDK instance exposes the following APIs.

SetArrayBufferCopy(viewOrBuffer)

Set the contents of the Binary Data object by copying viewOrBuffer, which can be either an ArrayBuffer or a typed array.

SetArrayBufferTransfer(arrayBuffer)

Set the contents of the Binary Object by taking ownership of the passed ArrayBuffer. This avoids copying the data, but the caller must not use the passed ArrayBuffer any more.

GetArrayBufferCopy()

Return an ArrayBuffer which is a copy of the contents of the Binary Data object. Since a copy is returned the caller may modify the returned ArrayBuffer.

GetArrayBufferReadOnly()

Return a direct reference to the ArrayBuffer representing the contents of the Binary Data object. This must not be modified by the caller. However this avoids copying the data if used for read-only purposes, e.g. sending down a WebSocket.