gossamer/int32_array

Types

A typed array of 32-bit signed integers.

See Int32Array on MDN.

pub type Int32Array

Values

pub fn at(
  array: Int32Array,
  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 byte_length(of array: Int32Array) -> Int
pub fn byte_offset(of array: Int32Array) -> Int
pub fn fill(array: Int32Array, with value: Int) -> Int32Array
pub fn from_buffer(
  buffer: array_buffer.ArrayBuffer,
) -> Result(Int32Array, js_error.JsError)

Creates an Int32Array view over buffer. Returns an error if buffer.byteLength is not a multiple of 4 (the element size).

pub fn from_buffer_range(
  buffer: array_buffer.ArrayBuffer,
  byte_offset byte_offset: Int,
  length length: Int,
) -> Result(Int32Array, js_error.JsError)

Creates an Int32Array view over a slice of buffer starting at byte_offset and spanning length elements. Returns an error if the range is out of bounds, buffer is detached, or byte_offset is not a multiple of 4.

pub fn from_length(
  length: Int,
) -> Result(Int32Array, js_error.JsError)

Creates a zero-filled Int32Array of the given length. Returns an error if length is negative or exceeds the maximum allocatable size.

pub fn from_list(list: List(Int)) -> Int32Array

Creates an Int32Array from a list of 32-bit signed integers. Values outside -2_147_483_6482_147_483_647 are wrapped modulo 4_294_967_296, matching the JS Int32Array constructor.

pub fn includes(in array: Int32Array, value value: Int) -> Bool
pub fn index_of(
  in array: Int32Array,
  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: Int32Array,
  value value: Int,
) -> Result(Int, Nil)

Returns the last index of value, or Error(Nil) if not present.

pub fn length(of array: Int32Array) -> Int
pub fn new() -> Int32Array
pub fn reverse(array: Int32Array) -> Int32Array
pub fn set(
  in array: Int32Array,
  values values: Int32Array,
) -> 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: Int32Array,
  values values: Int32Array,
  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 slice(array: Int32Array) -> Int32Array
pub fn slice_range(
  array: Int32Array,
  from start: Int,
  to end: Int,
) -> Int32Array
pub fn subarray(
  array: Int32Array,
  from begin: Int,
  to end: Int,
) -> Int32Array
pub fn to_list(array: Int32Array) -> List(Int)
pub fn with(
  array: Int32Array,
  at_index index: Int,
  value value: Int,
) -> Result(Int32Array, 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.

Search Document