Skip to content

Commit a97ef3c

Browse files
committed
Types for Lua 5.5
1 parent b224030 commit a97ef3c

File tree

9 files changed

+1732
-1871
lines changed

9 files changed

+1732
-1871
lines changed

5.3.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/// <reference path="./core/index.d.ts" />
22
/// <reference path="./special/5.3.d.ts" />
3+
/// <reference path="./version-specific-functions/utf8-decode/utf8-offset-5.3-5.4.d.ts" />

5.4.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/// <reference path="./core/index.d.ts" />
22
/// <reference path="./special/5.4.d.ts" />
3+
/// <reference path="./version-specific-functions/utf8-decode/utf8-offset-5.3-5.4.d.ts" />

5.5.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/// <reference path="./core/index.d.ts" />
2+
/// <reference path="./special/5.5.d.ts" />
3+
/// <reference path="./version-specific-functions/utf8-decode/utf8-offset-5.5.d.ts" />

package-lock.json

Lines changed: 1646 additions & 1856 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

special/5.3-plus.d.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -165,21 +165,6 @@ declare namespace utf8 {
165165
* position of the first invalid byte.
166166
*/
167167
function len(s: string, i?: number, j?: number): number;
168-
169-
/**
170-
* Returns the position (in bytes) where the encoding of the n-th character of
171-
* s (counting from position i) starts. A negative n gets characters before
172-
* position i. The default for i is 1 when n is non-negative and #s + 1
173-
* otherwise, so that utf8.offset(s, -n) gets the offset of the n-th character
174-
* from the end of the string. If the specified character is neither in the
175-
* subject nor right after its end, the function returns nil.
176-
*
177-
* As a special case, when n is 0 the function returns the start of the
178-
* encoding of the character that contains the i-th byte of s.
179-
*
180-
* This function assumes that s is a valid UTF-8 string.
181-
*/
182-
function offset(s: string, n?: number, i?: number): number;
183168
}
184169

185170
interface LuaMetatable<T> {

special/5.5-plus.d.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/** @noSelfInFile */
2+
3+
declare namespace table {
4+
/**
5+
* Creates a new empty table, preallocating memory. This preallocation may help
6+
* performance and save memory when you know in advance how many elements the
7+
* table will have.
8+
*
9+
* @param nseq hint for how many elements the table will have as a sequence
10+
* @param nrec (optional) hint for how many other elements the table will have; its default is zero.
11+
*/
12+
function create<T>(nseq: number, nrec?: number): T[];
13+
}

special/5.5.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/// <reference path="./5.4.d.ts" />
2+
/// <reference path="./5.5-plus.d.ts" />
3+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// https://www.lua.org/manual/5.3/manual.html#6.5
2+
3+
/**
4+
* This library provides basic support for UTF-8 encoding. It provides all its
5+
* functions inside the table utf8. This library does not provide any support
6+
* for Unicode other than the handling of the encoding. Any operation that needs
7+
* the meaning of a character, such as character classification, is outside its
8+
* scope.
9+
*
10+
* Unless stated otherwise, all functions that expect a byte position as a
11+
* parameter assume that the given position is either the start of a byte
12+
* sequence or one plus the length of the subject string. As in the string
13+
* library, negative indices count from the end of the string.
14+
*/
15+
declare namespace utf8 {
16+
/**
17+
* Returns the position (in bytes) where the encoding of the n-th character of
18+
* s (counting from position i) starts. A negative n gets characters before
19+
* position i. The default for i is 1 when n is non-negative and #s + 1
20+
* otherwise, so that utf8.offset(s, -n) gets the offset of the n-th character
21+
* from the end of the string. If the specified character is neither in the
22+
* subject nor right after its end, the function returns nil.
23+
*
24+
* As a special case, when n is 0 the function returns the start of the
25+
* encoding of the character that contains the i-th byte of s.
26+
*
27+
* This function assumes that s is a valid UTF-8 string.
28+
*/
29+
function offset(s: string, n?: number, i?: number): number;
30+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// https://www.lua.org/manual/5.5/manual.html#6.6
2+
3+
/**
4+
* This library provides basic support for UTF-8 encoding. It provides all its
5+
* functions inside the table utf8. This library does not provide any support
6+
* for Unicode other than the handling of the encoding. Any operation that needs
7+
* the meaning of a character, such as character classification, is outside its
8+
* scope.
9+
*
10+
* Unless stated otherwise, all functions that expect a byte position as a
11+
* parameter assume that the given position is either the start of a byte
12+
* sequence or one plus the length of the subject string. As in the string
13+
* library, negative indices count from the end of the string.
14+
*/
15+
declare namespace utf8 {
16+
/**
17+
* Returns the position of the n-th character of s (counting from byte
18+
* position i) as two integers: The index (in bytes) where its encoding
19+
* starts and the index (in bytes) where it ends.
20+
*
21+
* If the specified character is right after the end of s, the function
22+
* behaves as if there was a '\0' there. If the specified character is
23+
* neither in the subject nor right after its end, the function returns fail.
24+
*
25+
* A negative n gets characters before position i. The default for i is 1
26+
* when n is non-negative and #s + 1 otherwise, so that utf8.offset(s,-n)
27+
* gets the offset of the n-th character from the end of the string.
28+
*
29+
* As a special case, when n is 0 the function returns the start of the
30+
* encoding of the character that contains the i-th byte of s.
31+
*
32+
* This function assumes that s is a valid UTF-8 string.
33+
*/
34+
function offset(s: string, n?: number, i?: number): LuaMultiReturn<[number, number]>;
35+
}

0 commit comments

Comments
 (0)