lua-types
Advanced tools
Comparing version 2.9.1 to 2.10.0
@@ -28,3 +28,7 @@ // Based on https://www.lua.org/manual/5.3/manual.html#6.1 | ||
*/ | ||
declare function assert(v: any, message?: string): asserts v; | ||
declare function assert<V>(v: V): Exclude<V, undefined | null | false>; | ||
declare function assert<V, A extends any[]>( | ||
v: V, | ||
...args: A | ||
): LuaMultiReturn<[Exclude<V, undefined | null | false>, ...A]>; | ||
@@ -113,3 +117,3 @@ /** | ||
*/ | ||
declare function getmetatable<T extends object>(object: T): LuaMetatable<T> | undefined; | ||
declare function getmetatable<T>(object: T): LuaMetatable<T> | undefined; | ||
@@ -158,2 +162,5 @@ /** | ||
*/ | ||
declare function pairs<TKey, TValue>( | ||
t: LuaTable<TKey, TValue> | ||
): LuaIterable<LuaMultiReturn<[TKey, TValue]>>; | ||
declare function pairs<T>(t: T): LuaIterable<LuaMultiReturn<[keyof T, T[keyof T]]>>; | ||
@@ -240,6 +247,13 @@ | ||
*/ | ||
declare function setmetatable<T extends object, TIndex extends object>( | ||
declare function setmetatable< | ||
T extends object, | ||
TIndex extends object | ((this: T, key: any) => any) | undefined = undefined | ||
>( | ||
table: T, | ||
metatable: LuaMetatable<T & TIndex, TIndex> | null | undefined | ||
): T & TIndex; | ||
metatable?: LuaMetatable<T, TIndex> | null | ||
): TIndex extends (this: T, key: infer TKey) => infer TValue | ||
? T & { [K in TKey & string]: TValue } | ||
: TIndex extends object | ||
? T & TIndex | ||
: T; | ||
@@ -246,0 +260,0 @@ /** |
@@ -64,5 +64,3 @@ // Based on https://www.lua.org/manual/5.3/manual.html#6.8 | ||
): LuaIterable< | ||
LuaMultiReturn< | ||
[] extends T ? [string] : { [P in keyof T]: T[P] extends 'n' ? number : string } | ||
> | ||
LuaMultiReturn<[] extends T ? [string] : { [P in keyof T]: FileReadFormatToType<T[P]> }> | ||
>; | ||
@@ -104,3 +102,3 @@ | ||
*/ | ||
function popen(prog: string, mode?: 'r' | 'w'): LuaFile; | ||
function popen(prog: string, mode?: 'r' | 'w'): LuaMultiReturn<[LuaFile] | [undefined, string]>; | ||
@@ -110,5 +108,24 @@ /** | ||
*/ | ||
const read: LuaFile['read']; | ||
function read(): io.FileReadFormatToType<io.FileReadLineFormat> | undefined; | ||
function read<T extends io.FileReadFormat>(format: T): io.FileReadFormatToType<T> | undefined; | ||
function read<T extends io.FileReadFormat[]>( | ||
...formats: T | ||
): LuaMultiReturn<{ [P in keyof T]?: io.FileReadFormatToType<T[P]> }>; | ||
/** | ||
* Predefined file handle for standard error stream. The I/O library never closes this file. | ||
*/ | ||
const stderr: LuaFile; | ||
/** | ||
* Predefined file handle for standard input stream. The I/O library never closes this file. | ||
*/ | ||
const stdin: LuaFile; | ||
/** | ||
* Predefined file handle for standard output stream. The I/O library never closes this file. | ||
*/ | ||
const stdout: LuaFile; | ||
/** | ||
* In case of success, returns a handle for a temporary file. This file is | ||
@@ -131,2 +148,4 @@ * opened in update mode and it is automatically removed when the program | ||
function write(...args: (string | number)[]): LuaMultiReturn<[LuaFile] | [undefined, string]>; | ||
type FileReadFormatToType<T> = T extends FileReadNumberFormat ? number : string; | ||
} | ||
@@ -164,8 +183,6 @@ | ||
*/ | ||
lines<T extends FileReadFormat[]>( | ||
lines<T extends io.FileReadFormat[]>( | ||
...formats: T | ||
): LuaIterable< | ||
LuaMultiReturn< | ||
[] extends T ? [string] : { [P in keyof T]: T[P] extends 'n' ? number : string } | ||
> | ||
LuaMultiReturn<[] extends T ? [string] : { [P in keyof T]: io.FileReadFormatToType<T[P]> }> | ||
>; | ||
@@ -201,5 +218,7 @@ | ||
*/ | ||
read<T extends FileReadFormat[]>( | ||
read(): io.FileReadFormatToType<io.FileReadLineFormat> | undefined; | ||
read<T extends io.FileReadFormat>(format: T): io.FileReadFormatToType<T> | undefined; | ||
read<T extends io.FileReadFormat[]>( | ||
...formats: T | ||
): LuaMultiReturn<{ [P in keyof T]?: T[P] extends 'n' ? number : string }>; | ||
): LuaMultiReturn<{ [P in keyof T]?: io.FileReadFormatToType<T[P]> }>; | ||
@@ -206,0 +225,0 @@ /** |
// Based on https://www.lua.org/manual/5.3/manual.html#2.4 | ||
interface LuaMetatable<T, TIndex = object> { | ||
interface LuaMetatable<T, TIndex extends object | ((this: T, key: any) => any) | undefined> { | ||
/** | ||
@@ -105,3 +105,3 @@ * the addition (+) operation. If any operand for an addition is not a number | ||
*/ | ||
__index?: TIndex | ((this: T, key: any, value: any) => any); | ||
__index?: TIndex; | ||
@@ -108,0 +108,0 @@ /** |
@@ -183,2 +183,7 @@ // Based on https://www.lua.org/manual/5.3/manual.html#6.4 | ||
/** | ||
* Returns a string that is the concatenation of `n` copies of the string `s`. | ||
*/ | ||
function rep(s: string, n: number): string; | ||
/** | ||
* Returns a string that is the string s reversed. | ||
@@ -185,0 +190,0 @@ */ |
{ | ||
"name": "lua-types", | ||
"version": "2.9.1", | ||
"version": "2.10.0", | ||
"description": "TypeScript definitions for Lua standard library", | ||
@@ -14,4 +14,3 @@ "keywords": [ | ||
"files": [ | ||
"**/*.d.ts", | ||
"tsconfig.json" | ||
"**/*.d.ts" | ||
], | ||
@@ -18,0 +17,0 @@ "scripts": { |
@@ -99,2 +99,6 @@ /** @noSelfInFile */ | ||
type FileReadFormat = '*n' | '*a' | '*l' | number; | ||
declare namespace io { | ||
type FileReadNumberFormat = '*n'; | ||
type FileReadLineFormat = '*l'; | ||
type FileReadFormat = FileReadNumberFormat | FileReadLineFormat | '*a' | number; | ||
} |
@@ -1,1 +0,5 @@ | ||
type FileReadFormat = '*n' | '*a' | '*l' | '*L' | number; | ||
declare namespace io { | ||
type FileReadNumberFormat = '*n'; | ||
type FileReadLineFormat = '*l'; | ||
type FileReadFormat = FileReadNumberFormat | FileReadLineFormat | '*a' | '*L' | number; | ||
} |
@@ -230,2 +230,6 @@ /** @noSelfInFile */ | ||
type FileReadFormat = 'n' | 'a' | 'l' | 'L' | number; | ||
declare namespace io { | ||
type FileReadNumberFormat = 'n'; | ||
type FileReadLineFormat = 'l'; | ||
type FileReadFormat = FileReadNumberFormat | FileReadLineFormat | 'a' | 'L' | number; | ||
} |
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
129477
2860
0
35
1