njs/buffer

Buffer is a view of ArrayBuffer

Types

pub type ArrayBuffer
pub type Buffer

Byte is size(8) unit(1) bitarray

pub type Byte =
  BitArray
pub type Encoding {
  Utf8
  Hex
  Base64
  Base64Url
}

Constructors

  • Utf8
  • Hex
  • Base64
  • Base64Url
pub type TypedArray
pub type TypedArrayType {
  Int8
  UInt8
  Int16
  UInt16
  Int32
  UInt32
}

Constructors

  • Int8
  • UInt8
  • Int16
  • UInt16
  • Int32
  • UInt32

Functions

pub fn alloc(size s: Int) -> Buffer
pub fn byte_length(value v: a, encoding e: Encoding) -> Int
pub fn compare(buffer1 b1: Buffer, buffer2 b2: Buffer) -> Int
pub fn concat(buffers bs: Array(Buffer), length t: a) -> Buffer
pub fn copy(
  dst bd: Buffer,
  src bs: Buffer,
  from f: Int,
  to t: Int,
) -> Buffer
pub fn equals(buffer1 b1: Buffer, buffer2 b2: Buffer) -> Bool
pub fn fill(
  buffer bf: Buffer,
  with v: BitArray,
  from f: Int,
  to t: Int,
) -> Buffer
pub fn from(
  array_buffer ab: ArrayBuffer,
  offset o: Int,
  length l: Int,
) -> Buffer
pub fn from_buffer(buffer bf: Buffer) -> Buffer
pub fn from_bytes(array ab: Array(BitArray)) -> Buffer
pub fn from_string(
  bitarray ba: BitArray,
  encoding e: Encoding,
) -> Buffer
pub fn get_buffer(buffer bf: Buffer) -> ArrayBuffer
pub fn get_buffer_offset(buffer b: Buffer) -> Int
pub fn get_byte(buffer bf: Buffer, offset o: Int) -> BitArray
pub fn includes(
  buffer bf: Buffer,
  value v: a,
  offset o: Int,
) -> Bool
pub fn includes_string(
  buffer bf: Buffer,
  value v: BitArray,
  offset o: Int,
  encoding e: Encoding,
) -> Bool
pub fn index_of(
  buffer bf: Buffer,
  value v: a,
  offset o: Int,
) -> Int
pub fn index_of_string(
  buffer bf: Buffer,
  value v: BitArray,
  offset o: Int,
  encoding e: Encoding,
) -> Int
pub fn last_index_of(
  buffer bf: Buffer,
  value v: a,
  offset o: Int,
  encoding e: Encoding,
) -> Int
pub fn last_index_of_string(
  buffer bf: Buffer,
  value v: BitArray,
  offset o: Int,
  encoding e: Encoding,
) -> Int
pub fn length(buffer bf: Buffer) -> Int
pub fn new_array_buffer(size s: Int) -> ArrayBuffer
pub fn new_typed_array(
  t: TypedArrayType,
  size s: Int,
) -> TypedArray
pub fn set_byte(
  buffer bf: Buffer,
  offset o: Int,
  byte b: BitArray,
) -> Buffer
pub fn slice(buffer bf: Buffer, from f: Int, to t: Int) -> Buffer
pub fn to_string(
  buffer bf: Buffer,
  encoding e: Encoding,
  from f: Int,
  to t: Int,
) -> String
pub fn write(
  buffer bf: Buffer,
  bitarray ba: BitArray,
  encoding e: Encoding,
  offset o: Int,
  length l: Int,
) -> Buffer

write at offset of buffer for length number of bytes

Search Document