Skip to Content
Skip to Content

Byte/Buffer Manipulation

zune.mem


A library to manipulate/interact with bytes and buffers.

Properties

MAX_SIZE

The maximum amount of bytes luau can hold.

MAX_SIZE: number

Functions

len

Gets the length of a slice. This is similar to buffer.len but this supports strings and FFI pointers as well.

len(src: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer): number?

Parameters

  • src: MemReadableSlice - The source to get the length of.

copy

Copies data from one slice to another. This is similar to buffer.copy but this supports strings and FFI pointers as well.

copy(dest: -- references: -- (1) FFIPointer export type MemWritableSlice = buffer | FFIPointerMemWritableSlice-- references: -- (1) FFIPointer export type MemWritableSlice = buffer | FFIPointer, destOffset: number, src: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer, srcOffset: number, count: number?): ()

Parameters

  • dest: MemWritableSlice - The destination to copy to.
  • destOffset: number - The offset to start copying to in the destination.
  • src: MemReadableSlice - The source to copy from.
  • srcOffset: number - The offset to start copying from in the source.
  • count: number? - The number of bytes to copy. If not provided, will copy until the end of the source.

Throws

  • Memory Error

slice

Slices a portion of a source and returns it as a new buffer.

This does allocate memory for the new buffer.

slice(src: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer, offset: number, count: number?): buffer

Parameters

  • src: MemReadableSlice - The source to slice from.
  • offset: number - The offset to start the slice from.
  • count: number? - The number of bytes to include in the slice. If not provided,

Throws

  • Memory Error

eqlSlice

Compares two slices for equality.

eqlSlice(a: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer, aOffset: number, b: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer, bOffset: number, count: number?): boolean

Parameters

  • a: MemReadableSlice - The first slice to compare.
  • aOffset: number - The offset to start the comparison from in the first slice.
  • b: MemReadableSlice - The second slice to compare.
  • bOffset: number - The offset to start the comparison from in the second slice.
  • count: number? - The number of bytes to compare.

eql

Compares two slices for equality. A shortcut for eqlSlice(a, 0, b, 0, nil).

eql(a: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer, b: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer): boolean

Parameters

  • a: MemReadableSlice - The first slice to compare.
  • b: MemReadableSlice - The second slice to compare.

startsWith

Checks if a slice starts with a given needle.

startsWith(slice: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer, needle: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer): boolean

Parameters

  • slice: MemReadableSlice - The slice to check.
  • needle: MemReadableSlice - The needle to check for.

endsWith

Checks if a slice ends with a given needle.

endsWith(slice: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer, needle: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer): boolean

Parameters

  • slice: MemReadableSlice - The slice to check.
  • needle: MemReadableSlice - The needle to check for.

trim

Trims the given values from both ends of the buffer.

trim(src: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer, values_to_strip: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer): buffer

Parameters

  • src: MemReadableSlice - The source to trim.
  • values_to_strip: MemReadableSlice - The values to trim from the source.

Throws

  • Memory Error

trimLeft

Trims the given values from the left end of the buffer.

trimLeft(src: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer, values_to_strip: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer): buffer

Parameters

  • src: MemReadableSlice - The source to trim.
  • values_to_strip: MemReadableSlice - The values to trim from the source.

Throws

  • Memory Error

trimRight

Trims the given values from the right end of the buffer.

trimRight(src: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer, values_to_strip: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer): buffer

Parameters

  • src: MemReadableSlice - The source to trim.
  • values_to_strip: MemReadableSlice - The values to trim from the source.

Throws

  • Memory Error

find

Find the index of a needle in the buffer.

find(src: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer, needle: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer): number?

Parameters

  • src: MemReadableSlice - The source to search in.
  • needle: MemReadableSlice - The needle to search for.

findPos

Find the index of a needle in the buffer, starting from the given offset.

findPos(src: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer, offset: number, needle: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer): number?

Parameters

  • src: MemReadableSlice - The source to search in.
  • offset: number - The offset to start searching from.
  • needle: MemReadableSlice - The needle to search for.

findLast

Find the last index of a needle in the buffer.

findLast(src: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer, needle: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer): number?

Parameters

  • src: MemReadableSlice - The source to search in.
  • needle: MemReadableSlice - The needle to search for.

findScalar

Find the index of a scalar/char in the buffer.

findScalar(src: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer, char: number): number?

Parameters

  • src: MemReadableSlice - The source to search in.
  • char: number - The byte to search for.

findScalarPos

Find the index of a scalar/char in the buffer, starting from the given offset.

findScalarPos(src: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer, offset: number, char: number): number?

Parameters

  • src: MemReadableSlice - The source to search in.
  • offset: number - The offset to start searching from.
  • char: number - The byte to search for.

findScalarLast

Find the last index of a scalar/char in the buffer.

findScalarLast(src: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer, char: number): number?

Parameters

  • src: MemReadableSlice - The source to search in.
  • char: number - The byte to search for.

