Module stdext

Standard library extensions.

table

table.defaulting(f, nostore) Create a defaulting table, which returns a default value when indexed with a key that does not exist.
table.contains(tbl, entry) Check whether a table contains an entry.
table.indexOf(tbl, entry) Find the index of an entry in a table.
table.readonly(tbl) Create a read-only proxy for a table.
table.mergeLists(...) Merge multiple list-like tables into one new table.
table.equals(a, b) Check whether all keys and values are equal in two tables.

global

safecall(errorhandler, f, ...) Call a function, or call an error handler with the raised error.

string

titleopts The options accepted by string.title.
string.title(s[, opts]) Return a copy of the input string with all words changed to title case.
string.split(s, sep[, n]) Split a string by a separator.


table

table.defaulting(f, nostore)
Create a defaulting table, which returns a default value when indexed with a key that does not exist.

Parameters:

  • f The function to default values in the table to.
  • nostore Optional; if true, the constructed value is only returned from the index operation, and not stored in the table.

Returns:

    The constructed table.
table.contains(tbl, entry)
Check whether a table contains an entry.

Parameters:

  • tbl The table to check for.
  • entry The entry to check for.

Returns:

    true if there is some index i between 1 and #tbl such that tbl[i] == entry, otherwise false.
table.indexOf(tbl, entry)
Find the index of an entry in a table.

Parameters:

  • tbl table The table to search.
  • entry The entry to find.

Returns:

    The index of entry in table, or nil if it is not present.
table.readonly(tbl)
Create a read-only proxy for a table. Nested tables are also read-only, unless they are used as keys. Proxy tables are lightweight; the only allocation is an empty table with a shared metatable.

Parameters:

  • tbl table The table to make a read-only proxy for.

Returns:

    A read-only proxy for the table, which acts as the table when indexed or iterated.
table.mergeLists(...)
Merge multiple list-like tables into one new table.

Parameters:

  • ... The tables to merge.

Returns:

    table The merged table.
table.equals(a, b)
Check whether all keys and values are equal in two tables.

Parameters:

  • a table The first table to check.
  • b table The second table to check.

Returns:

    bool True if all keys and values are equal in the two tables, i.e. there is no value v such that a[v] ~= b[v].

global

safecall(errorhandler, f, ...)
Call a function, or call an error handler with the raised error.

Parameters:

  • errorhandler The function to call if f throws an error. Errors in this function are not caught.
  • f The function to call.
  • ... The arguments to pass to the function.

Returns:

    f(...) if that call does not throw an error, otherwise errorhandler(err, ...).

string

titleopts
The options accepted by string.title.
  • wchar string The set of characters to consider as word characters; the default is any non-punctuation non-space character. See the Lua manual's patterns section for details on character sets; the value will be placed in [] for use as a character class. (default "^%p%s")
  • lower function The function to lowercase the input. (default string.lower)
  • upper function The function to uppercase the input. (default string.upper)
string.title(s[, opts])
Return a copy of the input string with all words changed to title case. Word characters immediately preceded by a non-word character or the start of the string will be uppercased; all other characters will be lowercased.

Parameters:

  • s string The string to titlecase.
  • opts titleopts The options to use. (optional)

Returns:

    string The string with all words changed to title case.
string.split(s, sep[, n])
Split a string by a separator.

Parameters:

  • s string The string to split.
  • sep string The pattern to split on.
  • n integer The maximum number of times to split the string, or zero/nil for unlimited. (optional)

Returns:

    table A list of all substrings between the separators, including leading/trailing empty strings if the original string contained leading/trailing separators.
generated by LDoc 1.5.0