gossamer/int8_array
Types
Values
pub fn at(array: Int8Array, index index: Int) -> Result(Int, Nil)
Returns the element at index, or Error(Nil) if the index is
out of range. Negative indices count from the end.
pub fn buffer(of array: Int8Array) -> array_buffer.ArrayBuffer
pub fn byte_length(of array: Int8Array) -> Int
pub fn byte_offset(of array: Int8Array) -> Int
pub fn from_buffer(buffer: array_buffer.ArrayBuffer) -> Int8Array
pub fn from_buffer_range(
buffer: array_buffer.ArrayBuffer,
byte_offset byte_offset: Int,
length length: Int,
) -> Result(Int8Array, js_error.JsError)
Creates an Int8Array view over a slice of buffer starting at
byte_offset and spanning length elements. Returns an error if
the range is out of bounds or buffer is detached.
pub fn from_length(
length: Int,
) -> Result(Int8Array, js_error.JsError)
Creates a zero-filled Int8Array of the given length. Returns an
error if length is negative or exceeds the maximum allocatable
size.
pub fn from_list(list: List(Int)) -> Int8Array
Creates an Int8Array from a list of 8-bit signed integers.
Values outside -128–127 are wrapped modulo 256, matching the
JS Int8Array constructor.
pub fn index_of(
in array: Int8Array,
value value: Int,
) -> Result(Int, Nil)
Returns the first index of value, or Error(Nil) if not present.
pub fn last_index_of(
in array: Int8Array,
value value: Int,
) -> Result(Int, Nil)
Returns the last index of value, or Error(Nil) if not present.
pub fn set(
in array: Int8Array,
values values: Int8Array,
) -> Result(Nil, js_error.JsError)
Copies values into array starting at index 0. Returns an
error if values would extend past the end of array.
pub fn set_with_offset(
in array: Int8Array,
values values: Int8Array,
offset offset: Int,
) -> Result(Nil, js_error.JsError)
Copies values into array starting at offset. Returns an
error if offset is negative or the copy would extend past the
end of array.
pub fn with(
array: Int8Array,
at_index index: Int,
value value: Int,
) -> Result(Int8Array, js_error.JsError)
Returns a copy of array with the value at index replaced.
Negative indices count from the end. Returns an error if index
is out of range.