findAny

Find the index of the first byte that is in the given needle.

findAny(src: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer, needle: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer): number?

Parameters

  • src: MemReadableSlice - The source to search in.
  • needle: MemReadableSlice - The bytes to search for.

findAnyPos

Find the index of the first byte that is in the given needle, starting from the given offset.

findAnyPos(src: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer, offset: number, needle: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer): number?

Parameters

  • src: MemReadableSlice - The source to search in.
  • offset: number - The offset to start searching from.
  • needle: MemReadableSlice - The bytes to search for.

findAnyLast

Find the last index of a byte that is in the given needle.

findAnyLast(src: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer, needle: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer): number?

Parameters

  • src: MemReadableSlice - The source to search in.
  • needle: MemReadableSlice - The bytes to search for.

findNone

Find the index of the first byte that is not in the given needle.

findNone(src: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer, needle: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer): number?

Parameters

  • src: MemReadableSlice - The source to search in.
  • needle: MemReadableSlice - The bytes to not search for.

findNonePos

Find the index of the first byte that is not in the given needle, starting from the given offset.

findNonePos(src: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer, offset: number, needle: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer): number?

Parameters

  • src: MemReadableSlice - The source to search in.
  • offset: number - The offset to start searching from.
  • needle: MemReadableSlice - The bytes to not search for.

findNoneLast

Find the last index of a byte that is not in the given needle.

findNoneLast(src: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer, needle: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer): number?

Parameters

  • src: MemReadableSlice - The source to search in.
  • needle: MemReadableSlice - The bytes to not search for.

findDiff

Find the index of the first difference between two buffers.

findDiff(src: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer, needle: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer): number?

Parameters

  • src: MemReadableSlice - The source to search in.
  • needle: MemReadableSlice

findDiffPos

Find the index of the first difference between two buffers, starting from the given offset.

findDiffPos(src: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer, offset: number, needle: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer): number?

Parameters

  • src: MemReadableSlice - The source to search in.
  • offset: number - The offset to start searching from.
  • needle: MemReadableSlice

findMax

Find the index of the maximum value in the buffer.

Expects the buffer to be non-empty.

findMax(src: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer, offset: number?, count: number?): number

Parameters

  • src: MemReadableSlice - The source to search in.
  • offset: number? - The offset to start searching from.
  • count: number? - The number of bytes to search. If not provided, will search until the end of the buffer.

findMin

Find the index of the minimum value in the buffer.

Expects the buffer to be non-empty.

findMin(src: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer, offset: number?, count: number?): number

Parameters

  • src: MemReadableSlice - The source to search in.
  • offset: number? - The offset to start searching from.
  • count: number? - The number of bytes to search. If not provided, will search until the end of the buffer.

findMinMax

Find both the index of the minimum and maximum values in the buffer.

Expects the buffer to be non-empty.

findMinMax(src: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer, offset: number?, count: number?): (number, number)

Parameters

  • src: MemReadableSlice - The source to search in.
  • offset: number? - The offset to start searching from.
  • count: number? - The number of bytes to search. If not provided, will search until the end of the buffer.

cutPrefix

Cuts the buffer only if it starts with the given prefix. Returning the rest of the buffer.

cutPrefix(src: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer, prefix: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer): buffer?

Parameters

  • src: MemReadableSlice - The source to cut from.
  • prefix: MemReadableSlice - The prefix to check for.

Throws

  • Memory Error

cutSuffix

Cuts the buffer only if it ends with the given suffix. Returning the rest of the buffer.

cutSuffix(src: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer, suffix: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer): buffer?

Parameters

  • src: MemReadableSlice - The source to cut from.
  • suffix: MemReadableSlice - The suffix to check for.

Throws

  • Memory Error

cut

Cuts the buffer at the first occurrence of the needle, returning the part before and after the needle. If the needle is not found, returns nil.

cut(src: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer, needle: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer): (buffer?, buffer?)

Parameters

  • src: MemReadableSlice - The source to cut from.
  • needle: MemReadableSlice - The needle to cut at.

Throws

  • Memory Error

cutLast

Cuts the buffer at the last occurrence of the needle, returning the part before and after the needle. If the needle is not found, returns nil.

cutLast(src: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer, needle: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer): (buffer?, buffer?)

Parameters

  • src: MemReadableSlice - The source to cut from.
  • needle: MemReadableSlice - The needle to cut at.

Throws

  • Memory Error

cutScalar

Cuts the buffer at the first occurrence of the scalar/char, returning the part before and after the char. If the char is not found, returns nil.

cutScalar(src: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer, char: number): (buffer?, buffer?)

Parameters

  • src: MemReadableSlice - The source to cut from.
  • char: number - The byte to cut at.

Throws

  • Memory Error

cutScalarLast

Cuts the buffer at the last occurrence of the scalar/char, returning the part before and after the char. If the char is not found, returns nil.

