Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

array.uint8

import array

Everything here is re-exported by array, so import array is enough and the names are called as array.*. Importing array.uint8 on its own works too and reaches the same definitions.

UInt8Array: a packed array of unsigned 8-bit integers, 1 byte per element.

UINT8_MAX and UINT8_MIN bound what an element may be; a value outside them raises rather than wrapping.

Constants

UINT8_MAX

array.UINT8_MAX: number = 255

Maximum value that “should” exist in a list passed to UInt8Array.

Classes

UInt8Array

class array.UInt8Array < Array

class UInt8Array represents an array of twos-complement 8-bit unsigned integers.

  • printable — has a @to_string(), so echo and print() show something useful
  • serializable — has a @to_json(), so it can be handed straight to json.encode()
  • valueable — has a @to_value(), so it converts to a plain Zuri value

UInt8Array.reverse()

array.UInt8Array.reverse() -> UInt8Array

Returns a new array containing the elements in the original array in reverse order.

Returns UInt8Array

UInt8Array.clone()

array.UInt8Array.clone() -> UInt8Array

Returns a new UInt8Array containing all items from the current array. The new array is a shallow copy of the original array.

Returns UInt8Array

UInt8Array.slice()

array.UInt8Array.slice(start, end) -> UInt8Array

Returns a new UInt8Array over [start, end) of this array (both default to the whole array; negative bounds count from the end).

Parameters

  • start (?number)
  • end (?number)

Returns UInt8Array


2021, Richard Ore and Zuri contributors