Now I know table utility modules are all over the place on the forums, but I just felt like making my first post with this.
However, I did at least try to add new functions that I did not find on most table utility modules.
jTableUtility
table jTableUtility.Copy(table t, boolean deep)
Returns a copy of the table. If deep is true, nested tables will also be copied.
array jTableUtility.Divide(array t, number n)
Divides the array into n pieces. The amount of items per slice will be equalized, so this can be useful for team selection.
print(jTableUtility.Divide({1, 2, 3, 4, 5}, 4))
--> {{1, 2}, {3}, {4}, {5}}
table jTableUtility.Filter(table t, function f)
Filters the table based on the function f. If the function returns false, the item will be removed.
This function does not properly support mixed tables, and the array portion will be prioritized.
local t = {
A = 27,
B = 49,
C = 30,
D = 62
}
print(jTableUtility.Filter(t, function(v: number)
return v >= 30
end))
--> {B = 49, C = 30, D = 62}
table jTableUtility.FilterFirst(table t, function f)
Similar to table.find, but allows more customization.
void jTableUtility.FindAndQuickRemove(table t, Variant v)
Finds and quick removes the given value in the given array.
void jTableUtility.FindAndRemove(table t, Variant v)
Same as jTableUtility.FindAndQuickRemove, but uses the built-in table.remove function.
number jTableUtility.Keys(table t)
Returns the number of keys in the table.
array jTableUtility.Merge(array t…)
Merges the given arrays.
print(jTableUtility.Merge({1, 2}, {3, 4}))
--> {1, 2, 3, 4}
void jTableUtility.QuickRemove(array t, number i)
A quicker version of table.remove. As this function replaces the given index with the last item and removes the last item, the order of the array is not maintained.
void jTableUtility.Shuffle(array t)
Shuffles the given array.
array jTableUtility.Slice(array t, number i, number j, boolean useLength)
Returns an array containing the items in index i ~ j. If useLength is true, j will be equal to the length of the slice.
array jTableUtility.Split(array t, number maximumPerChunk, number minimumPerChunk [= 1])
Splits the array into chunks.