cutScalarLast(src: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer, char: number): (buffer?, buffer?)

Parameters

  • src: MemReadableSlice - The source to cut from.
  • char: number - The byte to cut at.

Throws

  • Memory Error

replaceScalar

Replaces all occurrences of a scalar in the buffer with another scalar.

  • [1, 2, 3, 2] with (2, 4) -> [1, 4, 3, 4]
replaceScalar(src: -- references: -- (1) FFIPointer export type MemWritableSlice = buffer | FFIPointerMemWritableSlice-- references: -- (1) FFIPointer export type MemWritableSlice = buffer | FFIPointer, char: number, replacement: number, offset: number?, count: number?): ()

Parameters

  • src: MemWritableSlice - The source to replace in.
  • char: number - The byte to replace.
  • replacement: number - The byte to replace with.
  • offset: number? - The offset to start replacing from.
  • count: number? - The number of bytes to replace. If not provided, will replace until the end of the buffer.

max

Finds the maximum value in the buffer.

Expects the buffer to be non-empty.

max(src: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer, offset: number?, count: number?): number

Parameters

  • src: MemReadableSlice - The source to search in.
  • offset: number? - The offset to start searching from.
  • count: number? - The number of bytes to search. If not provided, will search until the end of the buffer.

min

Finds the minimum value in the buffer.

Expects the buffer to be non-empty.

min(src: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer, offset: number?, count: number?): number

Parameters

  • src: MemReadableSlice - The source to search in.
  • offset: number? - The offset to start searching from.
  • count: number? - The number of bytes to search. If not provided, will search until

reverse

Reverses the buffer in place.

  • [1, 2, 3] -> [3, 2, 1]
reverse(src: -- references: -- (1) FFIPointer export type MemWritableSlice = buffer | FFIPointerMemWritableSlice-- references: -- (1) FFIPointer export type MemWritableSlice = buffer | FFIPointer, offset: number?, count: number?): ()

Parameters

  • src: MemWritableSlice - The source to reverse in.
  • offset: number? - The offset to start reversing from.
  • count: number? - The number of bytes to reverse. If not provided, will reverse until

rotate

Rotates the buffer to the left by the given amount.

For example, rotating [1, 2, 3, 4, 5] by 2 would result in [3, 4, 5, 1, 2].

rotate(src: -- references: -- (1) FFIPointer export type MemWritableSlice = buffer | FFIPointerMemWritableSlice-- references: -- (1) FFIPointer export type MemWritableSlice = buffer | FFIPointer, amount: number, offset: number?, count: number?): ()

Parameters

  • src: MemWritableSlice - The source to rotate in.
  • amount: number - The amount to rotate by.
  • offset: number? - The offset to start rotating from.
  • count: number? - The number of bytes to rotate. If not provided, will rotate up to the end of the buffer.

set

Sets the value of the buffer at the given offset to the given value, for the given count of bytes.

set(dest: -- references: -- (1) FFIPointer export type MemWritableSlice = buffer | FFIPointerMemWritableSlice-- references: -- (1) FFIPointer export type MemWritableSlice = buffer | FFIPointer, value: number, offset: number?, count: number?): ()

Parameters

  • dest: MemWritableSlice - The source to write in.
  • value: number - The value to set.
  • offset: number? - The offset to start writing at.
    • default: 0
  • count: number? - The number of bytes to write. If not provided, will write until the end of the buffer.

toVector2

Reads a vector with only 2 elements from a buffer.

toVector2(src: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer, offset: number?): vector

Parameters

  • src: MemReadableSlice - The source to read from.
  • offset: number? - The offset to start reading from.

toVector3

Reads a vector with only 3 elements from a buffer.

toVector3(src: -- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointerMemReadableSlice-- references: -- (1) FFIPointer export type MemReadableSlice = string | buffer | FFIPointer, offset: number?): vector

Parameters

  • src: MemReadableSlice - The source to read from.
  • offset: number? - The offset to start reading from.

writeVector2

Writes a vector with only 2 elements to a buffer.

writeVector2(dest: -- references: -- (1) FFIPointer export type MemWritableSlice = buffer | FFIPointerMemWritableSlice-- references: -- (1) FFIPointer export type MemWritableSlice = buffer | FFIPointer, offset: number?, vec: vector): ()

Parameters

  • dest: MemWritableSlice - The destination to write to.
  • offset: number? - The offset to start writing to.
  • vec: vector - The vector to write.

writeVector3

Writes a vector with only 3 elements to a buffer.

writeVector3(dest: -- references: -- (1) FFIPointer export type MemWritableSlice = buffer | FFIPointerMemWritableSlice-- references: -- (1) FFIPointer export type MemWritableSlice = buffer | FFIPointer, offset: number?, vec: vector): ()

Parameters

  • dest: MemWritableSlice - The destination to write to.
  • offset: number? - The offset to start writing to.
  • vec: vector - The vector to write.
Last updated on