tableext
local tableext = require("@std/tableext")WARNING
These APIs are still open to future evolution. In new major versions, they may change in backwards incompatible ways.
Summary
| Entry | Description |
|---|---|
| all | Returns true if predicate returns true for every element of arr. |
| any | Returns true if predicate returns true for at least one element of arr. |
| combine | Merges all additional tables into tbl in order. When the same key appears in multiple tables, the value from the last table containing that key wins. Returns tbl. |
| extend | Appends all elements from each additional array into tbl in order, mutating it in place. |
| filter | Returns a new table containing only the key-value pairs from table for which predicate returns true. |
| keys | Returns an array of all keys in tbl. Order is not guaranteed. |
| map | Returns a new table with the same keys as table, where each value has been transformed by applying f to it. |
| reverse | Returns tbl with its elements in reverse order. If inplace is true, reverses tbl in place; otherwise returns a new array. |
| toSet |
Functions and Properties
tableext.all
Returns true if predicate returns true for every element of arr.
(arr: { T }, predicate: (T) -> boolean) -> booleantableext.any
Returns true if predicate returns true for at least one element of arr.
(arr: { T }, predicate: (T) -> boolean) -> booleantableext.combine
Merges all additional tables into tbl in order. When the same key appears in multiple tables, the value from the last table containing that key wins. Returns tbl.
(tbl: { [K]: V }, ...: { [K]: V }) -> { [K]: V }tableext.extend
Appends all elements from each additional array into tbl in order, mutating it in place.
(tbl: { T }, ...: { T }) -> ()tableext.filter
Returns a new table containing only the key-value pairs from table for which predicate returns true.
(table: { [K]: V }, predicate: (V) -> boolean) -> { [K]: V }tableext.keys
Returns an array of all keys in tbl. Order is not guaranteed.
(tbl: { [K]: V }) -> { K }tableext.map
Returns a new table with the same keys as table, where each value has been transformed by applying f to it.
(table: { [K]: A }, f: (A) -> B) -> { [K]: B }tableext.reverse
Returns tbl with its elements in reverse order. If inplace is true, reverses tbl in place; otherwise returns a new array.
(tbl: { T }, inplace: boolean?) -> { T }tableext.toSet
(tbl: { T }) -> { [T]: true }