API Reference
Classes 
Bytes 
Immutable sequence of binary data.
Methods 
| Name | Description | 
|---|---|
|  | Get the byte at the given index. | 
|  | Create a copy of the bytesvalue. | 
|  | Get the slice of the bytesvalue from the given start index to the given end index. | 
|  | Convert the bytesvalue to a base64 encoded string. | 
|  | Convert the bytesvalue to a hex encoded string. | 
|  | Convert the bytesvalue to an array of byte values. | 
|  | Get the byte at the given index, returning nil if the index is out of bounds. | 
at 
at(index: num): num
Get the byte at the given index.
indexRequired 
- Type: num
index of the value to get.
copy 
copy(): Bytes
Create a copy of the bytes value.
slice 
slice(startIndex: num, endIndex?: num): Bytes
Get the slice of the bytes value from the given start index to the given end index.
startIndexRequired 
- Type: num
index to start the slice.
endIndexOptional 
- Type: num
index to end the slice.
toBase64 
toBase64(): str
Convert the bytes value to a base64 encoded string.
toHex 
toHex(): str
Convert the bytes value to a hex encoded string.
toRaw 
toRaw(): MutArray<num>
Convert the bytes value to an array of byte values.
tryAt 
tryAt(index: num): num?
Get the byte at the given index, returning nil if the index is out of bounds.
indexRequired 
- Type: num
index of the value to get.
Static Functions 
| Name | Description | 
|---|---|
|  | Concatenate multiple bytesvalues. | 
|  | Create a new bytesvalue from a base64 encoded string. | 
|  | Create a new bytesvalue from a hex encoded string. | 
|  | Create a new bytesvalue from an array of byte values. | 
|  | Create a new bytesvalue from a string. | 
|  | Create a new bytesvalue with the given length, filled with zeros. | 
concat 
Bytes.concat(...values: Array<Bytes>);
Concatenate multiple bytes values.
valuesRequired 
- Type: Bytes
the bytes values to concatenate.
fromBase64 
Bytes.fromBase64(base64: str);
Create a new bytes value from a base64 encoded string.
base64Required 
- Type: str
The base64 encoded string to create the bytes from.
fromHex 
Bytes.fromHex(hex: str);
Create a new bytes value from a hex encoded string.
hexRequired 
- Type: str
The hex encoded string to create the bytes from.
fromRaw 
Bytes.fromRaw(values: MutArray<num>);
Create a new bytes value from an array of byte values.
valuesRequired 
- Type: MutArray<num>
The byte values to create the bytes from.
fromString 
Bytes.fromString(value: str);
Create a new bytes value from a string.
valueRequired 
- Type: str
The string to create the bytes from.
zeros 
Bytes.zeros(length: num);
Create a new bytes value with the given length, filled with zeros.
lengthRequired 
- Type: num
The length of the new bytes value.
Properties 
| Name | Type | Description | 
|---|---|---|
|  | num | The length of the bytes. | 
lengthRequired 
length: num;
- Type: num
The length of the bytes.
Structs 
BytesToStringOptions 
Options for converting a bytes value to a string.
Initializer 
let BytesToStringOptions = BytesToStringOptions{ ... };
Properties 
| Name | Type | Description | 
|---|---|---|
|  | str | The encoding to use when converting the bytesvalue to a string. | 
encodingRequired 
encoding: str;
- Type: str
- Default: "utf-8"
The encoding to use when converting the bytes value to a string.
https://developer.mozilla.org/en-US/docs/Web/API/Encoding_API/Encodings