Companion¶
=== "common"
=== "android"
=== "jvm"
=== "native"
=== "web"
expect object Companion
actual object Companion
actual object Companion
actual object Companion
actual object Companion
Functions¶
allocate¶
=== "common"
=== "android"
=== "jvm"
=== "native"
=== "web"
expect fun allocate(sizeInBytes: ULong): ArrayBuffer
actual fun allocate(sizeInBytes: ULong): ArrayBuffer
actual fun allocate(sizeInBytes: ULong): ArrayBuffer
actual fun allocate(sizeInBytes: ULong): ArrayBuffer
actual fun allocate(sizeInBytes: ULong): ArrayBuffer
=== "common"
Allocates a new ArrayBuffer with the specified size in bytes. The buffer is zero-initialized and memory is managed automatically.
**Return**
a new ArrayBuffer with the specified size
=== "android"
Allocates a new ArrayBuffer with the specified size in bytes. The buffer is zero-initialized and memory is managed automatically.
**Return**
a new ArrayBuffer with the specified size
=== "jvm"
Allocates a new ArrayBuffer with the specified size in bytes. The buffer is zero-initialized and memory is managed automatically.
**Return**
a new ArrayBuffer with the specified size
=== "native"
Allocates a new ArrayBuffer with the specified size in bytes. The buffer is zero-initialized and memory is managed automatically.
**Return**
a new ArrayBuffer with the specified size
=== "web"
Allocates a new ArrayBuffer with the specified size in bytes. The buffer is zero-initialized and memory is managed automatically.
**Return**
a new ArrayBuffer with the specified size
=== "common, android, jvm, native, web"
**Parameters**
- sizeInBytes: the size of the buffer in bytes
- sizeInBytes: the size of the buffer in bytes
- sizeInBytes: the size of the buffer in bytes
- sizeInBytes: the size of the buffer in bytes
- sizeInBytes: the size of the buffer in bytes
of¶
=== "common"
=== "android"
=== "jvm"
=== "native"
=== "web"
expect fun of(array: ByteArray): ArrayBuffer
actual fun of(array: ByteArray): ArrayBuffer
actual fun of(array: ByteArray): ArrayBuffer
actual fun of(array: ByteArray): ArrayBuffer
actual fun of(array: ByteArray): ArrayBuffer
=== "common"
Creates an ArrayBuffer from a ByteArray.
**Return**
an ArrayBuffer containing the data from the byte array
=== "android"
Creates an ArrayBuffer from a ByteArray.
**Return**
an ArrayBuffer containing the data from the byte array
=== "jvm"
Creates an ArrayBuffer from a ByteArray.
**Return**
an ArrayBuffer containing the data from the byte array
=== "native"
Creates an ArrayBuffer from a ByteArray.
**Return**
an ArrayBuffer containing the data from the byte array
=== "web"
Creates an ArrayBuffer from a ByteArray.
**Return**
an ArrayBuffer containing the data from the byte array
=== "common, android, jvm, native, web"
**Parameters**
- array: the byte array to convert
- array: the byte array to convert
- array: the byte array to convert
- array: the byte array to convert
- array: the byte array to convert
=== "common"
=== "android"
=== "jvm"
=== "native"
=== "web"
expect fun of(array: ShortArray): ArrayBuffer
actual fun of(array: ShortArray): ArrayBuffer
actual fun of(array: ShortArray): ArrayBuffer
actual fun of(array: ShortArray): ArrayBuffer
actual fun of(array: ShortArray): ArrayBuffer
=== "common"
Creates an ArrayBuffer from a ShortArray.
**Return**
an ArrayBuffer containing the data from the short array
=== "android"
Creates an ArrayBuffer from a ShortArray.
**Return**
an ArrayBuffer containing the data from the short array
=== "jvm"
Creates an ArrayBuffer from a ShortArray.
**Return**
an ArrayBuffer containing the data from the short array
=== "native"
Creates an ArrayBuffer from a ShortArray.
**Return**
an ArrayBuffer containing the data from the short array
=== "web"
Creates an ArrayBuffer from a ShortArray.
**Return**
an ArrayBuffer containing the data from the short array
=== "common, android, jvm, native, web"
**Parameters**
- array: the short array to convert
- array: the short array to convert
- array: the short array to convert
- array: the short array to convert
- array: the short array to convert
=== "common"
=== "android"
=== "jvm"
=== "native"
=== "web"
expect fun of(array: IntArray): ArrayBuffer
actual fun of(array: IntArray): ArrayBuffer
actual fun of(array: IntArray): ArrayBuffer
actual fun of(array: IntArray): ArrayBuffer
actual fun of(array: IntArray): ArrayBuffer
=== "common"
Creates an ArrayBuffer from an IntArray.
**Return**
an ArrayBuffer containing the data from the int array
=== "android"
Creates an ArrayBuffer from an IntArray.
**Return**
an ArrayBuffer containing the data from the int array
=== "jvm"
Creates an ArrayBuffer from an IntArray.
**Return**
an ArrayBuffer containing the data from the int array
=== "native"
Creates an ArrayBuffer from an IntArray.
**Return**
an ArrayBuffer containing the data from the int array
=== "web"
Creates an ArrayBuffer from an IntArray.
**Return**
an ArrayBuffer containing the data from the int array
=== "common, android, jvm, native, web"
**Parameters**
- array: the int array to convert
- array: the int array to convert
- array: the int array to convert
- array: the int array to convert
- array: the int array to convert
=== "common"
=== "android"
=== "jvm"
=== "native"
=== "web"
expect fun of(array: FloatArray): ArrayBuffer
actual fun of(array: FloatArray): ArrayBuffer
actual fun of(array: FloatArray): ArrayBuffer
actual fun of(array: FloatArray): ArrayBuffer
actual fun of(array: FloatArray): ArrayBuffer
=== "common"
Creates an ArrayBuffer from a FloatArray.
**Return**
an ArrayBuffer containing the data from the float array
=== "android"
Creates an ArrayBuffer from a FloatArray.
**Return**
an ArrayBuffer containing the data from the float array
=== "jvm"
Creates an ArrayBuffer from a FloatArray.
**Return**
an ArrayBuffer containing the data from the float array
=== "native"
Creates an ArrayBuffer from a FloatArray.
**Return**
an ArrayBuffer containing the data from the float array
=== "web"
Creates an ArrayBuffer from a FloatArray.
**Return**
an ArrayBuffer containing the data from the float array
=== "common, android, jvm, native, web"
**Parameters**
- array: the float array to convert
- array: the float array to convert
- array: the float array to convert
- array: the float array to convert
- array: the float array to convert
=== "common"
=== "android"
=== "jvm"
=== "native"
=== "web"
expect fun of(array: DoubleArray): ArrayBuffer
actual fun of(array: DoubleArray): ArrayBuffer
actual fun of(array: DoubleArray): ArrayBuffer
actual fun of(array: DoubleArray): ArrayBuffer
actual fun of(array: DoubleArray): ArrayBuffer
=== "common"
Creates an ArrayBuffer from a DoubleArray.
**Return**
an ArrayBuffer containing the data from the double array
=== "android"
Creates an ArrayBuffer from a DoubleArray.
**Return**
an ArrayBuffer containing the data from the double array
=== "jvm"
Creates an ArrayBuffer from a DoubleArray.
**Return**
an ArrayBuffer containing the data from the double array
=== "native"
Creates an ArrayBuffer from a DoubleArray.
**Return**
an ArrayBuffer containing the data from the double array
=== "web"
Creates an ArrayBuffer from a DoubleArray.
**Return**
an ArrayBuffer containing the data from the double array
=== "common, android, jvm, native, web"
**Parameters**
- array: the double array to convert
- array: the double array to convert
- array: the double array to convert
- array: the double array to convert
- array: the double array to convert
=== "common"
=== "android"
=== "jvm"
=== "native"
=== "web"
expect fun of(array: UByteArray): ArrayBuffer
actual fun of(array: UByteArray): ArrayBuffer
actual fun of(array: UByteArray): ArrayBuffer
actual fun of(array: UByteArray): ArrayBuffer
actual fun of(array: UByteArray): ArrayBuffer
=== "common"
Creates an ArrayBuffer from a UByteArray.
**Return**
an ArrayBuffer containing the data from the unsigned byte array
=== "android"
Creates an ArrayBuffer from a UByteArray.
**Return**
an ArrayBuffer containing the data from the unsigned byte array
=== "jvm"
Creates an ArrayBuffer from a UByteArray.
**Return**
an ArrayBuffer containing the data from the unsigned byte array
=== "native"
Creates an ArrayBuffer from a UByteArray.
**Return**
an ArrayBuffer containing the data from the unsigned byte array
=== "web"
Creates an ArrayBuffer from a UByteArray.
**Return**
an ArrayBuffer containing the data from the unsigned byte array
=== "common, android, jvm, native, web"
**Parameters**
- array: the unsigned byte array to convert
- array: the unsigned byte array to convert
- array: the unsigned byte array to convert
- array: the unsigned byte array to convert
- array: the unsigned byte array to convert
=== "common"
=== "android"
=== "jvm"
=== "native"
=== "web"
expect fun of(array: UShortArray): ArrayBuffer
actual fun of(array: UShortArray): ArrayBuffer
actual fun of(array: UShortArray): ArrayBuffer
actual fun of(array: UShortArray): ArrayBuffer
actual fun of(array: UShortArray): ArrayBuffer
=== "common"
Creates an ArrayBuffer from a UShortArray.
**Return**
an ArrayBuffer containing the data from the unsigned short array
=== "android"
Creates an ArrayBuffer from a UShortArray.
**Return**
an ArrayBuffer containing the data from the unsigned short array
=== "jvm"
Creates an ArrayBuffer from a UShortArray.
**Return**
an ArrayBuffer containing the data from the unsigned short array
=== "native"
Creates an ArrayBuffer from a UShortArray.
**Return**
an ArrayBuffer containing the data from the unsigned short array
=== "web"
Creates an ArrayBuffer from a UShortArray.
**Return**
an ArrayBuffer containing the data from the unsigned short array
=== "common, android, jvm, native, web"
**Parameters**
- array: the unsigned short array to convert
- array: the unsigned short array to convert
- array: the unsigned short array to convert
- array: the unsigned short array to convert
- array: the unsigned short array to convert
=== "common"
=== "android"
=== "jvm"
=== "native"
=== "web"
expect fun of(array: UIntArray): ArrayBuffer
actual fun of(array: UIntArray): ArrayBuffer
actual fun of(array: UIntArray): ArrayBuffer
actual fun of(array: UIntArray): ArrayBuffer
actual fun of(array: UIntArray): ArrayBuffer
=== "common"
Creates an ArrayBuffer from a UIntArray.
**Return**
an ArrayBuffer containing the data from the unsigned int array
=== "android"
Creates an ArrayBuffer from a UIntArray.
**Return**
an ArrayBuffer containing the data from the unsigned int array
=== "jvm"
Creates an ArrayBuffer from a UIntArray.
**Return**
an ArrayBuffer containing the data from the unsigned int array
=== "native"
Creates an ArrayBuffer from a UIntArray.
**Return**
an ArrayBuffer containing the data from the unsigned int array
=== "web"
Creates an ArrayBuffer from a UIntArray.
**Return**
an ArrayBuffer containing the data from the unsigned int array
=== "common, android, jvm, native, web"
**Parameters**
- array: the unsigned int array to convert
- array: the unsigned int array to convert
- array: the unsigned int array to convert
- array: the unsigned int array to convert
- array: the unsigned int array to convert
wrap¶
fun wrap(buffer: ByteBuffer): ArrayBuffer
Creates an ArrayBuffer from a ByteBuffer.
**Return**
an ArrayBuffer backed by the byte buffer
**Parameters**
- buffer: the byte buffer to wrap (must be a direct buffer)
fun wrap(address: Long, size: ULong): ArrayBuffer
Wraps borrowed native memory as an ArrayBuffer.
The returned view reads and writes the memory at [`address`](index.md#wrap) directly, in the platform's native byte order: it never copies and never frees — the caller keeps owning the memory and must keep it valid for the view's whole lifetime. The intended use is a range a native library lends the caller for a bounded time, such as a GPU-mapped buffer between map and unmap.
**Return**
an ArrayBuffer view over the borrowed native memory
**Parameters**
- address: the native address of the borrowed memory (must not be null when [`size`](index.md#wrap) is non-zero)
- size: the size of the borrowed range in bytes
**Throws**
[`IllegalStateException`](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html)
: when a non-zero size is paired with a null address
fun wrap(segment: MemorySegment): ArrayBuffer
Creates an ArrayBuffer from a MemorySegment.
**Return**
an ArrayBuffer backed by the memory segment
**Parameters**
- segment: the memory segment to wrap
fun wrap(pointer: COpaquePointer, size: ULong): OpaquePointerArrayBuffer
Wraps a native pointer and its size into an OpaquePointerArrayBuffer.
**Return**
an instance of OpaquePointerArrayBuffer wrapping the provided pointer and size
**Parameters**
- pointer: the native pointer to wrap
- size: the size of the buffer in bytes
fun wrap(buffer: ArrayBuffer): WebArrayBuffer
Creates an ArrayBuffer from a JavaScript ArrayBuffer.
**Return**
an ArrayBuffer backed by the JavaScript array buffer
**Parameters**
- buffer: the JavaScript array buffer to wrap