Methods
TableUtils.all(tbl: [])
Returns whether every value in a table is true, iterating numerically.
Arguments:
| tbl: [] | The table to iterate through. |
Returns:
| result: boolean | Whether every value was true or not. |
TableUtils.any(tbl: [])
Returns whether any individual value in a table is true, iterating numerically.
Arguments:
| tbl: [] | The table to iterate through. |
Returns:
| result: boolean | Whether any value was true or not. |
TableUtils.clear(tbl: table)
Empties a table of all defined values.
Arguments:
| tbl: table | The table to clear. |
TableUtils.contains(tbl: table, val: any)
Whether the table contains the specified value.
Arguments:
| tbl: table | The table to check the value from. |
| val: any | The value to check. |
Returns:
| result: boolean | Whether the table contains the specified value. |
TableUtils.copy(tbl: table?, deep: boolean?, seen: table?)
Makes a new copy of a table, giving it all of the same values.
Arguments:
| tbl: table? | The table to copy. |
| deep: boolean? | Whether tables inside the specified table should be copied as well. |
| seen: table? | (Used internally) A table of values used to keep track of which objects have been cloned. |
Returns:
| new: table? | The new table. |
TableUtils.copyInto(new_tbl: table, tbl: table, deep: boolean?, seen: table?)
Copies the values of one table into a different one.
Arguments:
| new_tbl: table | The table receiving the copied values. |
| tbl: table | The table to copy values from. |
| deep: boolean? | Whether tables inside the specified table should be copied as well. |
| seen: table? | (Used internally) A table of values used to keep track of which objects have been cloned. |
Returns:
| 1: nil |
TableUtils.dump(o: any)
Returns a string converting a table value into readable text. Useful for debugging table values.
Arguments:
| o: any | The value to convert to a string. |
Returns:
| result: string | The newly generated string. |
TableUtils.endsWith(value: table, suffix: table)
Returns whether a table ends with the specified values.
The function will also return a second value, created by copying the initial value and removing the suffix.
Arguments:
| value: table | The table to check the end of. |
| suffix: table | The values that should be checked. |
Returns:
| success: boolean | Whether the value ended with the specified suffix. |
| rest: table | A new value created by removing the suffix substring or values from the initial value. If the result was unsuccessful, this value will simply be the initial unedited value. |
TableUtils.every(tbl: [], func: fun( <T)boolean)
Returns whether every value in a table satisfies a condition, iterating numerically.
Arguments:
| tbl: [] | The table to iterate through. |
| func: fun( <T)boolean | The condition function. |
Returns:
| result: boolean | Whether every value satisfied the condition or not. |
TableUtils.filter(tbl: [], filter: fun( <T)boolean)
Returns a new table containing only values that a function returns true for.
Arguments:
| tbl: [] | An array of values. |
| filter: fun( <T)boolean | A function that should return |
Returns:
| result: [] | A new array containing only approved values. |
TableUtils.filterInPlace(tbl: [], filter: fun( <T)boolean)
Removes values from a table if a function does not return true for them.
Arguments:
| tbl: [] | An array of values. |
| filter: fun( <T)boolean | A function that should return |
TableUtils.flatten(tbl: [][], deep: boolean?)
Merges a list of tables containing values into a single table containing each table's contents.
Arguments:
| tbl: [][] | The array of tables to merge. |
| deep: boolean? | If true, tables contained inside nested tables will also be merged. |
Returns:
| result: [] | The new table containing all values. |
TableUtils.flip(tbl: table)
Flips the values of a 2-dimensional array, such that its columns become its rows, and vice versa.
As an example, the following table:
{
{1, 2},
{3, 4},
}
would result in this when passed into the function:
{
{1, 3},
{2, 4},
}
Arguments:
| tbl: table | The table array to flip the values of. |
Returns:
| result: table | The new flipped array. |
TableUtils.getIndex(t: [], value: )
Returns the position of a specified value found within an array.
Arguments:
| t: [] | The array to get the position from. |
| value: | The value to find the position of. |
Returns:
| position: number? | The position found for the specified value. |
TableUtils.getKey(t: , value: )
Returns the key of a specified value found within a table.
Arguments:
| t: | The table to get the key from. |
| value: | The value to find the key of. |
Returns:
| key: ? | The key found for the specified value. |
TableUtils.getKeyCount(t: table)
Returns how many keys a table has.
Arguments:
| t: table | The table to check. |
Returns:
| result: number | The amount of keys found. |
TableUtils.getKeys(t: )
Returns a list of every key in a table.
Arguments:
| t: | The table to get the keys from. |
Returns:
| result: [] | An array of each key in the table. |
TableUtils.isArray(tbl: table)
Returns whether a table contains exclusively numerical indexes.
Arguments:
| tbl: table | The table to check. |
Returns:
| result: boolean | Whether the table contains only numerical indexes or not. |
TableUtils.lerp(from: table, to: table, value: number)
Lerp between each value in a table.
Arguments:
| from: table | The start values of the range. |
| to: table | The end values of the range. |
| value: number | The percentage (from 0 to 1) that determines the point on the specified range. |
Returns:
| result: table | The new table containing the values from the ranges. |
TableUtils.merge(tbl: table, other: table, deep: boolean?)
Merges the values of one table into another one.
Arguments:
| tbl: table | The table to merge values into. |
| other: table | The table to copy values from. |
| deep: boolean? | Whether shared table values between the two tables should also be merged. |
Returns:
| tbl: table | The initial table, now containing new values. |
TableUtils.mergeMany(...: table)
Merges many tables into a new table.
Arguments:
| ...: table | The tables to merge values from. |
Returns:
| result: table | A new table containing the values of the series of tables provided. |
TableUtils.pick(tbl: [])
Returns a random value from an array.
Arguments:
| tbl: [] | An array of values. |
Returns:
| result: | The randomly selected value. |
TableUtils.removeDuplicates(tbl: table, deep: boolean?)
Remove duplicate elements from a table.
Arguments:
| tbl: table | The table to remove duplicates from. |
| deep: boolean? | Whether tables inside the tbl will also have their duplicates removed. |
Returns:
| result: table | The new table that has its duplicates removed. |
TableUtils.removeValue(tbl: table, val: )
Removes the specified value from the table.
Arguments:
| tbl: table | The table to remove the value from. |
| val: | The value to be removed from the table. |
Returns:
| val: ? | The now removed value. |
TableUtils.reverse(tbl: [])
Returns a table containing the values of an array in reverse order.
Arguments:
| tbl: [] | An array of values. |
Returns:
| result: [] | The new table containing the values of the specified array. |
TableUtils.rotate(tbl: table, ccw: boolean?)
Rotates the values of a 2-dimensional array.
As an example, the following table:
{
{1, 2},
{3, 4},
}
would result in this when passed into the function, rotating it clockwise:
{
{3, 1},
{4, 2},
}
Arguments:
| tbl: table | The table array to rotate the values of. |
| ccw: boolean? | Whether the rotation should be counterclockwise. |
Returns:
| result: table | The new rotated array. |
TableUtils.shuffle(tbl: [])
Returns a table containing the values of another table, randomly rearranged.
Arguments:
| tbl: [] | An array of values. |
Returns:
| result: [] | The new randomly shuffled array. |
TableUtils.some(tbl: [], func: fun( <T)boolean)
Returns whether any individual value in a table satisfies a condition, iterating numerically.
Arguments:
| tbl: [] | The table to iterate through. |
| func: fun( <T)boolean | The condition function. |
Returns:
| result: boolean | Whether any value satisfied the condition or not. |
TableUtils.startsWith(value: table, prefix: table)
Returns whether a table starts with the specified values.
The function will also return a second value, created by copying the initial value and removing the prefix.
Arguments:
| value: table | The table to check the beginning of. |
| prefix: table | The values that should be checked. |
Returns:
| success: boolean | Whether the value started with the specified prefix. |
| rest: table | A new value created by removing the prefix substring or values from the initial value. If the result was unsuccessful, this value will simply be the initial unedited value. |
TableUtils.unpack(t: [])
Returns every numerically indexed value of a table.
This fixes the issue with unpack() not returning nil values.
Arguments:
| t: [] | The table to unpack. |
Returns:
| ...: | The values of the table. |