Socket
Socket
Sign inDemoInstall

lua-types

Package Overview
Dependencies
0
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.5.1 to 2.5.2

33

core/coroutine.d.ts

@@ -6,7 +6,9 @@ // Based on https://www.lua.org/manual/5.3/manual.html#6.2

/**
* This library comprises the operations to manipulate coroutines, which come inside the table coroutine.
* This library comprises the operations to manipulate coroutines, which come
* inside the table coroutine.
*/
declare namespace coroutine {
/**
* Creates a new coroutine, with body f. f must be a function. Returns this new coroutine, an object with type "thread".
* Creates a new coroutine, with body f. f must be a function. Returns this
* new coroutine, an object with type "thread".
*/

@@ -16,5 +18,12 @@ function create(f: (...args: any[]) => any): LuaThread;

/**
* Starts or continues the execution of coroutine co. The first time you resume a coroutine, it starts running its body. The values val1, ... are passed as the arguments to the body function. If the coroutine has yielded, resume restarts it; the values val1, ... are passed as the results from the yield.
* Starts or continues the execution of coroutine co. The first time you
* resume a coroutine, it starts running its body. The values val1, ... are
* passed as the arguments to the body function. If the coroutine has yielded,
* resume restarts it; the values val1, ... are passed as the results from the
* yield.
*
* If the coroutine runs without any errors, resume returns true plus any values passed to yield (when the coroutine yields) or any values returned by the body function (when the coroutine terminates). If there is any error, resume returns false plus the error message.
* If the coroutine runs without any errors, resume returns true plus any
* values passed to yield (when the coroutine yields) or any values returned
* by the body function (when the coroutine terminates). If there is any
* error, resume returns false plus the error message.
* @tupleReturn

@@ -25,3 +34,8 @@ */

/**
* Returns the status of coroutine co, as a string: "running", if the coroutine is running (that is, it called status); "suspended", if the coroutine is suspended in a call to yield, or if it has not started running yet; "normal" if the coroutine is active but not running (that is, it has resumed another coroutine); and "dead" if the coroutine has finished its body function, or if it has stopped with an error.
* Returns the status of coroutine co, as a string: "running", if the
* coroutine is running (that is, it called status); "suspended", if the
* coroutine is suspended in a call to yield, or if it has not started running
* yet; "normal" if the coroutine is active but not running (that is, it has
* resumed another coroutine); and "dead" if the coroutine has finished its
* body function, or if it has stopped with an error.
*/

@@ -31,3 +45,7 @@ function status(co: LuaThread): 'running' | 'suspended' | 'normal' | 'dead';

/**
* Creates a new coroutine, with body f. f must be a function. Returns a function that resumes the coroutine each time it is called. Any arguments passed to the function behave as the extra arguments to resume. Returns the same values returned by resume, except the first boolean. In case of error, propagates the error.
* Creates a new coroutine, with body f. f must be a function. Returns a
* function that resumes the coroutine each time it is called. Any arguments
* passed to the function behave as the extra arguments to resume. Returns the
* same values returned by resume, except the first boolean. In case of error,
* propagates the error.
*/

@@ -37,3 +55,4 @@ function wrap(f: (...args: any[]) => any): /** @tupleReturn */ (...args: any[]) => any[];

/**
* Suspends the execution of the calling coroutine. Any arguments to yield are passed as extra results to resume.
* Suspends the execution of the calling coroutine. Any arguments to yield are
* passed as extra results to resume.
* @tupleReturn

@@ -40,0 +59,0 @@ */

@@ -6,11 +6,24 @@ // Based on https://www.lua.org/manual/5.3/manual.html#6.10

/**
* This library provides the functionality of the debug interface (§4.9) to Lua programs. You should exert care when using this library. Several of its functions violate basic assumptions about Lua code (e.g., that variables local to a function cannot be accessed from outside; that userdata metatables cannot be changed by Lua code; that Lua programs do not crash) and therefore can compromise otherwise secure code. Moreover, some functions in this library may be slow.
* This library provides the functionality of the debug interface (§4.9) to Lua
* programs. You should exert care when using this library. Several of its
* functions violate basic assumptions about Lua code (e.g., that variables
* local to a function cannot be accessed from outside; that userdata metatables
* cannot be changed by Lua code; that Lua programs do not crash) and therefore
* can compromise otherwise secure code. Moreover, some functions in this
* library may be slow.
*
* All functions in this library are provided inside the debug table. All functions that operate over a thread have an optional first argument which is the thread to operate over. The default is always the current thread.
* All functions in this library are provided inside the debug table. All
* functions that operate over a thread have an optional first argument which is
* the thread to operate over. The default is always the current thread.
*/
declare namespace debug {
/**
* Enters an interactive mode with the user, running each string that the user enters. Using simple commands and other debug facilities, the user can inspect global and local variables, change their values, evaluate expressions, and so on. A line containing only the word cont finishes this function, so that the caller continues its execution.
* Enters an interactive mode with the user, running each string that the user
* enters. Using simple commands and other debug facilities, the user can
* inspect global and local variables, change their values, evaluate
* expressions, and so on. A line containing only the word cont finishes this
* function, so that the caller continues its execution.
*
* Note that commands for debug.debug are not lexically nested within any function and so have no direct access to local variables.
* Note that commands for debug.debug are not lexically nested within any
* function and so have no direct access to local variables.
*/

@@ -20,3 +33,5 @@ function debug(): void;

/**
* Returns the current hook settings of the thread, as three values: the current hook function, the current hook mask, and the current hook count (as set by the debug.sethook function).
* Returns the current hook settings of the thread, as three values: the
* current hook function, the current hook mask, and the current hook count
* (as set by the debug.sethook function).
* @tupleReturn

@@ -37,3 +52,4 @@ */

/**
* What the `name` field means. The empty string means that Lua did not find a name for the function.
* What the `name` field means. The empty string means that Lua did not find
* a name for the function.
*/

@@ -44,3 +60,4 @@ namewhat: 'global' | 'local' | 'method' | 'field' | '';

/**
* A short version of source (up to 60 characters), useful for error messages.
* A short version of source (up to 60 characters), useful for error
* messages.
*/

@@ -64,7 +81,21 @@ short_src: string;

/**
* Returns a table with information about a function. You can give the function directly or you can give a number as the value of f, which means the function running at level f of the call stack of the given thread: level 0 is the current function (getinfo itself); level 1 is the function that called getinfo (except for tail calls, which do not count on the stack); and so on. If f is a number larger than the number of active functions, then getinfo returns nil.
* Returns a table with information about a function. You can give the
* function directly or you can give a number as the value of f, which means
* the function running at level f of the call stack of the given thread:
* level 0 is the current function (getinfo itself); level 1 is the function
* that called getinfo (except for tail calls, which do not count on the
* stack); and so on. If f is a number larger than the number of active
* functions, then getinfo returns nil.
*
* The returned table can contain all the fields returned by lua_getinfo, with the string what describing which fields to fill in. The default for what is to get all information available, except the table of valid lines. If present, the option 'f' adds a field named func with the function itself. If present, the option 'L' adds a field named activelines with the table of valid lines.
* The returned table can contain all the fields returned by lua_getinfo, with
* the string what describing which fields to fill in. The default for what is
* to get all information available, except the table of valid lines. If
* present, the option 'f' adds a field named func with the function itself.
* If present, the option 'L' adds a field named activelines with the table of
* valid lines.
*
* For instance, the expression debug.getinfo(1,"n").name returns a name for the current function, if a reasonable name can be found, and the expression debug.getinfo(print) returns a table with all available information about the print function.
* For instance, the expression debug.getinfo(1,"n").name returns a name for
* the current function, if a reasonable name can be found, and the expression
* debug.getinfo(print) returns a table with all available information about
* the print function.
*/

@@ -85,3 +116,4 @@ function getinfo<T extends Function>(f: T): FunctionInfo<T>;

/**
* Returns the metatable of the given value or nil if it does not have a metatable.
* Returns the metatable of the given value or nil if it does not have a
* metatable.
*/

@@ -96,5 +128,9 @@ function getmetatable<T extends any>(value: T): LuaMetatable<T> | undefined;

/**
* This function returns the name and the value of the upvalue with index up of the function f. The function returns nil if there is no upvalue with the given index.
* This function returns the name and the value of the upvalue with index up
* of the function f. The function returns nil if there is no upvalue with the
* given index.
*
* Variable names starting with '(' (open parenthesis) represent variables with no known names (variables from chunks saved without debug information).
* Variable names starting with '(' (open parenthesis) represent variables
* with no known names (variables from chunks saved without debug
* information).
* @tupleReturn

@@ -105,3 +141,4 @@ */

/**
* Returns the Lua value associated to u. If u is not a full userdata, returns nil.
* Returns the Lua value associated to u. If u is not a full userdata, returns
* nil.
*/

@@ -111,3 +148,5 @@ function getuservalue(u: LuaUserdata): any;

/**
* Sets the given function as a hook. The string mask and the number count describe when the hook will be called. The string mask may have any combination of the following characters, with the given meaning:
* Sets the given function as a hook. The string mask and the number count
* describe when the hook will be called. The string mask may have any
* combination of the following characters, with the given meaning:
*

@@ -118,7 +157,13 @@ * * 'c': the hook is called every time Lua calls a function;

*
* Moreover, with a count different from zero, the hook is called also after every count instructions.
* Moreover, with a count different from zero, the hook is called also after
* every count instructions.
*
* When called without arguments, debug.sethook turns off the hook.
*
* When the hook is called, its first parameter is a string describing the event that has triggered its call: "call" (or "tail call"), "return", "line", and "count". For line events, the hook also gets the new line number as its second parameter. Inside a hook, you can call getinfo with level 2 to get more information about the running function (level 0 is the getinfo function, and level 1 is the hook function).
* When the hook is called, its first parameter is a string describing the
* event that has triggered its call: "call" (or "tail call"), "return",
* "line", and "count". For line events, the hook also gets the new line
* number as its second parameter. Inside a hook, you can call getinfo with
* level 2 to get more information about the running function (level 0 is the
* getinfo function, and level 1 is the hook function).
*/

@@ -139,3 +184,8 @@ function sethook(): void;

/**
* This function assigns the value value to the local variable with index local of the function at level level of the stack. The function returns nil if there is no local variable with the given index, and raises an error when called with a level out of range. (You can call getinfo to check whether the level is valid.) Otherwise, it returns the name of the local variable.
* This function assigns the value value to the local variable with index
* local of the function at level level of the stack. The function returns nil
* if there is no local variable with the given index, and raises an error
* when called with a level out of range. (You can call getinfo to check
* whether the level is valid.) Otherwise, it returns the name of the local
* variable.
*

@@ -153,3 +203,4 @@ * See debug.getlocal for more information about variable indices and names.

/**
* Sets the metatable for the given value to the given table (which can be nil). Returns value.
* Sets the metatable for the given value to the given table (which can be
* nil). Returns value.
*/

@@ -159,3 +210,5 @@ function setmetatable<T>(value: T, table: LuaMetatable<T> | null | undefined): T;

/**
* This function assigns the value value to the upvalue with index up of the function f. The function returns nil if there is no upvalue with the given index. Otherwise, it returns the name of the upvalue.
* This function assigns the value value to the upvalue with index up of the
* function f. The function returns nil if there is no upvalue with the given
* index. Otherwise, it returns the name of the upvalue.
*/

@@ -165,3 +218,4 @@ function setupvalue(f: Function, up: number, value: any): string | undefined;

/**
* Sets the given value as the Lua value associated to the given udata. udata must be a full userdata.
* Sets the given value as the Lua value associated to the given udata. udata
* must be a full userdata.
*

@@ -173,3 +227,8 @@ * Returns udata.

/**
* If message is present but is neither a string nor nil, this function returns message without further processing. Otherwise, it returns a string with a traceback of the call stack. The optional message string is appended at the beginning of the traceback. An optional level number tells at which level to start the traceback (default is 1, the function calling traceback).
* If message is present but is neither a string nor nil, this function
* returns message without further processing. Otherwise, it returns a string
* with a traceback of the call stack. The optional message string is appended
* at the beginning of the traceback. An optional level number tells at which
* level to start the traceback (default is 1, the function calling
* traceback).
*/

@@ -176,0 +235,0 @@ function traceback(message?: string | null, level?: number | null): string;

@@ -15,3 +15,4 @@ // Based on https://www.lua.org/manual/5.3/manual.html#6.1

/**
* A global variable (not a function) that holds a string containing the running Lua version.
* A global variable (not a function) that holds a string containing the running
* Lua version.
*/

@@ -21,3 +22,5 @@ declare const _VERSION: 'Lua 5.1' | 'Lua 5.2' | 'Lua 5.3' | 'Lua 5.4';

/**
* A global variable (not a function) that holds the global environment (see §2.2). Lua itself does not use this variable; changing its value does not affect any environment, nor vice versa.
* A global variable (not a function) that holds the global environment (see
* §2.2). Lua itself does not use this variable; changing its value does not
* affect any environment, nor vice versa.
*/

@@ -27,3 +30,5 @@ declare const _G: Record<string, any>;

/**
* Calls error if the value of its argument v is false (i.e., nil or false); otherwise, returns all its arguments. In case of error, message is the error object; when absent, it defaults to "assertion failed!"
* Calls error if the value of its argument v is false (i.e., nil or false);
* otherwise, returns all its arguments. In case of error, message is the error
* object; when absent, it defaults to "assertion failed!"
* @tupleReturn

@@ -36,3 +41,4 @@ */

/**
* This function is a generic interface to the garbage collector. It performs different functions according to its first argument, opt.
* This function is a generic interface to the garbage collector. It performs
* different functions according to its first argument, opt.
*

@@ -44,5 +50,7 @@ * Performs a full garbage-collection cycle. This is the default option.

/**
* This function is a generic interface to the garbage collector. It performs different functions according to its first argument, opt.
* This function is a generic interface to the garbage collector. It performs
* different functions according to its first argument, opt.
*
* Stops automatic execution of the garbage collector. The collector will run only when explicitly invoked, until a call to restart it.
* Stops automatic execution of the garbage collector. The collector will run
* only when explicitly invoked, until a call to restart it.
*/

@@ -52,3 +60,4 @@ declare function collectgarbage(opt: 'stop'): void;

/**
* This function is a generic interface to the garbage collector. It performs different functions according to its first argument, opt.
* This function is a generic interface to the garbage collector. It performs
* different functions according to its first argument, opt.
*

@@ -60,5 +69,7 @@ * Restarts automatic execution of the garbage collector.

/**
* This function is a generic interface to the garbage collector. It performs different functions according to its first argument, opt.
* This function is a generic interface to the garbage collector. It performs
* different functions according to its first argument, opt.
*
* Sets arg as the new value for the pause of the collector (see §2.5). Returns the previous value for pause.
* Sets arg as the new value for the pause of the collector (see §2.5). Returns
* the previous value for pause.
*/

@@ -68,5 +79,7 @@ declare function collectgarbage(opt: 'setpause', arg: number): number;

/**
* This function is a generic interface to the garbage collector. It performs different functions according to its first argument, opt.
* This function is a generic interface to the garbage collector. It performs
* different functions according to its first argument, opt.
*
* Sets arg as the new value for the step multiplier of the collector (see §2.5). Returns the previous value for step.
* Sets arg as the new value for the step multiplier of the collector (see
* §2.5). Returns the previous value for step.
*/

@@ -76,5 +89,10 @@ declare function collectgarbage(opt: 'setstepmul', arg: number): number;

/**
* This function is a generic interface to the garbage collector. It performs different functions according to its first argument, opt.
* This function is a generic interface to the garbage collector. It performs
* different functions according to its first argument, opt.
*
* Performs a garbage-collection step. The step "size" is controlled by arg. With a zero value, the collector will perform one basic (indivisible) step. For non-zero values, the collector will perform as if that amount of memory (in KBytes) had been allocated by Lua. Returns true if the step finished a collection cycle.
* Performs a garbage-collection step. The step "size" is controlled by arg.
* With a zero value, the collector will perform one basic (indivisible) step.
* For non-zero values, the collector will perform as if that amount of memory
* (in KBytes) had been allocated by Lua. Returns true if the step finished a
* collection cycle.
*/

@@ -84,3 +102,7 @@ declare function collectgarbage(opt: 'step', arg: number): boolean;

/**
* Opens the named file and executes its contents as a Lua chunk. When called without arguments, dofile executes the contents of the standard input (stdin). Returns all values returned by the chunk. In case of errors, dofile propagates the error to its caller (that is, dofile does not run in protected mode).
* Opens the named file and executes its contents as a Lua chunk. When called
* without arguments, dofile executes the contents of the standard input
* (stdin). Returns all values returned by the chunk. In case of errors, dofile
* propagates the error to its caller (that is, dofile does not run in protected
* mode).
*/

@@ -90,5 +112,11 @@ declare function dofile(filename?: string): any;

/**
* Terminates the last protected function called and returns message as the error object. Function error never returns.
* Terminates the last protected function called and returns message as the
* error object. Function error never returns.
*
* Usually, error adds some information about the error position at the beginning of the message, if the message is a string. The level argument specifies how to get the error position. With level 1 (the default), the error position is where the error function was called. Level 2 points the error to where the function that called error was called; and so on. Passing a level 0 avoids the addition of error position information to the message.
* Usually, error adds some information about the error position at the
* beginning of the message, if the message is a string. The level argument
* specifies how to get the error position. With level 1 (the default), the
* error position is where the error function was called. Level 2 points the
* error to where the function that called error was called; and so on. Passing
* a level 0 avoids the addition of error position information to the message.
*/

@@ -98,3 +126,5 @@ declare function error(message: string, level?: number): never;

/**
* If object does not have a metatable, returns nil. Otherwise, if the object's metatable has a __metatable field, returns the associated value. Otherwise, returns the metatable of the given object.
* If object does not have a metatable, returns nil. Otherwise, if the object's
* metatable has a __metatable field, returns the associated value. Otherwise,
* returns the metatable of the given object.
*/

@@ -104,7 +134,9 @@ declare function getmetatable<T extends object>(object: T): LuaMetatable<T> | undefined;

/**
* Returns three values (an iterator function, the table t, and 0) so that the construction
* Returns three values (an iterator function, the table t, and 0) so that the
* construction
*
* `for i,v in ipairs(t) do body end`
*
* will iterate over the key–value pairs (1,t[1]), (2,t[2]), ..., up to the first nil value.
* will iterate over the key–value pairs (1,t[1]), (2,t[2]), ..., up to the
* first nil value.
*/

@@ -114,7 +146,17 @@ declare function ipairs<T>(t: Record<number, T>): LuaTupleIterable<[number, T]>;

/**
* Allows a program to traverse all fields of a table. Its first argument is a table and its second argument is an index in this table. next returns the next index of the table and its associated value. When called with nil as its second argument, next returns an initial index and its associated value. When called with the last index, or with nil in an empty table, next returns nil. If the second argument is absent, then it is interpreted as nil. In particular, you can use next(t) to check whether a table is empty.
* Allows a program to traverse all fields of a table. Its first argument is a
* table and its second argument is an index in this table. next returns the
* next index of the table and its associated value. When called with nil as its
* second argument, next returns an initial index and its associated value. When
* called with the last index, or with nil in an empty table, next returns nil.
* If the second argument is absent, then it is interpreted as nil. In
* particular, you can use next(t) to check whether a table is empty.
*
* The order in which the indices are enumerated is not specified, even for numeric indices. (To traverse a table in numerical order, use a numerical for.)
* The order in which the indices are enumerated is not specified, even for
* numeric indices. (To traverse a table in numerical order, use a numerical
* for.)
*
* The behavior of next is undefined if, during the traversal, you assign any value to a non-existent field in the table. You may however modify existing fields. In particular, you may clear existing fields.
* The behavior of next is undefined if, during the traversal, you assign any
* value to a non-existent field in the table. You may however modify existing
* fields. In particular, you may clear existing fields.
* @tupleReturn

@@ -125,4 +167,5 @@ */

/**
* If t has a metamethod __pairs, calls it with t as argument and returns the first three results from the call.
* Otherwise, returns three values: the next function, the table t, and nil, so that the construction
* If t has a metamethod __pairs, calls it with t as argument and returns the
* first three results from the call. Otherwise, returns three values: the next
* function, the table t, and nil, so that the construction
*

@@ -133,3 +176,4 @@ * `for k,v in pairs(t) do body end`

*
* See function next for the caveats of modifying the table during its traversal.
* See function next for the caveats of modifying the table during its
* traversal.
*/

@@ -139,3 +183,8 @@ declare function pairs<T>(t: T): LuaTupleIterable<[keyof T, T[keyof T]]>;

/**
* Calls function f with the given arguments in protected mode. This means that any error inside f is not propagated; instead, pcall catches the error and returns a status code. Its first result is the status code (a boolean), which is true if the call succeeds without errors. In such case, pcall also returns all results from the call, after this first result. In case of any error, pcall returns false plus the error message.
* Calls function f with the given arguments in protected mode. This means that
* any error inside f is not propagated; instead, pcall catches the error and
* returns a status code. Its first result is the status code (a boolean), which
* is true if the call succeeds without errors. In such case, pcall also returns
* all results from the call, after this first result. In case of any error,
* pcall returns false plus the error message.
* @tupleReturn

@@ -156,3 +205,7 @@ */

/**
* Receives any number of arguments and prints their values to stdout, using the tostring function to convert each argument to a string. print is not intended for formatted output, but only as a quick way to show a value, for instance for debugging. For complete control over the output, use string.format and io.write.
* Receives any number of arguments and prints their values to stdout, using the
* tostring function to convert each argument to a string. print is not intended
* for formatted output, but only as a quick way to show a value, for instance
* for debugging. For complete control over the output, use string.format and
* io.write.
*/

@@ -162,3 +215,4 @@ declare function print(...args: any[]): void;

/**
* Checks whether v1 is equal to v2, without invoking the __eq metamethod. Returns a boolean.
* Checks whether v1 is equal to v2, without invoking the __eq metamethod.
* Returns a boolean.
*/

@@ -168,3 +222,4 @@ declare function rawequal<T>(v1: T, v2: T): boolean;

/**
* Gets the real value of table[index], without invoking the __index metamethod. table must be a table; index may be any value.
* Gets the real value of table[index], without invoking the __index metamethod.
* table must be a table; index may be any value.
*/

@@ -174,3 +229,4 @@ declare function rawget<T extends object, K extends keyof T>(table: T, index: K): T[K];

/**
* Returns the length of the object v, which must be a table or a string, without invoking the __len metamethod. Returns an integer.
* Returns the length of the object v, which must be a table or a string,
* without invoking the __len metamethod. Returns an integer.
*/

@@ -180,3 +236,5 @@ declare function rawlen(v: object | string): number;

/**
* Sets the real value of table[index] to value, without invoking the __newindex metamethod. table must be a table, index any value different from nil and NaN, and value any Lua value.
* Sets the real value of table[index] to value, without invoking the __newindex
* metamethod. table must be a table, index any value different from nil and
* NaN, and value any Lua value.
*

@@ -188,3 +246,6 @@ * This function returns table.

/**
* If index is a number, returns all arguments after argument number index; a negative number indexes from the end (-1 is the last argument). Otherwise, index must be the string "#", and select returns the total number of extra arguments it received.
* If index is a number, returns all arguments after argument number index; a
* negative number indexes from the end (-1 is the last argument). Otherwise,
* index must be the string "#", and select returns the total number of extra
* arguments it received.
* @tupleReturn

@@ -195,3 +256,6 @@ */

/**
* If index is a number, returns all arguments after argument number index; a negative number indexes from the end (-1 is the last argument). Otherwise, index must be the string "#", and select returns the total number of extra arguments it received.
* If index is a number, returns all arguments after argument number index; a
* negative number indexes from the end (-1 is the last argument). Otherwise,
* index must be the string "#", and select returns the total number of extra
* arguments it received.
*/

@@ -201,3 +265,6 @@ declare function select<T>(index: '#', ...args: T[]): number;

/**
* Sets the metatable for the given table. (To change the metatable of other types from Lua code, you must use the debug library (§6.10).) If metatable is nil, removes the metatable of the given table. If the original metatable has a __metatable field, raises an error.
* Sets the metatable for the given table. (To change the metatable of other
* types from Lua code, you must use the debug library (§6.10).) If metatable is
* nil, removes the metatable of the given table. If the original metatable has
* a __metatable field, raises an error.
*

@@ -212,7 +279,16 @@ * This function returns table.

/**
* When called with no base, tonumber tries to convert its argument to a number. If the argument is already a number or a string convertible to a number, then tonumber returns this number; otherwise, it returns nil.
* When called with no base, tonumber tries to convert its argument to a number.
* If the argument is already a number or a string convertible to a number, then
* tonumber returns this number; otherwise, it returns nil.
*
* The conversion of strings can result in integers or floats, according to the lexical conventions of Lua (see §3.1). (The string may have leading and trailing spaces and a sign.)
* The conversion of strings can result in integers or floats, according to the
* lexical conventions of Lua (see §3.1). (The string may have leading and
* trailing spaces and a sign.)
*
* When called with base, then e must be a string to be interpreted as an integer numeral in that base. The base may be any integer between 2 and 36, inclusive. In bases above 10, the letter 'A' (in either upper or lower case) represents 10, 'B' represents 11, and so forth, with 'Z' representing 35. If the string e is not a valid numeral in the given base, the function returns nil.
* When called with base, then e must be a string to be interpreted as an
* integer numeral in that base. The base may be any integer between 2 and 36,
* inclusive. In bases above 10, the letter 'A' (in either upper or lower case)
* represents 10, 'B' represents 11, and so forth, with 'Z' representing 35. If
* the string e is not a valid numeral in the given base, the function returns
* nil.
*/

@@ -222,5 +298,9 @@ declare function tonumber(e: any, base?: number): number | undefined;

/**
* Receives a value of any type and converts it to a string in a human-readable format. (For complete control of how numbers are converted, use string.format.)
* Receives a value of any type and converts it to a string in a human-readable
* format. (For complete control of how numbers are converted, use
* string.format.)
*
* If the metatable of v has a __tostring field, then tostring calls the corresponding value with v as argument, and uses the result of the call as its result.
* If the metatable of v has a __tostring field, then tostring calls the
* corresponding value with v as argument, and uses the result of the call as
* its result.
*/

@@ -227,0 +307,0 @@ declare function tostring(v: any): string;

@@ -6,9 +6,20 @@ // Based on https://www.lua.org/manual/5.3/manual.html#6.8

/**
* The I/O library provides two different styles for file manipulation. The first one uses implicit file handles; that is, there are operations to set a default input file and a default output file, and all input/output operations are over these default files. The second style uses explicit file handles.
* The I/O library provides two different styles for file manipulation. The
* first one uses implicit file handles; that is, there are operations to set a
* default input file and a default output file, and all input/output operations
* are over these default files. The second style uses explicit file handles.
*
* When using implicit file handles, all operations are supplied by table io. When using explicit file handles, the operation io.open returns a file handle and then all operations are supplied as methods of the file handle.
* When using implicit file handles, all operations are supplied by table io.
* When using explicit file handles, the operation io.open returns a file handle
* and then all operations are supplied as methods of the file handle.
*
* The table io also provides three predefined file handles with their usual meanings from C: io.stdin, io.stdout, and io.stderr. The I/O library never closes these files.
* The table io also provides three predefined file handles with their usual
* meanings from C: io.stdin, io.stdout, and io.stderr. The I/O library never
* closes these files.
*
* Unless otherwise stated, all I/O functions return nil on failure (plus an error message as a second result and a system-dependent error code as a third result) and some value different from nil on success. On non-POSIX systems, the computation of the error message and error code in case of errors may be not thread safe, because they rely on the global C variable errno.
* Unless otherwise stated, all I/O functions return nil on failure (plus an
* error message as a second result and a system-dependent error code as a third
* result) and some value different from nil on success. On non-POSIX systems,
* the computation of the error message and error code in case of errors may be
* not thread safe, because they rely on the global C variable errno.
*/

@@ -27,5 +38,9 @@ declare namespace io {

/**
* When called with a file name, it opens the named file (in text mode), and sets its handle as the default input file. When called with a file handle, it simply sets this file handle as the default input file. When called without parameters, it returns the current default input file.
* When called with a file name, it opens the named file (in text mode), and
* sets its handle as the default input file. When called with a file handle,
* it simply sets this file handle as the default input file. When called
* without parameters, it returns the current default input file.
*
* In case of errors this function raises the error, instead of returning an error code.
* In case of errors this function raises the error, instead of returning an
* error code.
*/

@@ -35,7 +50,13 @@ function input(file?: string | LuaFile): LuaFile;

/**
* Opens the given file name in read mode and returns an iterator function that works like file:lines(···) over the opened file. When the iterator function detects the end of file, it returns no values (to finish the loop) and automatically closes the file.
* Opens the given file name in read mode and returns an iterator function
* that works like file:lines(···) over the opened file. When the iterator
* function detects the end of file, it returns no values (to finish the loop)
* and automatically closes the file.
*
* The call io.lines() (with no file name) is equivalent to io.input():lines("*l"); that is, it iterates over the lines of the default input file. In this case it does not close the file when the loop ends.
* The call io.lines() (with no file name) is equivalent to
* io.input():lines("*l"); that is, it iterates over the lines of the default
* input file. In this case it does not close the file when the loop ends.
*
* In case of errors this function raises the error, instead of returning an error code.
* In case of errors this function raises the error, instead of returning an
* error code.
*/

@@ -50,3 +71,4 @@ function lines<T extends FileReadFormat[]>(

/**
* This function opens a file, in the mode specified in the string mode. In case of success, it returns a new file handle.
* This function opens a file, in the mode specified in the string mode. In
* case of success, it returns a new file handle.
*

@@ -60,5 +82,7 @@ * The mode string can be any of the following:

* * "w+": update mode, all previous data is erased;
* * "a+": append update mode, previous data is preserved, writing is only allowed at the end of file.
* * "a+": append update mode, previous data is preserved, writing is only
* allowed at the end of file.
*
* The mode string can also have a 'b' at the end, which is needed in some systems to open the file in binary mode.
* The mode string can also have a 'b' at the end, which is needed in some
* systems to open the file in binary mode.
* @tupleReturn

@@ -76,3 +100,5 @@ */

*
* Starts program prog in a separated process and returns a file handle that you can use to read data from this program (if mode is "r", the default) or to write data to this program (if mode is "w").
* Starts program prog in a separated process and returns a file handle that
* you can use to read data from this program (if mode is "r", the default) or
* to write data to this program (if mode is "w").
*/

@@ -88,3 +114,5 @@ function popen(prog: string, mode?: 'r' | 'w'): LuaFile;

/**
* In case of success, returns a handle for a temporary file. This file is opened in update mode and it is automatically removed when the program ends.
* In case of success, returns a handle for a temporary file. This file is
* opened in update mode and it is automatically removed when the program
* ends.
*/

@@ -94,3 +122,5 @@ function tmpfile(): LuaFile;

/**
* Checks whether obj is a valid file handle. Returns the string "file" if obj is an open file handle, "closed file" if obj is a closed file handle, or nil if obj is not a file handle.
* Checks whether obj is a valid file handle. Returns the string "file" if obj
* is an open file handle, "closed file" if obj is a closed file handle, or
* nil if obj is not a file handle.
*/

@@ -108,5 +138,8 @@ function type(obj: any): 'file' | 'closed file' | undefined;

/**
* Closes file. Note that files are automatically closed when their handles are garbage collected, but that takes an unpredictable amount of time to happen.
* Closes file. Note that files are automatically closed when their handles
* are garbage collected, but that takes an unpredictable amount of time to
* happen.
*
* When closing a file handle created with io.popen, file:close returns the same values returned by os.execute.
* When closing a file handle created with io.popen, file:close returns the
* same values returned by os.execute.
*/

@@ -121,9 +154,14 @@ close(): boolean;

/**
* Returns an iterator function that, each time it is called, reads the file according to the given formats. When no format is given, uses "l" as a default. As an example, the construction
* Returns an iterator function that, each time it is called, reads the file
* according to the given formats. When no format is given, uses "l" as a
* default. As an example, the construction
*
* `for c in file:lines(1) do body end`
*
* will iterate over all characters of the file, starting at the current position. Unlike io.lines, this function does not close the file when the loop ends.
* will iterate over all characters of the file, starting at the current
* position. Unlike io.lines, this function does not close the file when the
* loop ends.
*
* In case of errors this function raises the error, instead of returning an error code.
* In case of errors this function raises the error, instead of returning an
* error code.
*/

@@ -137,11 +175,26 @@ lines<T extends FileReadFormat[]>(

/**
* Reads the file file, according to the given formats, which specify what to read. For each format, the function returns a string or a number with the characters read, or nil if it cannot read data with the specified format. (In this latter case, the function does not read subsequent formats.) When called without formats, it uses a default format that reads the next line (see below).
* Reads the file file, according to the given formats, which specify what to
* read. For each format, the function returns a string or a number with the
* characters read, or nil if it cannot read data with the specified format.
* (In this latter case, the function does not read subsequent formats.) When
* called without formats, it uses a default format that reads the next line
* (see below).
*
* The available formats are
*
* * "n": reads a numeral and returns it as a float or an integer, following the lexical conventions of Lua. (The numeral may have leading spaces and a sign.) This format always reads the longest input sequence that is a valid prefix for a numeral; if that prefix does not form a valid numeral (e.g., an empty string, "0x", or "3.4e-"), it is discarded and the function returns nil.
* * "a": reads the whole file, starting at the current position. On end of file, it returns the empty string.
* * "l": reads the next line skipping the end of line, returning nil on end of file. This is the default format.
* * "L": reads the next line keeping the end-of-line character (if present), returning nil on end of file.
* * number: reads a string with up to this number of bytes, returning nil on end of file. If number is zero, it reads nothing and returns an empty string, or nil on end of file.
* * "n": reads a numeral and returns it as a float or an integer, following
* the lexical conventions of Lua. (The numeral may have leading spaces and
* a sign.) This format always reads the longest input sequence that is a
* valid prefix for a numeral; if that prefix does not form a valid numeral
* (e.g., an empty string, "0x", or "3.4e-"), it is discarded and the
* function returns nil.
* * "a": reads the whole file, starting at the current position. On end of
* file, it returns the empty string.
* * "l": reads the next line skipping the end of line, returning nil on end
* of file. This is the default format.
* * "L": reads the next line keeping the end-of-line character (if present),
* returning nil on end of file.
* * number: reads a string with up to this number of bytes, returning nil on
* end of file. If number is zero, it reads nothing and returns an empty
* string, or nil on end of file.
*

@@ -156,3 +209,5 @@ * The formats "l" and "L" should be used only for text files.

/**
* Sets and geionts the file position, measured from the beginning of the file, to the posit given by offset plus a base specified by the string whence, as follows:
* Sets and geionts the file position, measured from the beginning of the
* file, to the posit given by offset plus a base specified by the string
* whence, as follows:
*

@@ -163,5 +218,11 @@ * * "set": base is position 0 (beginning of the file);

*
* In case of success, seek returns the final file position, measured in bytes from the beginning of the file. If seek fails, it returns nil, plus a string describing the error.
* In case of success, seek returns the final file position, measured in bytes
* from the beginning of the file. If seek fails, it returns nil, plus a
* string describing the error.
*
* The default value for whence is "cur", and for offset is 0. Therefore, the call file:seek() returns the current file position, without changing it; the call file:seek("set") sets the position to the beginning of the file (and returns 0); and the call file:seek("end") sets the position to the end of the file, and returns its size.
* The default value for whence is "cur", and for offset is 0. Therefore, the
* call file:seek() returns the current file position, without changing it;
* the call file:seek("set") sets the position to the beginning of the file
* (and returns 0); and the call file:seek("end") sets the position to the end
* of the file, and returns its size.
* @tupleReturn

@@ -172,8 +233,13 @@ */

/**
* Sets the buffering mode for an output file. There are three available modes:
* Sets the buffering mode for an output file. There are three available
* modes:
*
* * "no": no buffering; the result of any output operation appears immediately.
* * "full": full buffering; output operation is performed only when the buffer is full or when you explicitly flush the file (see io.flush).
* * "line": line buffering; output is buffered until a newline is output or there is any input from some special files (such as a terminal device).
* For the last two cases, size specifies the size of the buffer, in bytes. The default is an appropriate size.
* * "no": no buffering; the result of any output operation appears
* immediately.
* * "full": full buffering; output operation is performed only when the
* buffer is full or when you explicitly flush the file (see io.flush).
* * "line": line buffering; output is buffered until a newline is output or
* there is any input from some special files (such as a terminal device).
* For the last two cases, size specifies the size of the buffer, in bytes.
* The default is an appropriate size.
*/

@@ -183,5 +249,7 @@ setvbuf(mode: 'no' | 'full' | 'line', size?: number): void;

/**
* Writes the value of each of its arguments to file. The arguments must be strings or numbers.
* Writes the value of each of its arguments to file. The arguments must be
* strings or numbers.
*
* In case of success, this function returns file. Otherwise it returns nil plus a string describing the error.
* In case of success, this function returns file. Otherwise it returns nil
* plus a string describing the error.
* @tupleReturn

@@ -188,0 +256,0 @@ */

@@ -6,3 +6,8 @@ // Based on https://www.lua.org/manual/5.3/manual.html#6.7

/**
* This library provides basic mathematical functions. It provides all its functions and constants inside the table math. Functions with the annotation "integer/float" give integer results for integer arguments and float results for float (or mixed) arguments. Rounding functions (math.ceil, math.floor, and math.modf) return an integer when the result fits in the range of an integer, or a float otherwise.
* This library provides basic mathematical functions. It provides all its
* functions and constants inside the table math. Functions with the annotation
* "integer/float" give integer results for integer arguments and float results
* for float (or mixed) arguments. Rounding functions (math.ceil, math.floor,
* and math.modf) return an integer when the result fits in the range of an
* integer, or a float otherwise.
*/

@@ -51,3 +56,4 @@ declare namespace math {

/**
* Returns the remainder of the division of x by y that rounds the quotient towards zero. (integer/float)
* Returns the remainder of the division of x by y that rounds the quotient
* towards zero. (integer/float)
*/

@@ -62,3 +68,4 @@ function fmod(x: number, y: number): number;

/**
* Returns the argument with the maximum value, according to the Lua operator <. (integer/float)
* Returns the argument with the maximum value, according to the Lua operator
* <. (integer/float)
*/

@@ -68,3 +75,4 @@ function max(x: number, ...numbers: number[]): number;

/**
* Returns the argument with the minimum value, according to the Lua operator <. (integer/float)
* Returns the argument with the minimum value, according to the Lua operator
* <. (integer/float)
*/

@@ -74,3 +82,4 @@ function min(x: number, ...numbers: number[]): number;

/**
* Returns the integral part of x and the fractional part of x. Its second result is always a float.
* Returns the integral part of x and the fractional part of x. Its second
* result is always a float.
*/

@@ -95,3 +104,4 @@ function modf(x: number): number;

/**
* Returns the square root of x. (You can also use the expression x^0.5 to compute this value.)
* Returns the square root of x. (You can also use the expression x^0.5 to
* compute this value.)
*/

@@ -98,0 +108,0 @@ function sqrt(x: number): number;

@@ -5,3 +5,9 @@ // Based on https://www.lua.org/manual/5.3/manual.html#2.4

/**
* the addition (+) operation. If any operand for an addition is not a number (nor a string coercible to a number), Lua will try to call a metamethod. First, Lua will check the first operand (even if it is valid). If that operand does not define a metamethod for __add, then Lua will check the second operand. If Lua can find a metamethod, it calls the metamethod with the two operands as arguments, and the result of the call (adjusted to one value) is the result of the operation. Otherwise, it raises an error.
* the addition (+) operation. If any operand for an addition is not a number
* (nor a string coercible to a number), Lua will try to call a metamethod.
* First, Lua will check the first operand (even if it is valid). If that
* operand does not define a metamethod for __add, then Lua will check the
* second operand. If Lua can find a metamethod, it calls the metamethod with
* the two operands as arguments, and the result of the call (adjusted to one
* value) is the result of the operation. Otherwise, it raises an error.
*/

@@ -16,3 +22,4 @@ __add?(this: T, operand: any): any;

/**
* the multiplication (*) operation. Behavior similar to the addition operation.
* the multiplication (*) operation. Behavior similar to the addition
* operation.
*/

@@ -32,3 +39,4 @@ __mul?(this: T, operand: any): any;

/**
* the exponentiation (^) operation. Behavior similar to the addition operation.
* the exponentiation (^) operation. Behavior similar to the addition
* operation.
*/

@@ -38,3 +46,4 @@ __pow?(this: T, operand: any): any;

/**
* the negation (unary -) operation. Behavior similar to the addition operation.
* the negation (unary -) operation. Behavior similar to the addition
* operation.
*/

@@ -44,3 +53,5 @@ __unm?(this: T, operand: any): any;

/**
* the concatenation (..) operation. Behavior similar to the addition operation, except that Lua will try a metamethod if any operand is neither a string nor a number (which is always coercible to a string).
* the concatenation (..) operation. Behavior similar to the addition
* operation, except that Lua will try a metamethod if any operand is neither
* a string nor a number (which is always coercible to a string).
*/

@@ -50,3 +61,8 @@ __concat?(this: T, operand: any): any;

/**
* the length (#) operation. If the object is not a string, Lua will try its metamethod. If there is a metamethod, Lua calls it with the object as argument, and the result of the call (always adjusted to one value) is the result of the operation. If there is no metamethod but the object is a table, then Lua uses the table length operation (see §3.4.7). Otherwise, Lua raises an error.
* the length (#) operation. If the object is not a string, Lua will try its
* metamethod. If there is a metamethod, Lua calls it with the object as
* argument, and the result of the call (always adjusted to one value) is the
* result of the operation. If there is no metamethod but the object is a
* table, then Lua uses the table length operation (see §3.4.7). Otherwise,
* Lua raises an error.
*/

@@ -56,3 +72,6 @@ __len?(this: T): any;

/**
* the equal (==) operation. Behavior similar to the addition operation, except that Lua will try a metamethod only when the values being compared are either both tables or both full userdata and they are not primitively equal. The result of the call is always converted to a boolean.
* the equal (==) operation. Behavior similar to the addition operation,
* except that Lua will try a metamethod only when the values being compared
* are either both tables or both full userdata and they are not primitively
* equal. The result of the call is always converted to a boolean.
*/

@@ -62,3 +81,6 @@ __eq?(this: T, operand: any): boolean;

/**
* the less than (<) operation. Behavior similar to the addition operation, except that Lua will try a metamethod only when the values being compared are neither both numbers nor both strings. The result of the call is always converted to a boolean.
* the less than (<) operation. Behavior similar to the addition operation,
* except that Lua will try a metamethod only when the values being compared
* are neither both numbers nor both strings. The result of the call is always
* converted to a boolean.
*/

@@ -68,3 +90,10 @@ __lt?(this: T, operand: any): boolean;

/**
* the less equal (<=) operation. Unlike other operations, the less-equal operation can use two different events. First, Lua looks for the __le metamethod in both operands, like in the less than operation. If it cannot find such a metamethod, then it will try the __lt metamethod, assuming that a <= b is equivalent to not (b < a). As with the other comparison operators, the result is always a boolean. (This use of the __lt event can be removed in future versions; it is also slower than a real __le metamethod.)
* the less equal (<=) operation. Unlike other operations, the less-equal
* operation can use two different events. First, Lua looks for the __le
* metamethod in both operands, like in the less than operation. If it cannot
* find such a metamethod, then it will try the __lt metamethod, assuming that
* a <= b is equivalent to not (b < a). As with the other comparison
* operators, the result is always a boolean. (This use of the __lt event can
* be removed in future versions; it is also slower than a real __le
* metamethod.)
*/

@@ -74,5 +103,12 @@ __le?(this: T, operand: any): boolean;

/**
* The indexing access table[key]. This event happens when table is not a table or when key is not present in table. The metamethod is looked up in table.
* The indexing access table[key]. This event happens when table is not a
* table or when key is not present in table. The metamethod is looked up in
* table.
*
* Despite the name, the metamethod for this event can be either a function or a table. If it is a function, it is called with table and key as arguments, and the result of the call (adjusted to one value) is the result of the operation. If it is a table, the final result is the result of indexing this table with key. (This indexing is regular, not raw, and therefore can trigger another metamethod.)
* Despite the name, the metamethod for this event can be either a function or
* a table. If it is a function, it is called with table and key as arguments,
* and the result of the call (adjusted to one value) is the result of the
* operation. If it is a table, the final result is the result of indexing
* this table with key. (This indexing is regular, not raw, and therefore can
* trigger another metamethod.)
*/

@@ -82,7 +118,15 @@ __index?: object | ((this: T, key: any, value: any) => any);

/**
* The indexing assignment table[key] = value. Like the index event, this event happens when table is not a table or when key is not present in table. The metamethod is looked up in table.
* The indexing assignment table[key] = value. Like the index event, this
* event happens when table is not a table or when key is not present in
* table. The metamethod is looked up in table.
*
* Like with indexing, the metamethod for this event can be either a function or a table. If it is a function, it is called with table, key, and value as arguments. If it is a table, Lua does an indexing assignment to this table with the same key and value. (This assignment is regular, not raw, and therefore can trigger another metamethod.)
* Like with indexing, the metamethod for this event can be either a function
* or a table. If it is a function, it is called with table, key, and value as
* arguments. If it is a table, Lua does an indexing assignment to this table
* with the same key and value. (This assignment is regular, not raw, and
* therefore can trigger another metamethod.)
*
* Whenever there is a __newindex metamethod, Lua does not perform the primitive assignment. (If necessary, the metamethod itself can call rawset to do the assignment.)
* Whenever there is a __newindex metamethod, Lua does not perform the
* primitive assignment. (If necessary, the metamethod itself can call rawset
* to do the assignment.)
*/

@@ -92,3 +136,8 @@ __newindex?: object | ((this: T, key: any, value: any) => void);

/**
* The call operation func(args). This event happens when Lua tries to call a non-function value (that is, func is not a function). The metamethod is looked up in func. If present, the metamethod is called with func as its first argument, followed by the arguments of the original call (args). All results of the call are the result of the operation. (This is the only metamethod that allows multiple results.)
* The call operation func(args). This event happens when Lua tries to call a
* non-function value (that is, func is not a function). The metamethod is
* looked up in func. If present, the metamethod is called with func as its
* first argument, followed by the arguments of the original call (args). All
* results of the call are the result of the operation. (This is the only
* metamethod that allows multiple results.)
*/

@@ -98,3 +147,5 @@ __call?(this: T, ...args: any[]): any;

/**
* If the metatable of v has a __tostring field, then tostring calls the corresponding value with v as argument, and uses the result of the call as its result.
* If the metatable of v has a __tostring field, then tostring calls the
* corresponding value with v as argument, and uses the result of the call as
* its result.
*/

@@ -104,3 +155,4 @@ __tostring?(this: T): string;

/**
* If this field is a string containing the character 'k', the keys in the table are weak. If it contains 'v', the values in the table are weak.
* If this field is a string containing the character 'k', the keys in the
* table are weak. If it contains 'v', the values in the table are weak.
*/

@@ -110,3 +162,4 @@ __mode?: 'k' | 'v' | 'kv';

/**
* If the object's metatable has this field, `getmetatable` returns the associated value.
* If the object's metatable has this field, `getmetatable` returns the
* associated value.
*/

@@ -116,5 +169,8 @@ __metatable?: any;

/**
* Userdata finalizer code. When userdata is set to be garbage collected, if the metatable has a __gc field pointing to a function, that function is first invoked, passing the userdata to it. The __gc metamethod is not called for tables.
* Userdata finalizer code. When userdata is set to be garbage collected, if
* the metatable has a __gc field pointing to a function, that function is
* first invoked, passing the userdata to it. The __gc metamethod is not
* called for tables.
*/
__gc?(this: T): void;
}

@@ -6,11 +6,28 @@ // Based on https://www.lua.org/manual/5.3/manual.html#6.3

/**
* Loads the given module. The function starts by looking into the package.loaded table to determine whether modname is already loaded. If it is, then require returns the value stored at package.loaded[modname]. Otherwise, it tries to find a loader for the module.
* Loads the given module. The function starts by looking into the
* package.loaded table to determine whether modname is already loaded. If it
* is, then require returns the value stored at package.loaded[modname].
* Otherwise, it tries to find a loader for the module.
*
* To find a loader, require is guided by the package.searchers sequence. By changing this sequence, we can change how require looks for a module. The following explanation is based on the default configuration for package.searchers.
* To find a loader, require is guided by the package.searchers sequence. By
* changing this sequence, we can change how require looks for a module. The
* following explanation is based on the default configuration for
* package.searchers.
*
* First require queries package.preload[modname]. If it has a value, this value (which must be a function) is the loader. Otherwise require searches for a Lua loader using the path stored in package.path. If that also fails, it searches for a C loader using the path stored in package.cpath. If that also fails, it tries an all-in-one loader (see package.searchers).
* First require queries package.preload[modname]. If it has a value, this value
* (which must be a function) is the loader. Otherwise require searches for a
* Lua loader using the path stored in package.path. If that also fails, it
* searches for a C loader using the path stored in package.cpath. If that also
* fails, it tries an all-in-one loader (see package.searchers).
*
* Once a loader is found, require calls the loader with two arguments: modname and an extra value dependent on how it got the loader. (If the loader came from a file, this extra value is the file name.) If the loader returns any non-nil value, require assigns the returned value to package.loaded[modname]. If the loader does not return a non-nil value and has not assigned any value to package.loaded[modname], then require assigns true to this entry. In any case, require returns the final value of package.loaded[modname].
* Once a loader is found, require calls the loader with two arguments: modname
* and an extra value dependent on how it got the loader. (If the loader came
* from a file, this extra value is the file name.) If the loader returns any
* non-nil value, require assigns the returned value to package.loaded[modname].
* If the loader does not return a non-nil value and has not assigned any value
* to package.loaded[modname], then require assigns true to this entry. In any
* case, require returns the final value of package.loaded[modname].
*
* If there is any error loading or running the module, or if it cannot find any loader for the module, then require raises an error.
* If there is any error loading or running the module, or if it cannot find any
* loader for the module, then require raises an error.
*/

@@ -20,12 +37,20 @@ declare function require(modname: string): any;

/**
* The package library provides basic facilities for loading modules in Lua. It exports one function directly in the global environment: require. Everything else is exported in a table package.
* The package library provides basic facilities for loading modules in Lua. It
* exports one function directly in the global environment: require. Everything
* else is exported in a table package.
*/
declare namespace package {
/**
* A string describing some compile-time configurations for packages. This string is a sequence of lines:
* * The first line is the directory separator string. Default is '\' for Windows and '/' for all other systems.
* * The second line is the character that separates templates in a path. Default is ';'.
* * The third line is the string that marks the substitution points in a template. Default is '?'.
* * The fourth line is a string that, in a path in Windows, is replaced by the executable's directory. Default is '!'.
* * The fifth line is a mark to ignore all text after it when building the luaopen_ function name. Default is '-'.
* A string describing some compile-time configurations for packages. This
* string is a sequence of lines:
* * The first line is the directory separator string. Default is '\' for
* Windows and '/' for all other systems.
* * The second line is the character that separates templates in a path.
* Default is ';'.
* * The third line is the string that marks the substitution points in a
* template. Default is '?'.
* * The fourth line is a string that, in a path in Windows, is replaced by
* the executable's directory. Default is '!'.
* * The fifth line is a mark to ignore all text after it when building the
* luaopen_ function name. Default is '-'.
*/

@@ -37,3 +62,5 @@ var config: string;

*
* Lua initializes the C path package.cpath in the same way it initializes the Lua path package.path, using the environment variable LUA_CPATH_5_3, or the environment variable LUA_CPATH, or a default path defined in luaconf.h.
* Lua initializes the C path package.cpath in the same way it initializes the
* Lua path package.path, using the environment variable LUA_CPATH_5_3, or the
* environment variable LUA_CPATH, or a default path defined in luaconf.h.
*/

@@ -43,5 +70,8 @@ var cpath: string;

/**
* A table used by require to control which modules are already loaded. When you require a module modname and package.loaded[modname] is not false, require simply returns the value stored there.
* A table used by require to control which modules are already loaded. When
* you require a module modname and package.loaded[modname] is not false,
* require simply returns the value stored there.
*
* This variable is only a reference to the real table; assignments to this variable do not change the table used by require.
* This variable is only a reference to the real table; assignments to this
* variable do not change the table used by require.
*/

@@ -53,7 +83,18 @@ const loaded: Record<string, any>;

*
* If funcname is "*", then it only links with the library, making the symbols exported by the library available to other dynamically linked libraries. Otherwise, it looks for a function funcname inside the library and returns this function as a C function. So, funcname must follow the lua_CFunction prototype (see lua_CFunction).
* If funcname is "*", then it only links with the library, making the symbols
* exported by the library available to other dynamically linked libraries.
* Otherwise, it looks for a function funcname inside the library and returns
* this function as a C function. So, funcname must follow the lua_CFunction
* prototype (see lua_CFunction).
*
* This is a low-level function. It completely bypasses the package and module system. Unlike require, it does not perform any path searching and does not automatically adds extensions. libname must be the complete file name of the C library, including if necessary a path and an extension. funcname must be the exact name exported by the C library (which may depend on the C compiler and linker used).
* This is a low-level function. It completely bypasses the package and module
* system. Unlike require, it does not perform any path searching and does not
* automatically adds extensions. libname must be the complete file name of
* the C library, including if necessary a path and an extension. funcname
* must be the exact name exported by the C library (which may depend on the C
* compiler and linker used).
*
* This function is not supported by Standard C. As such, it is only available on some platforms (Windows, Linux, Mac OS X, Solaris, BSD, plus other Unix systems that support the dlfcn standard).
* This function is not supported by Standard C. As such, it is only available
* on some platforms (Windows, Linux, Mac OS X, Solaris, BSD, plus other Unix
* systems that support the dlfcn standard).
*/

@@ -68,3 +109,7 @@ function loadlib(

*
* At start-up, Lua initializes this variable with the value of the environment variable LUA_PATH_5_3 or the environment variable LUA_PATH or with a default path defined in luaconf.h, if those environment variables are not defined. Any ";;" in the value of the environment variable is replaced by the default path.
* At start-up, Lua initializes this variable with the value of the
* environment variable LUA_PATH_5_3 or the environment variable LUA_PATH or
* with a default path defined in luaconf.h, if those environment variables
* are not defined. Any ";;" in the value of the environment variable is
* replaced by the default path.
*/

@@ -76,3 +121,4 @@ var path: string;

*
* This variable is only a reference to the real table; assignments to this variable do not change the table used by require.
* This variable is only a reference to the real table; assignments to this
* variable do not change the table used by require.
*/

@@ -84,3 +130,7 @@ const preload: Record<string, (modname: string, fileName?: string) => any>;

*
* A path is a string containing a sequence of templates separated by semicolons. For each template, the function replaces each interrogation mark (if any) in the template with a copy of name wherein all occurrences of sep (a dot, by default) were replaced by rep (the system's directory separator, by default), and then tries to open the resulting file name.
* A path is a string containing a sequence of templates separated by
* semicolons. For each template, the function replaces each interrogation
* mark (if any) in the template with a copy of name wherein all occurrences
* of sep (a dot, by default) were replaced by rep (the system's directory
* separator, by default), and then tries to open the resulting file name.
*

@@ -91,7 +141,10 @@ * For instance, if the path is the string

*
* the search for the name foo.a will try to open the files ./foo/a.lua, ./foo/a.lc, and /usr/local/foo/a/init.lua, in that order.
* the search for the name foo.a will try to open the files ./foo/a.lua,
* ./foo/a.lc, and /usr/local/foo/a/init.lua, in that order.
*
* Returns the resulting name of the first file that it can open in read mode (after closing the file), or nil plus an error message if none succeeds. (This error message lists all file names it tried to open.)
* Returns the resulting name of the first file that it can open in read mode
* (after closing the file), or nil plus an error message if none succeeds.
* (This error message lists all file names it tried to open.)
*/
function searchpath(name: string, path: string, sep?: string, rep?: string): string;
}

@@ -32,3 +32,4 @@ // Based on https://www.lua.org/manual/5.3/manual.html#6.9

/**
* Returns an approximation of the amount in seconds of CPU time used by the program.
* Returns an approximation of the amount in seconds of CPU time used by the
* program.
*/

@@ -38,13 +39,26 @@ function clock(): number;

/**
* Returns a string or a table containing date and time, formatted according to the given string format.
* Returns a string or a table containing date and time, formatted according
* to the given string format.
*
* If the time argument is present, this is the time to be formatted (see the os.time function for a description of this value). Otherwise, date formats the current time.
* If the time argument is present, this is the time to be formatted (see the
* os.time function for a description of this value). Otherwise, date formats
* the current time.
*
* If format starts with '!', then the date is formatted in Coordinated Universal Time. After this optional character, if format is the string "*t", then date returns a table with the following fields: year, month (1–12), day (1–31), hour (0–23), min (0–59), sec (0–61), wday (weekday, 1–7, Sunday is 1), yday (day of the year, 1–366), and isdst (daylight saving flag, a boolean). This last field may be absent if the information is not available.
* If format starts with '!', then the date is formatted in Coordinated
* Universal Time. After this optional character, if format is the string
* "*t", then date returns a table with the following fields: year, month
* (1–12), day (1–31), hour (0–23), min (0–59), sec (0–61), wday (weekday,
* 1–7, Sunday is 1), yday (day of the year, 1–366), and isdst (daylight
* saving flag, a boolean). This last field may be absent if the information
* is not available.
*
* If format is not "*t", then date returns the date as a string, formatted according to the same rules as the ISO C function strftime.
* If format is not "*t", then date returns the date as a string, formatted
* according to the same rules as the ISO C function strftime.
*
* When called without arguments, date returns a reasonable date and time representation that depends on the host system and on the current locale. (More specifically, os.date() is equivalent to os.date("%c").)
* When called without arguments, date returns a reasonable date and time
* representation that depends on the host system and on the current locale.
* (More specifically, os.date() is equivalent to os.date("%c").)
*
* On non-POSIX systems, this function may be not thread safe because of its reliance on C function gmtime and C function localtime.
* On non-POSIX systems, this function may be not thread safe because of its
* reliance on C function gmtime and C function localtime.
*/

@@ -54,13 +68,26 @@ function date(format?: string, time?: number): string;

/**
* Returns a string or a table containing date and time, formatted according to the given string format.
* Returns a string or a table containing date and time, formatted according
* to the given string format.
*
* If the time argument is present, this is the time to be formatted (see the os.time function for a description of this value). Otherwise, date formats the current time.
* If the time argument is present, this is the time to be formatted (see the
* os.time function for a description of this value). Otherwise, date formats
* the current time.
*
* If format starts with '!', then the date is formatted in Coordinated Universal Time. After this optional character, if format is the string "*t", then date returns a table with the following fields: year, month (1–12), day (1–31), hour (0–23), min (0–59), sec (0–61), wday (weekday, 1–7, Sunday is 1), yday (day of the year, 1–366), and isdst (daylight saving flag, a boolean). This last field may be absent if the information is not available.
* If format starts with '!', then the date is formatted in Coordinated
* Universal Time. After this optional character, if format is the string
* "*t", then date returns a table with the following fields: year, month
* (1–12), day (1–31), hour (0–23), min (0–59), sec (0–61), wday (weekday,
* 1–7, Sunday is 1), yday (day of the year, 1–366), and isdst (daylight
* saving flag, a boolean). This last field may be absent if the information
* is not available.
*
* If format is not "*t", then date returns the date as a string, formatted according to the same rules as the ISO C function strftime.
* If format is not "*t", then date returns the date as a string, formatted
* according to the same rules as the ISO C function strftime.
*
* When called without arguments, date returns a reasonable date and time representation that depends on the host system and on the current locale. (More specifically, os.date() is equivalent to os.date("%c").)
* When called without arguments, date returns a reasonable date and time
* representation that depends on the host system and on the current locale.
* (More specifically, os.date() is equivalent to os.date("%c").)
*
* On non-POSIX systems, this function may be not thread safe because of its reliance on C function gmtime and C function localtime.
* On non-POSIX systems, this function may be not thread safe because of its
* reliance on C function gmtime and C function localtime.
*/

@@ -70,3 +97,5 @@ function date(format: '*t', time?: number): LuaDateInfoResult;

/**
* Returns the difference, in seconds, from time t1 to time t2 (where the times are values returned by os.time). In POSIX, Windows, and some other systems, this value is exactly t2-t1.
* Returns the difference, in seconds, from time t1 to time t2 (where the
* times are values returned by os.time). In POSIX, Windows, and some other
* systems, this value is exactly t2-t1.
*/

@@ -76,3 +105,4 @@ function difftime(t1: number, t2: number): number;

/**
* Returns the value of the process environment variable varname, or nil if the variable is not defined.
* Returns the value of the process environment variable varname, or nil if
* the variable is not defined.
*/

@@ -82,3 +112,5 @@ function getenv(varname: string): string | undefined;

/**
* Deletes the file (or empty directory, on POSIX systems) with the given name. If this function fails, it returns nil, plus a string describing the error and the error code. Otherwise, it returns true.
* Deletes the file (or empty directory, on POSIX systems) with the given
* name. If this function fails, it returns nil, plus a string describing the
* error and the error code. Otherwise, it returns true.
* @tupleReturn

@@ -89,3 +121,5 @@ */

/**
* Renames the file or directory named oldname to newname. If this function fails, it returns nil, plus a string describing the error and the error code. Otherwise, it returns true.
* Renames the file or directory named oldname to newname. If this function
* fails, it returns nil, plus a string describing the error and the error
* code. Otherwise, it returns true.
* @tupleReturn

@@ -96,9 +130,17 @@ */

/**
* Sets the current locale of the program. locale is a system-dependent string specifying a locale; category is an optional string describing which category to change: "all", "collate", "ctype", "monetary", "numeric", or "time"; the default category is "all". The function returns the name of the new locale, or nil if the request cannot be honored.
* Sets the current locale of the program. locale is a system-dependent string
* specifying a locale; category is an optional string describing which
* category to change: "all", "collate", "ctype", "monetary", "numeric", or
* "time"; the default category is "all". The function returns the name of the
* new locale, or nil if the request cannot be honored.
*
* If locale is the empty string, the current locale is set to an implementation-defined native locale. If locale is the string "C", the current locale is set to the standard C locale.
* If locale is the empty string, the current locale is set to an
* implementation-defined native locale. If locale is the string "C", the
* current locale is set to the standard C locale.
*
* When called with nil as the first argument, this function only returns the name of the current locale for the given category.
* When called with nil as the first argument, this function only returns the
* name of the current locale for the given category.
*
* This function may be not thread safe because of its reliance on C function setlocale.
* This function may be not thread safe because of its reliance on C function
* setlocale.
*/

@@ -111,7 +153,19 @@ function setlocale(

/**
* Returns the current time when called without arguments, or a time representing the local date and time specified by the given table. This table must have fields year, month, and day, and may have fields hour (default is 12), min (default is 0), sec (default is 0), and isdst (default is nil). Other fields are ignored. For a description of these fields, see the os.date function.
* Returns the current time when called without arguments, or a time
* representing the local date and time specified by the given table. This
* table must have fields year, month, and day, and may have fields hour
* (default is 12), min (default is 0), sec (default is 0), and isdst (default
* is nil). Other fields are ignored. For a description of these fields, see
* the os.date function.
*
* The values in these fields do not need to be inside their valid ranges. For instance, if sec is -10, it means -10 seconds from the time specified by the other fields; if hour is 1000, it means +1000 hours from the time specified by the other fields.
* The values in these fields do not need to be inside their valid ranges. For
* instance, if sec is -10, it means -10 seconds from the time specified by
* the other fields; if hour is 1000, it means +1000 hours from the time
* specified by the other fields.
*
* The returned value is a number, whose meaning depends on your system. In POSIX, Windows, and some other systems, this number counts the number of seconds since some given start time (the "epoch"). In other systems, the meaning is not specified, and the number returned by time can be used only as an argument to os.date and os.difftime.
* The returned value is a number, whose meaning depends on your system. In
* POSIX, Windows, and some other systems, this number counts the number of
* seconds since some given start time (the "epoch"). In other systems, the
* meaning is not specified, and the number returned by time can be used only
* as an argument to os.date and os.difftime.
*/

@@ -121,7 +175,19 @@ function time(): number;

/**
* Returns the current time when called without arguments, or a time representing the local date and time specified by the given table. This table must have fields year, month, and day, and may have fields hour (default is 12), min (default is 0), sec (default is 0), and isdst (default is nil). Other fields are ignored. For a description of these fields, see the os.date function.
* Returns the current time when called without arguments, or a time
* representing the local date and time specified by the given table. This
* table must have fields year, month, and day, and may have fields hour
* (default is 12), min (default is 0), sec (default is 0), and isdst (default
* is nil). Other fields are ignored. For a description of these fields, see
* the os.date function.
*
* The values in these fields do not need to be inside their valid ranges. For instance, if sec is -10, it means -10 seconds from the time specified by the other fields; if hour is 1000, it means +1000 hours from the time specified by the other fields.
* The values in these fields do not need to be inside their valid ranges. For
* instance, if sec is -10, it means -10 seconds from the time specified by
* the other fields; if hour is 1000, it means +1000 hours from the time
* specified by the other fields.
*
* The returned value is a number, whose meaning depends on your system. In POSIX, Windows, and some other systems, this number counts the number of seconds since some given start time (the "epoch"). In other systems, the meaning is not specified, and the number returned by time can be used only as an argument to os.date and os.difftime.
* The returned value is a number, whose meaning depends on your system. In
* POSIX, Windows, and some other systems, this number counts the number of
* seconds since some given start time (the "epoch"). In other systems, the
* meaning is not specified, and the number returned by time can be used only
* as an argument to os.date and os.difftime.
*/

@@ -131,9 +197,16 @@ function time(table: LuaDateInfo): number;

/**
* Returns a string with a file name that can be used for a temporary file. The file must be explicitly opened before its use and explicitly removed when no longer needed.
* Returns a string with a file name that can be used for a temporary file.
* The file must be explicitly opened before its use and explicitly removed
* when no longer needed.
*
* On POSIX systems, this function also creates a file with that name, to avoid security risks. (Someone else might create the file with wrong permissions in the time between getting the name and creating the file.) You still have to open the file to use it and to remove it (even if you do not use it).
* On POSIX systems, this function also creates a file with that name, to
* avoid security risks. (Someone else might create the file with wrong
* permissions in the time between getting the name and creating the file.)
* You still have to open the file to use it and to remove it (even if you do
* not use it).
*
* When possible, you may prefer to use io.tmpfile, which automatically removes the file when the program ends.
* When possible, you may prefer to use io.tmpfile, which automatically
* removes the file when the program ends.
*/
function tmpname(): string;
}

@@ -6,5 +6,13 @@ // Based on https://www.lua.org/manual/5.3/manual.html#6.4

/**
* This library provides generic functions for string manipulation, such as finding and extracting substrings, and pattern matching. When indexing a string in Lua, the first character is at position 1 (not at 0, as in C). Indices are allowed to be negative and are interpreted as indexing backwards, from the end of the string. Thus, the last character is at position -1, and so on.
* This library provides generic functions for string manipulation, such as
* finding and extracting substrings, and pattern matching. When indexing a
* string in Lua, the first character is at position 1 (not at 0, as in C).
* Indices are allowed to be negative and are interpreted as indexing backwards,
* from the end of the string. Thus, the last character is at position -1, and
* so on.
*
* The string library provides all its functions inside the table string. It also sets a metatable for strings where the __index field points to the string table. Therefore, you can use the string functions in object-oriented style. For instance, string.byte(s,i) can be written as s:byte(i).
* The string library provides all its functions inside the table string. It
* also sets a metatable for strings where the __index field points to the
* string table. Therefore, you can use the string functions in object-oriented
* style. For instance, string.byte(s,i) can be written as s:byte(i).
*

@@ -15,3 +23,5 @@ * The string library assumes one-byte character encodings.

/**
* Returns the internal numeric codes of the characters s[i], s[i+1], ..., s[j]. The default value for i is 1; the default value for j is i. These indices are corrected following the same rules of function string.sub.
* Returns the internal numeric codes of the characters s[i], s[i+1], ...,
* s[j]. The default value for i is 1; the default value for j is i. These
* indices are corrected following the same rules of function string.sub.
*

@@ -23,3 +33,5 @@ * Numeric codes are not necessarily portable across platforms.

/**
* Receives zero or more integers. Returns a string with length equal to the number of arguments, in which each character has the internal numeric code equal to its corresponding argument.
* Receives zero or more integers. Returns a string with length equal to the
* number of arguments, in which each character has the internal numeric code
* equal to its corresponding argument.
*

@@ -31,3 +43,5 @@ * Numeric codes are not necessarily portable across platforms.

/**
* Returns a string containing a binary representation of the given function, so that a later load on this string returns a copy of the function (but with new upvalues).
* Returns a string containing a binary representation of the given function,
* so that a later load on this string returns a copy of the function (but
* with new upvalues).
*/

@@ -37,5 +51,13 @@ function dump(func: Function): string;

/**
* Looks for the first match of pattern (see §6.4.1) in the string s. If it finds a match, then find returns the indices of s where this occurrence starts and ends; otherwise, it returns nil. A third, optional numeric argument init specifies where to start the search; its default value is 1 and can be negative. A value of true as a fourth, optional argument plain turns off the pattern matching facilities, so the function does a plain "find substring" operation, with no characters in pattern being considered magic. Note that if plain is given, then init must be given as well.
* Looks for the first match of pattern (see §6.4.1) in the string s. If it
* finds a match, then find returns the indices of s where this occurrence
* starts and ends; otherwise, it returns nil. A third, optional numeric
* argument init specifies where to start the search; its default value is 1
* and can be negative. A value of true as a fourth, optional argument plain
* turns off the pattern matching facilities, so the function does a plain
* "find substring" operation, with no characters in pattern being considered
* magic. Note that if plain is given, then init must be given as well.
*
* If the pattern has captures, then in a successful match the captured values are also returned, after the two indices.
* If the pattern has captures, then in a successful match the captured values
* are also returned, after the two indices.
* @tupleReturn

@@ -46,5 +68,11 @@ */

/**
* Returns a formatted version of its variable number of arguments following the description given in its first argument (which must be a string). The format string follows the same rules as the ISO C function sprintf. The only differences are that the options/modifiers *, h, L, l, n, and p are not supported and that there is an extra option, q.
* Returns a formatted version of its variable number of arguments following
* the description given in its first argument (which must be a string). The
* format string follows the same rules as the ISO C function sprintf. The
* only differences are that the options/modifiers *, h, L, l, n, and p are
* not supported and that there is an extra option, q.
*
* The q option formats a string between double quotes, using escape sequences when necessary to ensure that it can safely be read back by the Lua interpreter. For instance, the call
* The q option formats a string between double quotes, using escape sequences
* when necessary to ensure that it can safely be read back by the Lua
* interpreter. For instance, the call
*

@@ -56,6 +84,11 @@ * `string.format('%q', 'a string with "quotes" and \n new line')`

* `"a string with \"quotes\" and \
* new line"`
* Options A, a, E, e, f, G, and g all expect a number as argument. Options c, d, i, o, u, X, and x expect an integer. When Lua is compiled with a C89 compiler, options A and a (hexadecimal floats) do not support any modifier (flags, width, length).
* new line"` Options A, a, E, e, f, G, and g all expect a number as
* argument. Options c, d, i, o, u, X, and x expect an integer. When Lua is
* compiled with a C89 compiler, options A and a (hexadecimal floats) do not
* support any modifier (flags, width, length).
*
* Option s expects a string; if its argument is not a string, it is converted to one following the same rules of tostring. If the option has any modifier (flags, width, length), the string argument should not contain embedded zeros.
* Option s expects a string; if its argument is not a string, it is converted
* to one following the same rules of tostring. If the option has any modifier
* (flags, width, length), the string argument should not contain embedded
* zeros.
*/

@@ -65,5 +98,8 @@ function format(formatstring: string, ...args: any[]): string;

/**
* Returns an iterator function that, each time it is called, returns the next captures from pattern (see §6.4.1) over the string s. If pattern specifies no captures, then the whole match is produced in each call.
* Returns an iterator function that, each time it is called, returns the next
* captures from pattern (see §6.4.1) over the string s. If pattern specifies
* no captures, then the whole match is produced in each call.
*
* As an example, the following loop will iterate over all the words from string s, printing one per line:
* As an example, the following loop will iterate over all the words from
* string s, printing one per line:
*

@@ -77,3 +113,4 @@ * ```

*
* The next example collects all pairs key=value from the given string into a table:
* The next example collects all pairs key=value from the given string into a
* table:
*

@@ -88,3 +125,4 @@ * ```

*
* For this function, a caret '^' at the start of a pattern does not work as an anchor, as this would prevent the iteration.
* For this function, a caret '^' at the start of a pattern does not work as
* an anchor, as this would prevent the iteration.
*/

@@ -94,13 +132,27 @@ function gmatch(s: string, pattern: string): LuaTupleIterable<string[]>;

/**
* Returns a copy of s in which all (or the first n, if given) occurrences of the pattern (see §6.4.1) have been replaced by a replacement string specified by repl, which can be a string, a table, or a function. gsub also returns, as its second value, the total number of matches that occurred. The name gsub comes from Global SUBstitution.
* Returns a copy of s in which all (or the first n, if given) occurrences of
* the pattern (see §6.4.1) have been replaced by a replacement string
* specified by repl, which can be a string, a table, or a function. gsub also
* returns, as its second value, the total number of matches that occurred.
* The name gsub comes from Global SUBstitution.
*
* If repl is a string, then its value is used for replacement. The character % works as an escape character: any sequence in repl of the form %d, with d between 1 and 9, stands for the value of the d-th captured substring. The sequence %0 stands for the whole match. The sequence %% stands for a single %.
* If repl is a string, then its value is used for replacement. The character
* % works as an escape character: any sequence in repl of the form %d, with d
* between 1 and 9, stands for the value of the d-th captured substring. The
* sequence %0 stands for the whole match. The sequence %% stands for a single
* %.
*
* If repl is a table, then the table is queried for every match, using the first capture as the key.
* If repl is a table, then the table is queried for every match, using the
* first capture as the key.
*
* If repl is a function, then this function is called every time a match occurs, with all captured substrings passed as arguments, in order.
* If repl is a function, then this function is called every time a match
* occurs, with all captured substrings passed as arguments, in order.
*
* In any case, if the pattern specifies no captures, then it behaves as if the whole pattern was inside a capture.
* In any case, if the pattern specifies no captures, then it behaves as if
* the whole pattern was inside a capture.
*
* If the value returned by the table query or by the function call is a string or a number, then it is used as the replacement string; otherwise, if it is false or nil, then there is no replacement (that is, the original match is kept in the string).
* If the value returned by the table query or by the function call is a
* string or a number, then it is used as the replacement string; otherwise,
* if it is false or nil, then there is no replacement (that is, the original
* match is kept in the string).
* @tupleReturn

@@ -116,3 +168,4 @@ */

/**
* Receives a string and returns its length. The empty string "" has length 0. Embedded zeros are counted, so "a\000bc\000" has length 5.
* Receives a string and returns its length. The empty string "" has length 0.
* Embedded zeros are counted, so "a\000bc\000" has length 5.
*/

@@ -122,3 +175,5 @@ function len(s: string): number;

/**
* Receives a string and returns a copy of this string with all uppercase letters changed to lowercase. All other characters are left unchanged. The definition of what an uppercase letter is depends on the current locale.
* Receives a string and returns a copy of this string with all uppercase
* letters changed to lowercase. All other characters are left unchanged. The
* definition of what an uppercase letter is depends on the current locale.
*/

@@ -128,3 +183,7 @@ function lower(s: string): string;

/**
* Looks for the first match of pattern (see §6.4.1) in the string s. If it finds one, then match returns the captures from the pattern; otherwise it returns nil. If pattern specifies no captures, then the whole match is returned. A third, optional numeric argument init specifies where to start the search; its default value is 1 and can be negative.
* Looks for the first match of pattern (see §6.4.1) in the string s. If it
* finds one, then match returns the captures from the pattern; otherwise it
* returns nil. If pattern specifies no captures, then the whole match is
* returned. A third, optional numeric argument init specifies where to start
* the search; its default value is 1 and can be negative.
*/

@@ -139,5 +198,12 @@ function match(s: string, pattern: string, init?: number): string[];

/**
* Returns the substring of s that starts at i and continues until j; i and j can be negative. If j is absent, then it is assumed to be equal to -1 (which is the same as the string length). In particular, the call string.sub(s,1,j) returns a prefix of s with length j, and string.sub(s, -i) (for a positive i) returns a suffix of s with length i.
* Returns the substring of s that starts at i and continues until j; i and j
* can be negative. If j is absent, then it is assumed to be equal to -1
* (which is the same as the string length). In particular, the call
* string.sub(s,1,j) returns a prefix of s with length j, and string.sub(s,
* -i) (for a positive i) returns a suffix of s with length i.
*
* If, after the translation of negative indices, i is less than 1, it is corrected to 1. If j is greater than the string length, it is corrected to that length. If, after these corrections, i is greater than j, the function returns the empty string.
* If, after the translation of negative indices, i is less than 1, it is
* corrected to 1. If j is greater than the string length, it is corrected to
* that length. If, after these corrections, i is greater than j, the function
* returns the empty string.
*/

@@ -147,5 +213,7 @@ function sub(s: string, i: number, j?: number): string;

/**
* Receives a string and returns a copy of this string with all lowercase letters changed to uppercase. All other characters are left unchanged. The definition of what a lowercase letter is depends on the current locale.
* Receives a string and returns a copy of this string with all lowercase
* letters changed to uppercase. All other characters are left unchanged. The
* definition of what a lowercase letter is depends on the current locale.
*/
function upper(s: string): string;
}

@@ -6,9 +6,15 @@ // Based on https://www.lua.org/manual/5.3/manual.html#6.6

/**
* This library provides generic functions for table manipulation. It provides all its functions inside the table table.
* This library provides generic functions for table manipulation. It provides
* all its functions inside the table table.
*
* Remember that, whenever an operation needs the length of a table, all caveats about the length operator apply (see §3.4.7). All functions ignore non-numeric keys in the tables given as arguments.
* Remember that, whenever an operation needs the length of a table, all caveats
* about the length operator apply (see §3.4.7). All functions ignore
* non-numeric keys in the tables given as arguments.
*/
declare namespace table {
/**
* Given a list where all elements are strings or numbers, returns the string list[i]..sep..list[i+1] ··· sep..list[j]. The default value for sep is the empty string, the default for i is 1, and the default for j is #list. If i is greater than j, returns the empty string.
* Given a list where all elements are strings or numbers, returns the string
* list[i]..sep..list[i+1] ··· sep..list[j]. The default value for sep is the
* empty string, the default for i is 1, and the default for j is #list. If i
* is greater than j, returns the empty string.
*/

@@ -18,3 +24,5 @@ function concat(list: (string | number)[], sep?: string, i?: number, j?: number): string;

/**
* Inserts element value at position pos in list, shifting up the elements list[pos], list[pos+1], ···, list[#list]. The default value for pos is #list+1, so that a call table.insert(t,x) inserts x at the end of list t.
* Inserts element value at position pos in list, shifting up the elements
* list[pos], list[pos+1], ···, list[#list]. The default value for pos is
* #list+1, so that a call table.insert(t,x) inserts x at the end of list t.
*/

@@ -25,5 +33,10 @@ function insert<T>(list: T[], value: T): void;

/**
* Removes from list the element at position pos, returning the value of the removed element. When pos is an integer between 1 and #list, it shifts down the elements list[pos+1], list[pos+2], ···, list[#list] and erases element list[#list]; The index pos can also be 0 when #list is 0, or #list + 1; in those cases, the function erases the element list[pos].
* Removes from list the element at position pos, returning the value of the
* removed element. When pos is an integer between 1 and #list, it shifts down
* the elements list[pos+1], list[pos+2], ···, list[#list] and erases element
* list[#list]; The index pos can also be 0 when #list is 0, or #list + 1; in
* those cases, the function erases the element list[pos].
*
* The default value for pos is #list, so that a call table.remove(l) removes the last element of list l.
* The default value for pos is #list, so that a call table.remove(l) removes
* the last element of list l.
*/

@@ -33,9 +46,17 @@ function remove<T>(list: T[], pos?: number): T | undefined;

/**
* Sorts list elements in a given order, in-place, from list[1] to list[#list]. If comp is given, then it must be a function that receives two list elements and returns true when the first element must come before the second in the final order (so that, after the sort, i < j implies not comp(list[j],list[i])). If comp is not given, then the standard Lua operator < is used instead.
* Sorts list elements in a given order, in-place, from list[1] to
* list[#list]. If comp is given, then it must be a function that receives two
* list elements and returns true when the first element must come before the
* second in the final order (so that, after the sort, i < j implies not
* comp(list[j],list[i])). If comp is not given, then the standard Lua
* operator < is used instead.
*
* Note that the comp function must define a strict partial order over the elements in the list; that is, it must be asymmetric and transitive. Otherwise, no valid sort may be possible.
* Note that the comp function must define a strict partial order over the
* elements in the list; that is, it must be asymmetric and transitive.
* Otherwise, no valid sort may be possible.
*
* The sort algorithm is not stable: elements considered equal by the given order may have their relative positions changed by the sort.
* The sort algorithm is not stable: elements considered equal by the given
* order may have their relative positions changed by the sort.
*/
function sort<T>(list: T[], comp?: (a: T, b: T) => boolean): void;
}
{
"name": "lua-types",
"version": "2.5.1",
"version": "2.5.2",
"description": "TypeScript definitions for Lua standard library",

@@ -5,0 +5,0 @@ "keywords": [

/** @noSelfInFile */
/**
* Loads a chunk using function func to get its pieces. Each call to func must return a string that concatenates with previous results. A return of an empty string, nil, or no value signals the end of the chunk.
* Loads a chunk using function func to get its pieces. Each call to func must
* return a string that concatenates with previous results. A return of an empty
* string, nil, or no value signals the end of the chunk.
*
* If there are no errors, returns the compiled chunk as a function; otherwise, returns nil plus the error message. The environment of the returned function is the global environment.
* If there are no errors, returns the compiled chunk as a function; otherwise,
* returns nil plus the error message. The environment of the returned function
* is the global environment.
*
* chunkname is used as the chunk name for error messages and debug information. When absent, it defaults to "=(load)".
* chunkname is used as the chunk name for error messages and debug information.
* When absent, it defaults to "=(load)".
* @tupleReturn

@@ -17,3 +22,4 @@ */

/**
* Similar to load, but gets the chunk from file filename or from the standard input, if no file name is given.
* Similar to load, but gets the chunk from file filename or from the standard
* input, if no file name is given.
* @tupleReturn

@@ -36,5 +42,12 @@ */

/**
* This function is similar to pcall, except that it sets a new message handler msgh.
* This function is similar to pcall, except that it sets a new message handler
* msgh.
*
* xpcall calls function f in protected mode, using err as the error handler. Any error inside f is not propagated; instead, xpcall catches the error, calls the err function with the original error object, and returns a status code. Its first result is the status code (a boolean), which is true if the call succeeds without errors. In this case, xpcall also returns all results from the call, after this first result. In case of any error, xpcall returns false plus the result from err.
* xpcall calls function f in protected mode, using err as the error handler.
* Any error inside f is not propagated; instead, xpcall catches the error,
* calls the err function with the original error object, and returns a status
* code. Its first result is the status code (a boolean), which is true if the
* call succeeds without errors. In this case, xpcall also returns all results
* from the call, after this first result. In case of any error, xpcall returns
* false plus the result from err.
* @tupleReturn

@@ -60,3 +73,4 @@ */

/**
* Calls the C function exit, with an optional code, to terminate the host program. The default value for code is the success code.
* Calls the C function exit, with an optional code, to terminate the host
* program. The default value for code is the success code.
*/

@@ -68,5 +82,11 @@ function exit(code?: number): never;

/**
* This function returns the name and the value of the local variable with index local of the function at level level of the stack. (The first parameter or local variable has index 1, and so on, until the last active local variable.) The function returns nil if there is no local variable with the given index, and raises an error when called with a level out of range. (You can call debug.getinfo to check whether the level is valid.)
* This function returns the name and the value of the local variable with
* index local of the function at level level of the stack. (The first
* parameter or local variable has index 1, and so on, until the last active
* local variable.) The function returns nil if there is no local variable
* with the given index, and raises an error when called with a level out of
* range. (You can call debug.getinfo to check whether the level is valid.)
*
* Variable names starting with '(' (open parentheses) represent internal variables (loop control variables, temporaries, and C function locals).
* Variable names starting with '(' (open parentheses) represent internal
* variables (loop control variables, temporaries, and C function locals).
* @tupleReturn

@@ -73,0 +93,0 @@ */

/** @noSelfInFile */
/**
* This function is a generic interface to the garbage collector. It performs different functions according to its first argument, opt.
* This function is a generic interface to the garbage collector. It performs
* different functions according to its first argument, opt.
*
* Returns the total memory in use by Lua in Kbytes. The value has a fractional part, so that it multiplied by 1024 gives the exact number of bytes in use by Lua (except for overflows).
* Returns the total memory in use by Lua in Kbytes. The value has a fractional
* part, so that it multiplied by 1024 gives the exact number of bytes in use by
* Lua (except for overflows).
*/

@@ -15,3 +18,5 @@ declare function collectgarbage(opt: 'count'): number;

*
* except that the above code can be written only for a fixed number of elements. By default, i is 1 and j is the length of the list, as defined by the length operator (see §2.5.5).
* except that the above code can be written only for a fixed number of
* elements. By default, i is 1 and j is the length of the list, as defined by
* the length operator (see §2.5.5).
* @tupleReturn

@@ -24,3 +29,6 @@ */

/**
* Returns the current environment in use by the function. f can be a Lua function or a number that specifies the function at that stack level: Level 1 is the function calling getfenv. If the given function is not a Lua function, or if f is 0, getfenv returns the global environment. The default for f is 1.
* Returns the current environment in use by the function. f can be a Lua
* function or a number that specifies the function at that stack level: Level 1
* is the function calling getfenv. If the given function is not a Lua function,
* or if f is 0, getfenv returns the global environment. The default for f is 1.
*/

@@ -30,5 +38,8 @@ declare function getfenv(f?: Function | number): any;

/**
* Sets the environment to be used by the given function. f can be a Lua function or a number that specifies the function at that stack level: Level 1 is the function calling setfenv. setfenv returns the given function.
* Sets the environment to be used by the given function. f can be a Lua
* function or a number that specifies the function at that stack level: Level 1
* is the function calling setfenv. setfenv returns the given function.
*
* As a special case, when f is 0 setfenv changes the environment of the running thread. In this case, setfenv returns no values.
* As a special case, when f is 0 setfenv changes the environment of the running
* thread. In this case, setfenv returns no values.
*/

@@ -46,3 +57,4 @@ declare function setfenv<T extends Function>(f: T, table: object): T;

/**
* Sets the environment of the given object to the given table. Returns object.
* Sets the environment of the given object to the given table. Returns
* object.
*/

@@ -56,3 +68,8 @@ function setfenv<T extends object>(o: T, table: object): T;

*
* Each entry in this table is a searcher function. When looking for a module, require calls each of these searchers in ascending order, with the module name (the argument given to require) as its sole parameter. The function can return another function (the module loader) plus an extra value that will be passed to that loader, or a string explaining why it did not find that module (or nil if it has nothing to say).
* Each entry in this table is a searcher function. When looking for a module,
* require calls each of these searchers in ascending order, with the module
* name (the argument given to require) as its sole parameter. The function
* can return another function (the module loader) plus an extra value that
* will be passed to that loader, or a string explaining why it did not find
* that module (or nil if it has nothing to say).
*

@@ -63,11 +80,29 @@ * Lua initializes this table with four searcher functions.

*
* The second searcher looks for a loader as a Lua library, using the path stored at package.path. The search is done as described in function package.searchpath.
* The second searcher looks for a loader as a Lua library, using the path
* stored at package.path. The search is done as described in function
* package.searchpath.
*
* The third searcher looks for a loader as a C library, using the path given by the variable package.cpath. Again, the search is done as described in function package.searchpath. For instance, if the C path is the string
* The third searcher looks for a loader as a C library, using the path given
* by the variable package.cpath. Again, the search is done as described in
* function package.searchpath. For instance, if the C path is the string
*
* `./?.so;./?.dll;/usr/local/?/init.so`
*
* the searcher for module foo will try to open the files ./foo.so, ./foo.dll, and /usr/local/foo/init.so, in that order. Once it finds a C library, this searcher first uses a dynamic link facility to link the application with the library. Then it tries to find a C function inside the library to be used as the loader. The name of this C function is the string "luaopen_" concatenated with a copy of the module name where each dot is replaced by an underscore. Moreover, if the module name has a hyphen, its suffix after (and including) the first hyphen is removed. For instance, if the module name is a.b.c-v2.1, the function name will be luaopen_a_b_c.
* the searcher for module foo will try to open the files ./foo.so, ./foo.dll,
* and /usr/local/foo/init.so, in that order. Once it finds a C library, this
* searcher first uses a dynamic link facility to link the application with
* the library. Then it tries to find a C function inside the library to be
* used as the loader. The name of this C function is the string "luaopen_"
* concatenated with a copy of the module name where each dot is replaced by
* an underscore. Moreover, if the module name has a hyphen, its suffix after
* (and including) the first hyphen is removed. For instance, if the module
* name is a.b.c-v2.1, the function name will be luaopen_a_b_c.
*
* The fourth searcher tries an all-in-one loader. It searches the C path for a library for the root name of the given module. For instance, when requiring a.b.c, it will search for a C library for a. If found, it looks into it for an open function for the submodule; in our example, that would be luaopen_a_b_c. With this facility, a package can pack several C submodules into one single library, with each submodule keeping its original open function.
* The fourth searcher tries an all-in-one loader. It searches the C path for
* a library for the root name of the given module. For instance, when
* requiring a.b.c, it will search for a C library for a. If found, it looks
* into it for an open function for the submodule; in our example, that would
* be luaopen_a_b_c. With this facility, a package can pack several C
* submodules into one single library, with each submodule keeping its
* original open function.
*/

@@ -82,3 +117,6 @@ var loaders: (

/**
* This function is equivalent to the C function system. It passes command to be executed by an operating system shell. It returns a status code, which is system-dependent. If command is absent, then it returns nonzero if a shell is available and zero otherwise.
* This function is equivalent to the C function system. It passes command to
* be executed by an operating system shell. It returns a status code, which
* is system-dependent. If command is absent, then it returns nonzero if a
* shell is available and zero otherwise.
*/

@@ -97,3 +135,5 @@ function execute(command?: string): number;

/**
* Returns the largest positive numerical index of the given table, or zero if the table has no positive numerical indices. (To do its job this function does a linear traversal of the whole table.)
* Returns the largest positive numerical index of the given table, or zero if
* the table has no positive numerical indices. (To do its job this function
* does a linear traversal of the whole table.)
*/

@@ -100,0 +140,0 @@ function maxn(table: object): number;

/** @noSelfInFile */
/**
* This function is a generic interface to the garbage collector. It performs different functions according to its first argument, opt.
* This function is a generic interface to the garbage collector. It performs
* different functions according to its first argument, opt.
*
* Returns the total memory in use by Lua (in Kbytes) and a second value with the total memory in bytes modulo 1024. The first value has a fractional part, so the following equality is always true:
* Returns the total memory in use by Lua (in Kbytes) and a second value with
* the total memory in bytes modulo 1024. The first value has a fractional part,
* so the following equality is always true:
*

@@ -16,5 +19,7 @@ * ```

/**
* This function is a generic interface to the garbage collector. It performs different functions according to its first argument, opt.
* This function is a generic interface to the garbage collector. It performs
* different functions according to its first argument, opt.
*
* Changes the collector to generational mode. This is an experimental feature (see §2.5).
* Changes the collector to generational mode. This is an experimental feature
* (see §2.5).
*/

@@ -24,3 +29,4 @@ declare function collectgarbage(opt: 'generational'): void;

/**
* This function is a generic interface to the garbage collector. It performs different functions according to its first argument, opt.
* This function is a generic interface to the garbage collector. It performs
* different functions according to its first argument, opt.
*

@@ -32,11 +38,22 @@ * Changes the collector to incremental mode. This is the default mode.

/**
* This library provides bitwise operations. It provides all its functions inside the table bit32.
* This library provides bitwise operations. It provides all its functions
* inside the table bit32.
*
* Unless otherwise stated, all functions accept numeric arguments in the range (-251,+251); each argument is normalized to the remainder of its division by 232 and truncated to an integer (in some unspecified way), so that its final value falls in the range [0,232 - 1]. Similarly, all results are in the range [0,232 - 1]. Note that bit32.bnot(0) is 0xFFFFFFFF, which is different from -1.
* Unless otherwise stated, all functions accept numeric arguments in the range
* (-251,+251); each argument is normalized to the remainder of its division by
* 232 and truncated to an integer (in some unspecified way), so that its final
* value falls in the range [0,232 - 1]. Similarly, all results are in the range
* [0,232 - 1]. Note that bit32.bnot(0) is 0xFFFFFFFF, which is different from
* -1.
*/
declare namespace bit32 {
/**
* Returns the number x shifted disp bits to the right. The number disp may be any representable integer. Negative displacements shift to the left.
* Returns the number x shifted disp bits to the right. The number disp may be
* any representable integer. Negative displacements shift to the left.
*
* This shift operation is what is called arithmetic shift. Vacant bits on the left are filled with copies of the higher bit of x; vacant bits on the right are filled with zeros. In particular, displacements with absolute values higher than 31 result in zero or 0xFFFFFFFF (all original bits are shifted out).
* This shift operation is what is called arithmetic shift. Vacant bits on the
* left are filled with copies of the higher bit of x; vacant bits on the
* right are filled with zeros. In particular, displacements with absolute
* values higher than 31 result in zero or 0xFFFFFFFF (all original bits are
* shifted out).
*/

@@ -51,3 +68,4 @@ function arshift(x: number, disp: number): number;

/**
* Returns the bitwise negation of x. For any integer x, the following identity holds:
* Returns the bitwise negation of x. For any integer x, the following
* identity holds:
*

@@ -64,3 +82,4 @@ * `assert(bit32.bnot(x) == (-1 - x) % 2^32)`

/**
* Returns a boolean signaling whether the bitwise and of its operands is different from zero.
* Returns a boolean signaling whether the bitwise and of its operands is
* different from zero.
*/

@@ -75,3 +94,5 @@ function btest(...operands: number[]): boolean;

/**
* Returns the unsigned number formed by the bits field to field + width - 1 from n. Bits are numbered from 0 (least significant) to 31 (most significant). All accessed bits must be in the range [0, 31].
* Returns the unsigned number formed by the bits field to field + width - 1
* from n. Bits are numbered from 0 (least significant) to 31 (most
* significant). All accessed bits must be in the range [0, 31].
*

@@ -83,3 +104,4 @@ * The default for width is 1.

/**
* Returns a copy of n with the bits field to field + width - 1 replaced by the value v. See bit32.extract for details about field and width.
* Returns a copy of n with the bits field to field + width - 1 replaced by
* the value v. See bit32.extract for details about field and width.
*/

@@ -89,3 +111,4 @@ function replace(n: number, v: number, field: number, width?: number): number;

/**
* Returns the number x rotated disp bits to the left. The number disp may be any representable integer.
* Returns the number x rotated disp bits to the left. The number disp may be
* any representable integer.
*

@@ -101,7 +124,11 @@ * For any valid displacement, the following identity holds:

/**
* Returns the number x shifted disp bits to the left. The number disp may be any representable integer. Negative displacements shift to the right. In any direction, vacant bits are filled with zeros. In particular, displacements with absolute values higher than 31 result in zero (all bits are shifted out).
* Returns the number x shifted disp bits to the left. The number disp may be
* any representable integer. Negative displacements shift to the right. In
* any direction, vacant bits are filled with zeros. In particular,
* displacements with absolute values higher than 31 result in zero (all bits
* are shifted out).
*
* For positive displacements, the following equality holds:
* For positive displacements, the following equality holds:
*
* `assert(bit32.lshift(b, disp) == (b * 2^disp) % 2^32)`
* `assert(bit32.lshift(b, disp) == (b * 2^disp) % 2^32)`
*/

@@ -111,3 +138,4 @@ function lshift(x: number, disp: number): number;

/**
* Returns the number x rotated disp bits to the right. The number disp may be any representable integer.
* Returns the number x rotated disp bits to the right. The number disp may be
* any representable integer.
*

@@ -123,3 +151,7 @@ * For any valid displacement, the following identity holds:

/**
* Returns the number x shifted disp bits to the right. The number disp may be any representable integer. Negative displacements shift to the left. In any direction, vacant bits are filled with zeros. In particular, displacements with absolute values higher than 31 result in zero (all bits are shifted out).
* Returns the number x shifted disp bits to the right. The number disp may be
* any representable integer. Negative displacements shift to the left. In any
* direction, vacant bits are filled with zeros. In particular, displacements
* with absolute values higher than 31 result in zero (all bits are shifted
* out).
*

@@ -126,0 +158,0 @@ * For positive displacements, the following equality holds:

@@ -6,13 +6,29 @@ /** @noSelfInFile */

*
* If chunk is a string, the chunk is this string. If chunk is a function, load calls it repeatedly to get the chunk pieces. Each call to chunk must return a string that concatenates with previous results. A return of an empty string, nil, or no value signals the end of the chunk.
* If chunk is a string, the chunk is this string. If chunk is a function, load
* calls it repeatedly to get the chunk pieces. Each call to chunk must return a
* string that concatenates with previous results. A return of an empty string,
* nil, or no value signals the end of the chunk.
*
* If there are no syntactic errors, returns the compiled chunk as a function; otherwise, returns nil plus the error message.
* If there are no syntactic errors, returns the compiled chunk as a function;
* otherwise, returns nil plus the error message.
*
* If the resulting function has upvalues, the first upvalue is set to the value of env, if that parameter is given, or to the value of the global environment. Other upvalues are initialized with nil. (When you load a main chunk, the resulting function will always have exactly one upvalue, the _ENV variable (see §2.2). However, when you load a binary chunk created from a function (see string.dump), the resulting function can have an arbitrary number of upvalues.) All upvalues are fresh, that is, they are not shared with any other function.
* If the resulting function has upvalues, the first upvalue is set to the value
* of env, if that parameter is given, or to the value of the global
* environment. Other upvalues are initialized with nil. (When you load a main
* chunk, the resulting function will always have exactly one upvalue, the _ENV
* variable (see §2.2). However, when you load a binary chunk created from a
* function (see string.dump), the resulting function can have an arbitrary
* number of upvalues.) All upvalues are fresh, that is, they are not shared
* with any other function.
*
* chunkname is used as the name of the chunk for error messages and debug information (see §4.9). When absent, it defaults to chunk, if chunk is a string, or to "=(load)" otherwise.
* chunkname is used as the name of the chunk for error messages and debug
* information (see §4.9). When absent, it defaults to chunk, if chunk is a
* string, or to "=(load)" otherwise.
*
* The string mode controls whether the chunk can be text or binary (that is, a precompiled chunk). It may be the string "b" (only binary chunks), "t" (only text chunks), or "bt" (both binary and text). The default is "bt".
* The string mode controls whether the chunk can be text or binary (that is, a
* precompiled chunk). It may be the string "b" (only binary chunks), "t" (only
* text chunks), or "bt" (both binary and text). The default is "bt".
*
* Lua does not check the consistency of binary chunks. Maliciously crafted binary chunks can crash the interpreter.
* Lua does not check the consistency of binary chunks. Maliciously crafted
* binary chunks can crash the interpreter.
* @tupleReturn

@@ -28,3 +44,4 @@ */

/**
* Similar to load, but gets the chunk from file filename or from the standard input, if no file name is given.
* Similar to load, but gets the chunk from file filename or from the standard
* input, if no file name is given.
* @tupleReturn

@@ -39,3 +56,4 @@ */

/**
* This function is similar to pcall, except that it sets a new message handler msgh.
* This function is similar to pcall, except that it sets a new message handler
* msgh.
* @tupleReturn

@@ -64,9 +82,20 @@ */

/**
* This function returns the name and the value of the local variable with index local of the function at level f of the stack. This function accesses not only explicit local variables, but also parameters, temporaries, etc.
* This function returns the name and the value of the local variable with
* index local of the function at level f of the stack. This function accesses
* not only explicit local variables, but also parameters, temporaries, etc.
*
* The first parameter or local variable has index 1, and so on, following the order that they are declared in the code, counting only the variables that are active in the current scope of the function. Negative indices refer to vararg parameters; -1 is the first vararg parameter. The function returns nil if there is no variable with the given index, and raises an error when called with a level out of range. (You can call debug.getinfo to check whether the level is valid.)
* The first parameter or local variable has index 1, and so on, following the
* order that they are declared in the code, counting only the variables that
* are active in the current scope of the function. Negative indices refer to
* vararg parameters; -1 is the first vararg parameter. The function returns
* nil if there is no variable with the given index, and raises an error when
* called with a level out of range. (You can call debug.getinfo to check
* whether the level is valid.)
*
* Variable names starting with '(' (open parenthesis) represent variables with no known names (internal variables such as loop control variables, and variables from chunks saved without debug information).
* Variable names starting with '(' (open parenthesis) represent variables
* with no known names (internal variables such as loop control variables, and
* variables from chunks saved without debug information).
*
* The parameter f may also be a function. In that case, getlocal returns only the name of function parameters.
* The parameter f may also be a function. In that case, getlocal returns only
* the name of function parameters.
* @tupleReturn

@@ -79,5 +108,9 @@ */

/**
* Returns a unique identifier (as a light userdata) for the upvalue numbered n from the given function.
* Returns a unique identifier (as a light userdata) for the upvalue numbered
* n from the given function.
*
* These unique identifiers allow a program to check whether different closures share upvalues. Lua closures that share an upvalue (that is, that access a same external local variable) will return identical ids for those upvalue indices.
* These unique identifiers allow a program to check whether different
* closures share upvalues. Lua closures that share an upvalue (that is, that
* access a same external local variable) will return identical ids for those
* upvalue indices.
*/

@@ -87,3 +120,4 @@ function upvalueid(f: Function, n: number): LuaUserdata;

/**
* Make the n1-th upvalue of the Lua closure f1 refer to the n2-th upvalue of the Lua closure f2.
* Make the n1-th upvalue of the Lua closure f1 refer to the n2-th upvalue of
* the Lua closure f2.
*/

@@ -95,3 +129,4 @@ function upvaluejoin(f1: Function, n1: number, f2: Function, n2: number): void;

/**
* Returns the logarithm of x in the given base. The default for base is e (so that the function returns the natural logarithm of x).
* Returns the logarithm of x in the given base. The default for base is e (so
* that the function returns the natural logarithm of x).
*/

@@ -103,5 +138,8 @@ function log(x: number, base?: number): number;

/**
* Returns a string that is the concatenation of n copies of the string s separated by the string sep. The default value for sep is the empty string (that is, no separator). Returns the empty string if n is not positive.
* Returns a string that is the concatenation of n copies of the string s
* separated by the string sep. The default value for sep is the empty string
* (that is, no separator). Returns the empty string if n is not positive.
*
* (Note that it is very easy to exhaust the memory of your machine with a single call to this function.)
* (Note that it is very easy to exhaust the memory of your machine with a
* single call to this function.)
*/

@@ -113,7 +151,11 @@ function rep(s: string, n: number, sep?: string): string;

/**
* Calls the ISO C function exit to terminate the host program. If code is true, the returned status is EXIT_SUCCESS; if code is false, the returned status is EXIT_FAILURE; if code is a number, the returned status is this number. The default value for code is true.
* Calls the ISO C function exit to terminate the host program. If code is
* true, the returned status is EXIT_SUCCESS; if code is false, the returned
* status is EXIT_FAILURE; if code is a number, the returned status is this
* number. The default value for code is true.
*
* If the optional second argument close is true, closes the Lua state before exiting.
* If the optional second argument close is true, closes the Lua state before
* exiting.
*/
function exit(code?: boolean | number, close?: boolean): never;
}

@@ -6,5 +6,7 @@ /** @noSelfInFile */

/**
* This function is a generic interface to the garbage collector. It performs different functions according to its first argument, opt.
* This function is a generic interface to the garbage collector. It performs
* different functions according to its first argument, opt.
*
* Returns a boolean that tells whether the collector is running (i.e., not stopped).
* Returns a boolean that tells whether the collector is running (i.e., not
* stopped).
*/

@@ -14,7 +16,19 @@ declare function collectgarbage(opt: 'isrunning'): boolean;

/**
* Creates a module. If there is a table in package.loaded[name], this table is the module. Otherwise, if there is a global table t with the given name, this table is the module. Otherwise creates a new table t and sets it as the value of the global name and the value of package.loaded[name]. This function also initializes t._NAME with the given name, t._M with the module (t itself), and t._PACKAGE with the package name (the full module name minus last component; see below). Finally, module sets t as the new environment of the current function and the new value of package.loaded[name], so that require returns t.
* Creates a module. If there is a table in package.loaded[name], this table is
* the module. Otherwise, if there is a global table t with the given name, this
* table is the module. Otherwise creates a new table t and sets it as the value
* of the global name and the value of package.loaded[name]. This function also
* initializes t._NAME with the given name, t._M with the module (t itself), and
* t._PACKAGE with the package name (the full module name minus last component;
* see below). Finally, module sets t as the new environment of the current
* function and the new value of package.loaded[name], so that require returns
* t.
*
* If name is a compound name (that is, one with components separated by dots), module creates (or reuses, if they already exist) tables for each component. For instance, if name is a.b.c, then module stores the module table in field c of field b of global a.
* If name is a compound name (that is, one with components separated by dots),
* module creates (or reuses, if they already exist) tables for each component.
* For instance, if name is a.b.c, then module stores the module table in field
* c of field b of global a.
*
* This function can receive optional options after the module name, where each option is a function to be applied over the module.
* This function can receive optional options after the module name, where each
* option is a function to be applied over the module.
*/

@@ -27,3 +41,8 @@ declare function module(name: string, ...options: Function[]): void;

*
* Each entry in this table is a searcher function. When looking for a module, require calls each of these searchers in ascending order, with the module name (the argument given to require) as its sole parameter. The function can return another function (the module loader) plus an extra value that will be passed to that loader, or a string explaining why it did not find that module (or nil if it has nothing to say).
* Each entry in this table is a searcher function. When looking for a module,
* require calls each of these searchers in ascending order, with the module
* name (the argument given to require) as its sole parameter. The function
* can return another function (the module loader) plus an extra value that
* will be passed to that loader, or a string explaining why it did not find
* that module (or nil if it has nothing to say).
*

@@ -34,13 +53,33 @@ * Lua initializes this table with four searcher functions.

*
* The second searcher looks for a loader as a Lua library, using the path stored at package.path. The search is done as described in function package.searchpath.
* The second searcher looks for a loader as a Lua library, using the path
* stored at package.path. The search is done as described in function
* package.searchpath.
*
* The third searcher looks for a loader as a C library, using the path given by the variable package.cpath. Again, the search is done as described in function package.searchpath. For instance, if the C path is the string
* The third searcher looks for a loader as a C library, using the path given
* by the variable package.cpath. Again, the search is done as described in
* function package.searchpath. For instance, if the C path is the string
*
* `./?.so;./?.dll;/usr/local/?/init.so`
*
* the searcher for module foo will try to open the files ./foo.so, ./foo.dll, and /usr/local/foo/init.so, in that order. Once it finds a C library, this searcher first uses a dynamic link facility to link the application with the library. Then it tries to find a C function inside the library to be used as the loader. The name of this C function is the string "luaopen_" concatenated with a copy of the module name where each dot is replaced by an underscore. Moreover, if the module name has a hyphen, its suffix after (and including) the first hyphen is removed. For instance, if the module name is a.b.c-v2.1, the function name will be luaopen_a_b_c.
* the searcher for module foo will try to open the files ./foo.so, ./foo.dll,
* and /usr/local/foo/init.so, in that order. Once it finds a C library, this
* searcher first uses a dynamic link facility to link the application with
* the library. Then it tries to find a C function inside the library to be
* used as the loader. The name of this C function is the string "luaopen_"
* concatenated with a copy of the module name where each dot is replaced by
* an underscore. Moreover, if the module name has a hyphen, its suffix after
* (and including) the first hyphen is removed. For instance, if the module
* name is a.b.c-v2.1, the function name will be luaopen_a_b_c.
*
* The fourth searcher tries an all-in-one loader. It searches the C path for a library for the root name of the given module. For instance, when requiring a.b.c, it will search for a C library for a. If found, it looks into it for an open function for the submodule; in our example, that would be luaopen_a_b_c. With this facility, a package can pack several C submodules into one single library, with each submodule keeping its original open function.
* The fourth searcher tries an all-in-one loader. It searches the C path for
* a library for the root name of the given module. For instance, when
* requiring a.b.c, it will search for a C library for a. If found, it looks
* into it for an open function for the submodule; in our example, that would
* be luaopen_a_b_c. With this facility, a package can pack several C
* submodules into one single library, with each submodule keeping its
* original open function.
*
* All searchers except the first one (preload) return as the extra value the file name where the module was found, as returned by package.searchpath. The first searcher returns no extra value.
* All searchers except the first one (preload) return as the extra value the
* file name where the module was found, as returned by package.searchpath.
* The first searcher returns no extra value.
*/

@@ -67,3 +106,5 @@ var searchers: (

/**
* Returns a new table with all parameters stored into keys 1, 2, etc. and with a field "n" with the total number of parameters. Note that the resulting table may not be a sequence.
* Returns a new table with all parameters stored into keys 1, 2, etc. and
* with a field "n" with the total number of parameters. Note that the
* resulting table may not be a sequence.
*/

@@ -75,7 +116,13 @@ function pack<T extends any[]>(...args: T): T & { n: number };

/**
* This function is equivalent to the ISO C function system. It passes command to be executed by an operating system shell. Its first result is true if the command terminated successfully, or nil otherwise. After this first result the function returns a string plus a number, as follows:
* * "exit": the command terminated normally; the following number is the exit status of the command.
* * "signal": the command was terminated by a signal; the following number is the signal that terminated the command.
* This function is equivalent to the ISO C function system. It passes command
* to be executed by an operating system shell. Its first result is true if
* the command terminated successfully, or nil otherwise. After this first
* result the function returns a string plus a number, as follows:
* * "exit": the command terminated normally; the following number is the exit
* status of the command.
* * "signal": the command was terminated by a signal; the following number is
* the signal that terminated the command.
*
* When called without a command, os.execute returns a boolean that is true if a shell is available.
* When called without a command, os.execute returns a boolean that is true if
* a shell is available.
*/

@@ -85,7 +132,13 @@ function execute(): boolean;

/**
* This function is equivalent to the ISO C function system. It passes command to be executed by an operating system shell. Its first result is true if the command terminated successfully, or nil otherwise. After this first result the function returns a string plus a number, as follows:
* * "exit": the command terminated normally; the following number is the exit status of the command.
* * "signal": the command was terminated by a signal; the following number is the signal that terminated the command.
* This function is equivalent to the ISO C function system. It passes command
* to be executed by an operating system shell. Its first result is true if
* the command terminated successfully, or nil otherwise. After this first
* result the function returns a string plus a number, as follows:
* * "exit": the command terminated normally; the following number is the exit
* status of the command.
* * "signal": the command was terminated by a signal; the following number is
* the signal that terminated the command.
*
* When called without a command, os.execute returns a boolean that is true if a shell is available.
* When called without a command, os.execute returns a boolean that is true if
* a shell is available.
* @tupleReturn

@@ -104,3 +157,4 @@ */

/**
* Handle iteration through table pairs when `for k,v in pairs(tbl) do ... end` is called.
* Handle iteration through table pairs when `for k,v in pairs(tbl) do ...
* end` is called.
*/

@@ -110,3 +164,4 @@ __pairs?<T>(t: T): [(t: T, index?: any) => [any, any], T];

/**
* Handle iteration through table pairs when `for k,v in ipairs(tbl) do ... end` is called.
* Handle iteration through table pairs when `for k,v in ipairs(tbl) do ...
* end` is called.
*/

@@ -118,3 +173,4 @@ __ipairs?<T extends object>(t: T): [(t: T, index?: number) => [number, any], T, 0];

/**
* Returns the running coroutine plus a boolean, true when the running coroutine is the main one.
* Returns the running coroutine plus a boolean, true when the running
* coroutine is the main one.
* @tupleReturn

@@ -121,0 +177,0 @@ */

/** @noSelfInFile */
/**
* This function is a generic interface to the garbage collector. It performs different functions according to its first argument, opt.
* This function is a generic interface to the garbage collector. It performs
* different functions according to its first argument, opt.
*
* Returns the total memory in use by Lua in Kbytes. The value has a fractional part, so that it multiplied by 1024 gives the exact number of bytes in use by Lua (except for overflows).
* Returns the total memory in use by Lua in Kbytes. The value has a fractional
* part, so that it multiplied by 1024 gives the exact number of bytes in use by
* Lua (except for overflows).
*/

@@ -12,5 +15,8 @@ declare function collectgarbage(opt: 'count'): number;

/**
* Returns the arc tangent of y/x (in radians), but uses the signs of both parameters to find the quadrant of the result. (It also handles correctly the case of x being zero.)
* Returns the arc tangent of y/x (in radians), but uses the signs of both
* parameters to find the quadrant of the result. (It also handles correctly
* the case of x being zero.)
*
* The default value for x is 1, so that the call math.atan(y) returns the arc tangent of y.
* The default value for x is 1, so that the call math.atan(y) returns the arc
* tangent of y.
*/

@@ -30,3 +36,4 @@ function atan(y: number, x?: number): number;

/**
* If the value x is convertible to an integer, returns that integer. Otherwise, returns nil.
* If the value x is convertible to an integer, returns that integer.
* Otherwise, returns nil.
*/

@@ -36,3 +43,4 @@ function tointeger(x: number): number;

/**
* Returns "integer" if x is an integer, "float" if it is a float, or nil if x is not a number.
* Returns "integer" if x is an integer, "float" if it is a float, or nil if x
* is not a number.
*/

@@ -42,3 +50,4 @@ function type(x: number): 'integer' | 'float' | undefined;

/**
* Returns a boolean, true if and only if integer m is below integer n when they are compared as unsigned integers.
* Returns a boolean, true if and only if integer m is below integer n when
* they are compared as unsigned integers.
*/

@@ -50,3 +59,6 @@ function ult(m: number, n: number): boolean;

/**
* Moves elements from table a1 to table a2, performing the equivalent to the following multiple assignment: a2[t],··· = a1[f],···,a1[e]. The default for a2 is a1. The destination range can overlap with the source range. The number of elements to be moved must fit in a Lua integer.
* Moves elements from table a1 to table a2, performing the equivalent to the
* following multiple assignment: a2[t],··· = a1[f],···,a1[e]. The default for
* a2 is a1. The destination range can overlap with the source range. The
* number of elements to be moved must fit in a Lua integer.
*

@@ -60,5 +72,12 @@ * Returns the destination table a2.

/**
* Returns a string containing a binary representation (a binary chunk) of the given function, so that a later load on this string returns a copy of the function (but with new upvalues). If strip is a true value, the binary representation may not include all debug information about the function, to save space.
* Returns a string containing a binary representation (a binary chunk) of the
* given function, so that a later load on this string returns a copy of the
* function (but with new upvalues). If strip is a true value, the binary
* representation may not include all debug information about the function, to
* save space.
*
* Functions with upvalues have only their number of upvalues saved. When (re)loaded, those upvalues receive fresh instances containing nil. (You can use the debug library to serialize and reload the upvalues of a function in a way adequate to your needs.)
* Functions with upvalues have only their number of upvalues saved. When
* (re)loaded, those upvalues receive fresh instances containing nil. (You can
* use the debug library to serialize and reload the upvalues of a function in
* a way adequate to your needs.)
*/

@@ -68,3 +87,4 @@ function dump(func: Function, strip?: boolean): string;

/**
* Returns a binary string containing the values v1, v2, etc. packed (that is, serialized in binary form) according to the format string fmt (see §6.4.2).
* Returns a binary string containing the values v1, v2, etc. packed (that is,
* serialized in binary form) according to the format string fmt (see §6.4.2).
*/

@@ -74,3 +94,6 @@ function pack(fmt: string, ...values: any[]): string;

/**
* Returns the values packed in string s (see string.pack) according to the format string fmt (see §6.4.2). An optional pos marks where to start reading in s (default is 1). After the read values, this function also returns the index of the first unread byte in s.
* Returns the values packed in string s (see string.pack) according to the
* format string fmt (see §6.4.2). An optional pos marks where to start
* reading in s (default is 1). After the read values, this function also
* returns the index of the first unread byte in s.
* @tupleReturn

@@ -81,3 +104,5 @@ */

/**
* Returns the size of a string resulting from string.pack with the given format. The format string cannot have the variable-length options 's' or 'z' (see §6.4.2).
* Returns the size of a string resulting from string.pack with the given
* format. The format string cannot have the variable-length options 's' or
* 'z' (see §6.4.2).
*/

@@ -91,3 +116,4 @@ function packsize(fmt: string): number;

*
* A running coroutine is yieldable if it is not the main thread and it is not inside a non-yieldable C function.
* A running coroutine is yieldable if it is not the main thread and it is not
* inside a non-yieldable C function.
*/

@@ -100,9 +126,18 @@ function isyieldable(): boolean;

/**
* This library provides basic support for UTF-8 encoding. It provides all its functions inside the table utf8. This library does not provide any support for Unicode other than the handling of the encoding. Any operation that needs the meaning of a character, such as character classification, is outside its scope.
* This library provides basic support for UTF-8 encoding. It provides all its
* functions inside the table utf8. This library does not provide any support
* for Unicode other than the handling of the encoding. Any operation that needs
* the meaning of a character, such as character classification, is outside its
* scope.
*
* Unless stated otherwise, all functions that expect a byte position as a parameter assume that the given position is either the start of a byte sequence or one plus the length of the subject string. As in the string library, negative indices count from the end of the string.
* Unless stated otherwise, all functions that expect a byte position as a
* parameter assume that the given position is either the start of a byte
* sequence or one plus the length of the subject string. As in the string
* library, negative indices count from the end of the string.
*/
declare namespace utf8 {
/**
* Receives zero or more integers, converts each one to its corresponding UTF-8 byte sequence and returns a string with the concatenation of all these sequences
* Receives zero or more integers, converts each one to its corresponding
* UTF-8 byte sequence and returns a string with the concatenation of all
* these sequences
*/

@@ -112,3 +147,5 @@ function char(...args: number[]): string;

/**
* The pattern (a string, not a function) "[\0-\x7F\xC2-\xF4][\x80-\xBF]*" (see §6.4.1), which matches exactly one UTF-8 byte sequence, assuming that the subject is a valid UTF-8 string.
* The pattern (a string, not a function) "[\0-\x7F\xC2-\xF4][\x80-\xBF]*"
* (see §6.4.1), which matches exactly one UTF-8 byte sequence, assuming that
* the subject is a valid UTF-8 string.
*/

@@ -122,3 +159,5 @@ var charpattern: string;

*
* will iterate over all characters in string s, with p being the position (in bytes) and c the code point of each character. It raises an error if it meets any invalid byte sequence.
* will iterate over all characters in string s, with p being the position (in
* bytes) and c the code point of each character. It raises an error if it
* meets any invalid byte sequence.
*/

@@ -130,3 +169,5 @@ function codes<S extends string>(

/**
* Returns the codepoints (as integers) from all characters in s that start between byte position i and j (both included). The default for i is 1 and for j is i. It raises an error if it meets any invalid byte sequence.
* Returns the codepoints (as integers) from all characters in s that start
* between byte position i and j (both included). The default for i is 1 and
* for j is i. It raises an error if it meets any invalid byte sequence.
* @tupleReturn

@@ -137,3 +178,6 @@ */

/**
* Returns the number of UTF-8 characters in string s that start between positions i and j (both inclusive). The default for i is 1 and for j is -1. If it finds any invalid byte sequence, returns a false value plus the position of the first invalid byte.
* Returns the number of UTF-8 characters in string s that start between
* positions i and j (both inclusive). The default for i is 1 and for j is -1.
* If it finds any invalid byte sequence, returns a false value plus the
* position of the first invalid byte.
*/

@@ -143,5 +187,11 @@ function len(s: string, i?: number, j?: number): number;

/**
* Returns the position (in bytes) where the encoding of the n-th character of s (counting from position i) starts. A negative n gets characters before position i. The default for i is 1 when n is non-negative and #s + 1 otherwise, so that utf8.offset(s, -n) gets the offset of the n-th character from the end of the string. If the specified character is neither in the subject nor right after its end, the function returns nil.
* Returns the position (in bytes) where the encoding of the n-th character of
* s (counting from position i) starts. A negative n gets characters before
* position i. The default for i is 1 when n is non-negative and #s + 1
* otherwise, so that utf8.offset(s, -n) gets the offset of the n-th character
* from the end of the string. If the specified character is neither in the
* subject nor right after its end, the function returns nil.
*
* As a special case, when n is 0 the function returns the start of the encoding of the character that contains the i-th byte of s.
* As a special case, when n is 0 the function returns the start of the
* encoding of the character that contains the i-th byte of s.
*

@@ -155,3 +205,4 @@ * This function assumes that s is a valid UTF-8 string.

/**
* the floor division (//) operation. Behavior similar to the addition operation.
* the floor division (//) operation. Behavior similar to the addition
* operation.
*/

@@ -161,3 +212,5 @@ __idiv?(this: T, operand: any): any;

/**
* the bitwise AND (&) operation. Behavior similar to the addition operation, except that Lua will try a metamethod if any operand is neither an integer nor a value coercible to an integer (see §3.4.3).
* the bitwise AND (&) operation. Behavior similar to the addition operation,
* except that Lua will try a metamethod if any operand is neither an integer
* nor a value coercible to an integer (see §3.4.3).
*/

@@ -167,3 +220,4 @@ __band?(this: T, operand: any): any;

/**
* the bitwise OR (|) operation. Behavior similar to the bitwise AND operation.
* the bitwise OR (|) operation. Behavior similar to the bitwise AND
* operation.
*/

@@ -173,3 +227,4 @@ __bor?(this: T, operand: any): any;

/**
* the bitwise exclusive OR (binary ~) operation. Behavior similar to the bitwise AND operation.
* the bitwise exclusive OR (binary ~) operation. Behavior similar to the
* bitwise AND operation.
*/

@@ -179,3 +234,4 @@ __bxor?(this: T, operand: any): any;

/**
* the bitwise NOT (unary ~) operation. Behavior similar to the bitwise AND operation.
* the bitwise NOT (unary ~) operation. Behavior similar to the bitwise AND
* operation.
*/

@@ -185,3 +241,4 @@ __bnot?(this: T, operand: any): any;

/**
* the bitwise left shift (<<) operation. Behavior similar to the bitwise AND operation.
* the bitwise left shift (<<) operation. Behavior similar to the bitwise AND
* operation.
*/

@@ -191,3 +248,4 @@ __shl?(this: T, operand: any): any;

/**
* the bitwise right shift (>>) operation. Behavior similar to the bitwise AND operation.
* the bitwise right shift (>>) operation. Behavior similar to the bitwise AND
* operation.
*/

@@ -194,0 +252,0 @@ __shr?(this: T, operand: any): any;

@@ -10,3 +10,5 @@ /** @noSelfInFile */

/**
* Returns the arc tangent of y/x (in radians), but uses the signs of both parameters to find the quadrant of the result. (It also handles correctly the case of x being zero.)
* Returns the arc tangent of y/x (in radians), but uses the signs of both
* parameters to find the quadrant of the result. (It also handles correctly
* the case of x being zero.)
*/

@@ -21,3 +23,4 @@ function atan2(y: number, x: number): number;

/**
* Returns m and e such that x = m2e, e is an integer and the absolute value of m is in the range [0.5, 1) (or zero when x is zero).
* Returns m and e such that x = m2e, e is an integer and the absolute value
* of m is in the range [0.5, 1) (or zero when x is zero).
*/

@@ -24,0 +27,0 @@ function frexp(x: number): number;

@@ -5,7 +5,20 @@ /** @noSelfInFile */

/**
* When called without arguments, returns a pseudo-random float with uniform distribution in the range [0,1). When called with two integers m and n, math.random returns a pseudo-random integer with uniform distribution in the range [m, n]. The call math.random(n), for a positive n, is equivalent to math.random(1,n). The call math.random(0) produces an integer with all bits (pseudo)random.
* When called without arguments, returns a pseudo-random float with uniform
* distribution in the range [0,1). When called with two integers m and n,
* math.random returns a pseudo-random integer with uniform distribution in
* the range [m, n]. The call math.random(n), for a positive n, is equivalent
* to math.random(1,n). The call math.random(0) produces an integer with all
* bits (pseudo)random.
*
* Lua initializes its pseudo-random generator with a weak attempt for "randomness", so that math.random should generate different sequences of results each time the program runs. To ensure a required level of randomness to the initial state (or contrarily, to have a deterministic sequence, for instance when debugging a program), you should call math.randomseed explicitly.
* Lua initializes its pseudo-random generator with a weak attempt for
* "randomness", so that math.random should generate different sequences of
* results each time the program runs. To ensure a required level of
* randomness to the initial state (or contrarily, to have a deterministic
* sequence, for instance when debugging a program), you should call
* math.randomseed explicitly.
*
* The results from this function have good statistical qualities, but they are not cryptographically secure. (For instance, there are no garanties that it is hard to predict future results based on the observation of some number of previous results.)
* The results from this function have good statistical qualities, but they
* are not cryptographically secure. (For instance, there are no garanties
* that it is hard to predict future results based on the observation of some
* number of previous results.)
*/

@@ -15,5 +28,6 @@ function random(m?: number, n?: number): number;

/**
* Sets x and y as the "seed" for the pseudo-random generator: equal seeds produce equal sequences of numbers. The default for y is zero.
* Sets x and y as the "seed" for the pseudo-random generator: equal seeds
* produce equal sequences of numbers. The default for y is zero.
*/
function randomseed(x: number, y?: number): number;
}

@@ -5,5 +5,10 @@ /** @noSelfInFile */

/**
* When called without arguments, returns a pseudo-random float with uniform distribution in the range [0,1). When called with two integers m and n, math.random returns a pseudo-random integer with uniform distribution in the range [m, n]. (The value n-m cannot be negative and must fit in a Lua integer.) The call math.random(n) is equivalent to math.random(1,n).
* When called without arguments, returns a pseudo-random float with uniform
* distribution in the range [0,1). When called with two integers m and n,
* math.random returns a pseudo-random integer with uniform distribution in
* the range [m, n]. (The value n-m cannot be negative and must fit in a Lua
* integer.) The call math.random(n) is equivalent to math.random(1,n).
*
* This function is an interface to the underling pseudo-random generator function provided by C.
* This function is an interface to the underling pseudo-random generator
* function provided by C.
*/

@@ -13,5 +18,6 @@ function random(m?: number, n?: number): number;

/**
* Sets x as the "seed" for the pseudo-random generator: equal seeds produce equal sequences of numbers.
* Sets x as the "seed" for the pseudo-random generator: equal seeds produce
* equal sequences of numbers.
*/
function randomseed(x: number): number;
}

@@ -6,13 +6,29 @@ /** @noSelfInFile */

*
* If chunk is a string, the chunk is this string. If chunk is a function, load calls it repeatedly to get the chunk pieces. Each call to chunk must return a string that concatenates with previous results. A return of an empty string, nil, or no value signals the end of the chunk.
* If chunk is a string, the chunk is this string. If chunk is a function, load
* calls it repeatedly to get the chunk pieces. Each call to chunk must return a
* string that concatenates with previous results. A return of an empty string,
* nil, or no value signals the end of the chunk.
*
* If there are no syntactic errors, returns the compiled chunk as a function; otherwise, returns nil plus the error message.
* If there are no syntactic errors, returns the compiled chunk as a function;
* otherwise, returns nil plus the error message.
*
* If the resulting function has upvalues, the first upvalue is set to the value of env, if that parameter is given, or to the value of the global environment. Other upvalues are initialized with nil. (When you load a main chunk, the resulting function will always have exactly one upvalue, the _ENV variable (see §2.2). However, when you load a binary chunk created from a function (see string.dump), the resulting function can have an arbitrary number of upvalues.) All upvalues are fresh, that is, they are not shared with any other function.
* If the resulting function has upvalues, the first upvalue is set to the value
* of env, if that parameter is given, or to the value of the global
* environment. Other upvalues are initialized with nil. (When you load a main
* chunk, the resulting function will always have exactly one upvalue, the _ENV
* variable (see §2.2). However, when you load a binary chunk created from a
* function (see string.dump), the resulting function can have an arbitrary
* number of upvalues.) All upvalues are fresh, that is, they are not shared
* with any other function.
*
* chunkname is used as the name of the chunk for error messages and debug information (see §4.9). When absent, it defaults to chunk, if chunk is a string, or to "=(load)" otherwise.
* chunkname is used as the name of the chunk for error messages and debug
* information (see §4.9). When absent, it defaults to chunk, if chunk is a
* string, or to "=(load)" otherwise.
*
* The string mode controls whether the chunk can be text or binary (that is, a precompiled chunk). It may be the string "b" (only binary chunks), "t" (only text chunks), or "bt" (both binary and text). The default is "bt".
* The string mode controls whether the chunk can be text or binary (that is, a
* precompiled chunk). It may be the string "b" (only binary chunks), "t" (only
* text chunks), or "bt" (both binary and text). The default is "bt".
*
* Lua does not check the consistency of binary chunks. Maliciously crafted binary chunks can crash the interpreter.
* Lua does not check the consistency of binary chunks. Maliciously crafted
* binary chunks can crash the interpreter.
* @tupleReturn

@@ -29,3 +45,6 @@ */

/**
* Normalizes a number to the numeric range for bit operations and returns it. This function is usually not needed since all bit operations already normalize all of their input arguments. Check the operational semantics for details.
* Normalizes a number to the numeric range for bit operations and returns it.
* This function is usually not needed since all bit operations already
* normalize all of their input arguments. Check the operational semantics for
* details.
*/

@@ -35,3 +54,7 @@ function tobit(x: number): number;

/**
* Converts its first argument to a hex string. The number of hex digits is given by the absolute value of the optional second argument. Positive numbers between 1 and 8 generate lowercase hex digits. Negative numbers generate uppercase hex digits. Only the least-significant 4*|n| bits are used. The default is to generate 8 lowercase hex digits.
* Converts its first argument to a hex string. The number of hex digits is
* given by the absolute value of the optional second argument. Positive
* numbers between 1 and 8 generate lowercase hex digits. Negative numbers
* generate uppercase hex digits. Only the least-significant 4*|n| bits are
* used. The default is to generate 8 lowercase hex digits.
*/

@@ -59,23 +82,38 @@ function tohex(x: number, n?: number): string;

/**
* Returns the (bitwise logical left-shift, bitwise logical right-shift, bitwise arithmetic right-shift) of its first argument by the number of bits given by the second argument.
* Returns the (bitwise logical left-shift, bitwise logical right-shift,
* bitwise arithmetic right-shift) of its first argument by the number of bits
* given by the second argument.
*
* Logical shifts treat the first argument as an unsigned number and shift in 0-bits. Arithmetic right-shift treats the most-significant bit as a sign bit and replicates it.
* Logical shifts treat the first argument as an unsigned number and shift in
* 0-bits. Arithmetic right-shift treats the most-significant bit as a sign
* bit and replicates it.
*
* Only the lower 5 bits of the shift count are used (reduces to the range [0..31]).
* Only the lower 5 bits of the shift count are used (reduces to the range
* [0..31]).
*/
function lshift(x: number, n: number): number;
/**
* Returns the (bitwise logical left-shift, bitwise logical right-shift, bitwise arithmetic right-shift) of its first argument by the number of bits given by the second argument.
* Returns the (bitwise logical left-shift, bitwise logical right-shift,
* bitwise arithmetic right-shift) of its first argument by the number of bits
* given by the second argument.
*
* Logical shifts treat the first argument as an unsigned number and shift in 0-bits. Arithmetic right-shift treats the most-significant bit as a sign bit and replicates it.
* Logical shifts treat the first argument as an unsigned number and shift in
* 0-bits. Arithmetic right-shift treats the most-significant bit as a sign
* bit and replicates it.
*
* Only the lower 5 bits of the shift count are used (reduces to the range [0..31]).
* Only the lower 5 bits of the shift count are used (reduces to the range
* [0..31]).
*/
function rshift(x: number, n: number): number;
/**
* Returns the (bitwise logical left-shift, bitwise logical right-shift, bitwise arithmetic right-shift) of its first argument by the number of bits given by the second argument.
* Returns the (bitwise logical left-shift, bitwise logical right-shift,
* bitwise arithmetic right-shift) of its first argument by the number of bits
* given by the second argument.
*
* Logical shifts treat the first argument as an unsigned number and shift in 0-bits. Arithmetic right-shift treats the most-significant bit as a sign bit and replicates it.
* Logical shifts treat the first argument as an unsigned number and shift in
* 0-bits. Arithmetic right-shift treats the most-significant bit as a sign
* bit and replicates it.
*
* Only the lower 5 bits of the shift count are used (reduces to the range [0..31]).
* Only the lower 5 bits of the shift count are used (reduces to the range
* [0..31]).
*/

@@ -85,5 +123,8 @@ function arshift(x: number, n: number): number;

/**
* Returns bitwise left rotation of its first argument by the number of bits given by the second argument. Bits shifted out on one side are shifted back in on the other side.
* Returns bitwise left rotation of its first argument by the number of bits
* given by the second argument. Bits shifted out on one side are shifted back
* in on the other side.
*
* Only the lower 5 bits of the rotate count are used (reduces to the range [0..31]).
* Only the lower 5 bits of the rotate count are used (reduces to the range
* [0..31]).
*/

@@ -93,5 +134,8 @@ function rol(x: number, n: number): number;

/**
* Returns bitwise right rotation of its first argument by the number of bits given by the second argument. Bits shifted out on one side are shifted back in on the other side.
* Returns bitwise right rotation of its first argument by the number of bits
* given by the second argument. Bits shifted out on one side are shifted back
* in on the other side.
*
* Only the lower 5 bits of the rotate count are used (reduces to the range [0..31]).
* Only the lower 5 bits of the rotate count are used (reduces to the range
* [0..31]).
*/

@@ -101,3 +145,4 @@ function ror(x: number, n: number): number;

/**
* Swaps the bytes of its argument and returns it. This can be used to convert little-endian 32 bit numbers to big-endian 32 bit numbers or vice versa
* Swaps the bytes of its argument and returns it. This can be used to convert
* little-endian 32 bit numbers to big-endian 32 bit numbers or vice versa
*/

@@ -109,9 +154,19 @@ function bswap(x: number): number;

/**
* Adds multiple C declarations for types or external symbols (named variables or functions). def must be a Lua string. It's recommended to use the syntactic sugar for string arguments as follows:
* Adds multiple C declarations for types or external symbols (named variables
* or functions). def must be a Lua string. It's recommended to use the
* syntactic sugar for string arguments as follows:
*
* The contents of the string must be a sequence of C declarations, separated by semicolons. The trailing semicolon for a single declaration may be omitted.
* The contents of the string must be a sequence of C declarations, separated
* by semicolons. The trailing semicolon for a single declaration may be
* omitted.
*
* Please note that external symbols are only declared, but they are not bound to any specific address, yet. Binding is achieved with C library namespaces (see below).
* Please note that external symbols are only declared, but they are not bound
* to any specific address, yet. Binding is achieved with C library namespaces
* (see below).
*
* C declarations are not passed through a C pre-processor, yet. No pre-processor tokens are allowed, except for #pragma pack. Replace #define in existing C header files with enum, static const or typedef and/or pass the files through an external C pre-processor (once). Be careful not to include unneeded or redundant declarations from unrelated header files.
* C declarations are not passed through a C pre-processor, yet. No
* pre-processor tokens are allowed, except for #pragma pack. Replace #define
* in existing C header files with enum, static const or typedef and/or pass
* the files through an external C pre-processor (once). Be careful not to
* include unneeded or redundant declarations from unrelated header files.
*/

@@ -121,7 +176,17 @@ function cdef(defs: string): void;

/**
* This is the default C library namespace — note the uppercase 'C'. It binds to the default set of symbols or libraries on the target system. These are more or less the same as a C compiler would offer by default, without specifying extra link libraries.
* This is the default C library namespace — note the uppercase 'C'. It binds
* to the default set of symbols or libraries on the target system. These are
* more or less the same as a C compiler would offer by default, without
* specifying extra link libraries.
*
* On POSIX systems, this binds to symbols in the default or global namespace. This includes all exported symbols from the executable and any libraries loaded into the global namespace. This includes at least libc, libm, libdl (on Linux), libgcc (if compiled with GCC), as well as any exported symbols from the Lua/C API provided by LuaJIT itself.
* On POSIX systems, this binds to symbols in the default or global namespace.
* This includes all exported symbols from the executable and any libraries
* loaded into the global namespace. This includes at least libc, libm, libdl
* (on Linux), libgcc (if compiled with GCC), as well as any exported symbols
* from the Lua/C API provided by LuaJIT itself.
*
* On Windows systems, this binds to symbols exported from the *.exe, the lua51.dll (i.e. the Lua/C API provided by LuaJIT itself), the C runtime library LuaJIT was linked with (msvcrt*.dll), kernel32.dll, user32.dll and gdi32.dll.
* On Windows systems, this binds to symbols exported from the *.exe, the
* lua51.dll (i.e. the Lua/C API provided by LuaJIT itself), the C runtime
* library LuaJIT was linked with (msvcrt*.dll), kernel32.dll, user32.dll and
* gdi32.dll.
*/

@@ -131,9 +196,17 @@ const C: Record<string, any>;

/**
* This loads the dynamic library given by name and returns a new C library namespace which binds to its symbols. On POSIX systems, if global is true, the library symbols are loaded into the global namespace, too.
* This loads the dynamic library given by name and returns a new C library
* namespace which binds to its symbols. On POSIX systems, if global is true,
* the library symbols are loaded into the global namespace, too.
*
* If name is a path, the library is loaded from this path. Otherwise name is canonicalized in a system-dependent way and searched in the default search path for dynamic libraries:
* If name is a path, the library is loaded from this path. Otherwise name is
* canonicalized in a system-dependent way and searched in the default search
* path for dynamic libraries:
*
* On POSIX systems, if the name contains no dot, the extension .so is appended. Also, the lib prefix is prepended if necessary. So ffi.load("z") looks for "libz.so" in the default shared library search path.
* On POSIX systems, if the name contains no dot, the extension .so is
* appended. Also, the lib prefix is prepended if necessary. So ffi.load("z")
* looks for "libz.so" in the default shared library search path.
*
* On Windows systems, if the name contains no dot, the extension .dll is appended. So ffi.load("ws2_32") looks for "ws2_32.dll" in the default DLL search path.
* On Windows systems, if the name contains no dot, the extension .dll is
* appended. So ffi.load("ws2_32") looks for "ws2_32.dll" in the default DLL
* search path.
*/

@@ -168,7 +241,11 @@ function load(name: string, global?: boolean): any;

*
* The current function, i.e. the Lua function calling this library function, can also be specified by passing true as the first argument.
* The current function, i.e. the Lua function calling this library function,
* can also be specified by passing true as the first argument.
*
* If the second argument is true, JIT compilation is also enabled, disabled or flushed recursively for all sub-functions of a function. With false only the sub-functions are affected.
* If the second argument is true, JIT compilation is also enabled, disabled
* or flushed recursively for all sub-functions of a function. With false only
* the sub-functions are affected.
*
* This function only sets a flag which is checked when the function is about to be compiled. It does not trigger immediate compilation.
* This function only sets a flag which is checked when the function is about
* to be compiled. It does not trigger immediate compilation.
*/

@@ -178,9 +255,14 @@ function on(func: Function | true, recursive?: boolean): void;

/**
* Disables JIT compilation for a Lua function and flushes any already compiled code from the code cache.
* Disables JIT compilation for a Lua function and flushes any already
* compiled code from the code cache.
*
* The current function, i.e. the Lua function calling this library function, can also be specified by passing true as the first argument.
* The current function, i.e. the Lua function calling this library function,
* can also be specified by passing true as the first argument.
*
* If the second argument is true, JIT compilation is also enabled, disabled or flushed recursively for all sub-functions of a function. With false only the sub-functions are affected.
* If the second argument is true, JIT compilation is also enabled, disabled
* or flushed recursively for all sub-functions of a function. With false only
* the sub-functions are affected.
*
* This function only sets a flag which is checked when the function is about to be compiled. It does not trigger immediate compilation.
* This function only sets a flag which is checked when the function is about
* to be compiled. It does not trigger immediate compilation.
*/

@@ -192,5 +274,8 @@ function off(func: Function | true, recursive?: boolean): void;

*
* The current function, i.e. the Lua function calling this library function, can also be specified by passing true as the first argument.
* The current function, i.e. the Lua function calling this library function,
* can also be specified by passing true as the first argument.
*
* If the second argument is true, JIT compilation is also enabled, disabled or flushed recursively for all sub-functions of a function. With false only the sub-functions are affected.
* If the second argument is true, JIT compilation is also enabled, disabled
* or flushed recursively for all sub-functions of a function. With false only
* the sub-functions are affected.
*/

@@ -200,3 +285,5 @@ function flush(func: Function | true, recursive?: boolean): void;

/**
* Flushes the root trace, specified by its number, and all of its side traces from the cache. The code for the trace will be retained as long as there are any other traces which link to it.
* Flushes the root trace, specified by its number, and all of its side traces
* from the cache. The code for the trace will be retained as long as there
* are any other traces which link to it.
*/

@@ -206,3 +293,5 @@ function flush(tr: number): void;

/**
* Returns the current status of the JIT compiler. The first result is either true or false if the JIT compiler is turned on or off. The remaining results are strings for CPU-specific features and enabled optimizations.
* Returns the current status of the JIT compiler. The first result is either
* true or false if the JIT compiler is turned on or off. The remaining
* results are strings for CPU-specific features and enabled optimizations.
* @tupleReturn

@@ -218,3 +307,4 @@ */

/**
* Contains the version number of the LuaJIT core. Version xx.yy.zz is represented by the decimal number xxyyzz.
* Contains the version number of the LuaJIT core. Version xx.yy.zz is
* represented by the decimal number xxyyzz.
*/

@@ -244,3 +334,5 @@ const version_num: number;

*
* Unlike in LuaJIT 1.x, the module is built-in and optimization is turned on by default! It's no longer necessary to run require("jit.opt").start(), which was one of the ways to enable optimization.
* Unlike in LuaJIT 1.x, the module is built-in and optimization is turned on
* by default! It's no longer necessary to run require("jit.opt").start(),
* which was one of the ways to enable optimization.
*/

@@ -250,7 +342,10 @@ const opt: any;

/**
* This sub-module holds functions to introspect the bytecode, generated traces, the IR and the generated machine code. The functionality provided by this module is still in flux and therefore undocumented.
* This sub-module holds functions to introspect the bytecode, generated
* traces, the IR and the generated machine code. The functionality provided
* by this module is still in flux and therefore undocumented.
*
* The debug modules -jbc, -jv and -jdump make extensive use of these functions. Please check out their source code, if you want to know more.
* The debug modules -jbc, -jv and -jdump make extensive use of these
* functions. Please check out their source code, if you want to know more.
*/
const util: any;
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc