Constructor
new SFSArray()
Creates a new instance of the SFSArray class.
Methods
addBool(value)
Appends a boolean value to the end of the array.
Parameters:| Name | Type | Description |
|---|
value | boolean | The value to be appended to the array. |
addBoolArray(array)
Appends an array of boolean values to the end of the array.
Parameters:| Name | Type | Description |
|---|
array | Array.<boolean> | The array of booleans to be appended to the array. |
addByte(value)
Appends a byte (8 bits) value to the end of the array.
Parameters:| Name | Type | Description |
|---|
value | number | The value to be appended to the array. |
addByteArray(array)
Appends a byte array to the end of the array.
Parameters:| Name | Type | Description |
|---|
array | Uint8Array | The byte array to be appended to the array. |
addDouble(value)
Appends a double precision number (64 bits) value to the end of the array.
Parameters:| Name | Type | Description |
|---|
value | number | The value to be appended to the array. |
addDoubleArray(array)
Appends an array of double precision number values to the end of the array.
Parameters:| Name | Type | Description |
|---|
array | Array.<number> | The array of doubles to be appended to the array. |
addFloat(value)
Appends a floating point number (32 bits) value to the end of the array.
Parameters:| Name | Type | Description |
|---|
value | number | The value to be appended to the array. |
addFloatArray(array)
Appends an array of floating point number values to the end of the array.
Parameters:| Name | Type | Description |
|---|
array | Array.<number> | The array of floats to be appended to the array. |
addInt(value)
Appends an integer (32 bits) value to the end of the array.
Parameters:| Name | Type | Description |
|---|
value | number | The value to be appended to the array. |
addIntArray(array)
Appends an array of integer values to the end of the array.
Parameters:| Name | Type | Description |
|---|
array | Array.<number> | The array of integers to be appended to the array. |
addLong(value)
Appends a long integer (64 bits) value to the end of the array.
IMPORTANT: in this API, long integers are represented by BigInt values, but SmartFoxServer supports long integers up to 64-bit signed. Make sure to take this limitation (and others, see BigInt documentation) into account when dealing with long integers.
Parameters:| Name | Type | Description |
|---|
value | number | bigint | The value to be appended to the array. |
addLongArray(array)
Appends an array of long integer values to the end of the array.
IMPORTANT: in this API, long integers are represented by BigInt values, but SmartFoxServer supports long integers up to 64-bit signed. Make sure to take this limitation (and others, see BigInt documentation) into account when dealing with long integers.
Parameters:| Name | Type | Description |
|---|
array | Array.<number> | Array.<bigint> | The array of longs to be appended to the array. |
addNull()
Appends a null value to the end of the array.
addSFSArray(value)
Appends an SFSArray object to the end of the array.
Parameters:| Name | Type | Description |
|---|
value | SFSArray | The SFSArray to be appended to the array. |
addSFSObject(value)
Appends an SFSObject object to the end of the array.
Parameters:| Name | Type | Description |
|---|
value | SFSObject | The SFSObject to be appended to the array. |
addShort(value)
Appends a short integer (16 bits) value to the end of the array.
Parameters:| Name | Type | Description |
|---|
value | number | The value to be appended to the array. |
addShortArray(array)
Appends an array of short integer values to the end of the array.
Parameters:| Name | Type | Description |
|---|
array | Array.<number> | The array of shorts to be appended to the array. |
addShortString(value)
Appends a UTF-8 string (with max length of 255 bytes) value to the end of the array.
Parameters:| Name | Type | Description |
|---|
value | string | The value to be appended to the array. |
addShortStringArray(array)
Appends an array of short UTF-8 string values to the end of the array.
Parameters:| Name | Type | Description |
|---|
array | Array.<string> | The array of strings to be appended to the array. |
addString(value)
Appends a UTF-8 string (with max length of 32767 bytes) value to the end of the array.
Parameters:| Name | Type | Description |
|---|
value | string | The value to be appended to the array. |
addStringArray(array)
Appends an array of UTF-8 string values to the end of the array.
Parameters:| Name | Type | Description |
|---|
array | Array.<string> | The array of strings to be appended to the array. |
addText(value)
Appends a UTF-8 string (with max length of 2 GBytes) value to the end of the array.
Parameters:| Name | Type | Description |
|---|
value | string | The value to be appended to the array. |
addVector2(value)
Appends a SFSVector2 object to the end of the array.
Parameters:| Name | Type | Description |
|---|
value | SFSVector2 | The SFSVector2 to be appended to the array. |
addVector2Array(array)
Appends an array of SFSVector2 objects to the end of the array.
Parameters:| Name | Type | Description |
|---|
array | Array.<SFSVector2> | The array of SFSVector2 to be appended to the array. |
addVector3(value)
Appends a SFSVector3 object to the end of the array.
Parameters:| Name | Type | Description |
|---|
value | SFSVector3 | The SFSVector3 to be appended to the array. |
addVector3Array(array)
Appends an array of SFSVector3 objects to the end of the array.
Parameters:| Name | Type | Description |
|---|
array | Array.<SFSVector3> | The array of SFSVector3 to be appended to the array. |
contains(obj) → {boolean}
Indicates whether the array contains the specified object.
IMPORTANT: checking if the SFSArray contains a nested SFSObject or SFSArray is not supported.
Parameters:| Name | Type | Description |
|---|
obj | * | The object whose presence in the array should be checked. |
Returns:true if the specified object is present in the array.
- Type:
- boolean
getBigInt(index) → {bigint}
Returns the element at the specified position as a BigInt.
Parameters:| Name | Type | Description |
|---|
index | number | The position of the element to return. |
Returns:The element of the array at the specified index.
- Type:
- bigint
getBigIntArray(index) → {Array.<bigint>}
Returns the element at the specified position as an array of BigInts.
Parameters:| Name | Type | Description |
|---|
index | number | The position of the element to return. |
Returns:The element of the array at the specified index.
- Type:
- Array.<bigint>
getBool(index) → {boolean}
Returns the element at the specified position as a boolean.
Parameters:| Name | Type | Description |
|---|
index | number | The position of the element to return. |
Returns:The element of the array at the specified index.
- Type:
- boolean
getBoolArray(index) → {Array.<boolean>}
Returns the element at the specified position as an array of booleans.
Parameters:| Name | Type | Description |
|---|
index | number | The position of the element to return. |
Returns:The element of the array at the specified index.
- Type:
- Array.<boolean>
getDump(formatopt) → {string}
Provides a formatted string representing the array.
The returned string can be logged or printed in the console for debugging purposes.
Parameters:| Name | Type | Attributes | Default | Description |
|---|
format | boolean | <optional>
| true | If true, the output is formatted in a human-readable way. |
Returns:The string representation of the array.
- Type:
- string
getElementAt(index) → {*}
Returns the element at the specified position in the array.
Parameters:| Name | Type | Description |
|---|
index | number | The position of the element to return. |
Returns:The element at the specified index in the array.
- Type:
- *
getHexDump() → {string}
Provides a detailed hexadecimal representation of the array.
The returned string can be logged or printed in the console for debugging purposes.
Returns:The hexadecimal string representation of the array.
- Type:
- string
getNumber(index) → {number}
Returns the element at the specified position as a number.
IMPORTANT: in case the original value is of type long, it will be cast to number, with possible loss of precision. Use SFSArrayt#getBigInt method to get the precise value.
Parameters:| Name | Type | Description |
|---|
index | number | The position of the element to return. |
Returns:The element of the array at the specified index.
- Type:
- number
getNumberArray(index) → {Array.<number>}
Returns the element at the specified position as an array of numbers.
IMPORTANT: in case the original values in the array are of type long, they will be cast to number, with possible loss of precision. Use SFSArray#getBigIntArray method to get the precise values.
Parameters:| Name | Type | Description |
|---|
index | number | The position of the element to return. |
Returns:The element of the array at the specified index.
- Type:
- Array.<number>
getSFSArray(index) → {SFSArray}
Returns the element at the specified position as an SFSArray.
Parameters:| Name | Type | Description |
|---|
index | number | The position of the element to return. |
Returns:The element of the array at the specified index.
- Type:
- SFSArray
getSFSObject(index) → {SFSObject}
Returns the element at the specified position as an SFSObject.
Parameters:| Name | Type | Description |
|---|
index | number | The position of the element to return. |
Returns:The element of the array at the specified index.
- Type:
- SFSObject
getString(index) → {string}
Returns the element at the specified position as an UTF-8 string.
Parameters:| Name | Type | Description |
|---|
index | number | The position of the element to return. |
Returns:The element of the array at the specified index.
- Type:
- string
getStringArray(index) → {Array.<string>}
Returns the element at the specified position as an array of UTF-8 strings.
Parameters:| Name | Type | Description |
|---|
index | number | The position of the element to return. |
Returns:The element of the array at the specified index.
- Type:
- Array.<string>
getVector2(index) → {SFSVector2}
Returns the element at the specified position as a SFSVector2.
Parameters:| Name | Type | Description |
|---|
index | number | The position of the element to return. |
Returns:The element of the array at the specified index.
- Type:
- SFSVector2
getVector2Array(index) → {Array.<SFSVector2>}
Returns the element at the specified position as an array of SFSVector2.
Parameters:| Name | Type | Description |
|---|
index | number | The position of the element to return. |
Returns:The element of the array at the specified index.
- Type:
- Array.<SFSVector2>
getVector3(index) → {SFSVector3}
Returns the element at the specified position as a SFSVector3.
Parameters:| Name | Type | Description |
|---|
index | number | The position of the element to return. |
Returns:The element of the array at the specified index.
- Type:
- SFSVector3
getVector3Array(index) → {Array.<SFSVector3>}
Returns the element at the specified position as an array of SFSVector3.
Parameters:| Name | Type | Description |
|---|
index | number | The position of the element to return. |
Returns:The element of the array at the specified index.
- Type:
- Array.<SFSVector3>
isNull(index) → {boolean}
Indicates whether the element at the specified position in the array is null.
Parameters:| Name | Type | Description |
|---|
index | number | The position of the element to be checked. |
Returns:true if the element of the array at the specified position is null.
- Type:
- boolean
removeElementAt(index) → {*}
Removes the element at the specified position in the array.
Parameters:| Name | Type | Description |
|---|
index | number | The position of the element to be removed. |
Returns:The element that was removed.
- Type:
- *
size() → {number}
Number of elements in the array.
Returns:The number of elements in the array.
- Type:
- number
toBinary() → {Uint8Array}
Provides the binary form of the array.
Returns:The binary data representing the array.
- Type:
- Uint8Array
(static) newFromBinaryData(binData) → {SFSArray}
Returns a new SFSArray instance.
This method is a static alternative to the standard class constructor that builds an SFSArray from a valid SFSArray binary representation.
Parameters:| Name | Type | Description |
|---|
binData | Uint8Array | The byte array representation of the SFSArray. |
Returns:A new SFSArray instance.
- Type:
- SFSArray