{
"import": [
"mizchi/js",
"mizchi/js/builtins/arraybuffer"
]
}fn main {
// Create a Uint8Array
let arr = @typedarray.Uint8Array::from_size(10)
// Set values
arr.set_at(0, 42)
arr.set_at(1, 100)
// Get values
let value = arr.get_at(0) // 42
// Byte operations
let bytes = Bytes::new(10)
let typed_arr = @typedarray.bytes_to_uint8array(bytes)
}pub(all) struct ArrayBuffer {
byteLength : Int
maxByteLength : Int
resizable : Bool
}pub(all) struct BigInt64Array {
buffer : ArrayBuffer
byteLength : Int
byteOffset : Int
length : Int
}pub(all) struct BigUint64Array {
buffer : ArrayBuffer
byteLength : Int
byteOffset : Int
length : Int
}fn BigUint64Array::lastIndexOf(self : BigUint64Array, search_element : Int, from_index? : Int) -> Intpub(all) struct SharedArrayBuffer {
byteLength : Int
}fn SharedArrayBuffer::slice(self : SharedArrayBuffer, begin? : Int, end? : Int) -> SharedArrayBuffer#external
pub type TypedArraypub(all) struct Uint16Array {
buffer : ArrayBuffer
byteLength : UInt
byteOffset : UInt
length : UInt
}fn Uint16Array::from_array_buffer(buffer : ArrayBuffer, byte_offset? : Int, length? : Int) -> Uint16Arraypub(all) struct Uint32Array {
buffer : ArrayBuffer
byteLength : UInt
byteOffset : UInt
length : UInt
}fn Uint8Array::from_array_buffer(buffer : ArrayBuffer, byte_offset? : Int, length? : Int) -> Uint8Arraylet bytes = Bytes::from_array([1, 2, 3, 4, 5])
let uint8array = bytes_to_uint8array(bytes).as_typed_array()
assert_eq(uint8array.length(), 5)let uint8array = Uint8Array::from_array([1, 2, 3, 4, 5])
let bytes = uint8array_to_bytes(uint8array)
assert_eq(bytes.length(), 5)js bindings for builtins/web/node/deno/bun (browser APIs split to mizchi/js_browser)
Dependencies