@tsonic/js-globals 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +53 -53
- package/package.json +2 -2
package/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* Key principle: Array<T> HAS JS members like .length and .map
|
|
10
10
|
* This enables JS-style programming while compiling to C# with Tsonic.JSRuntime
|
|
11
11
|
*
|
|
12
|
-
* Index-space values (length, indexOf, etc.) use
|
|
12
|
+
* Index-space values (length, indexOf, etc.) use `int` type alias from
|
|
13
13
|
* @tsonic/types to enable numeric proof validation for array indexing.
|
|
14
14
|
*/
|
|
15
15
|
|
|
@@ -29,7 +29,7 @@ declare global {
|
|
|
29
29
|
/**
|
|
30
30
|
* Returns the item located at the specified index.
|
|
31
31
|
*/
|
|
32
|
-
[n:
|
|
32
|
+
[n: int]: T;
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* Appends new elements to the end of an array, and returns the new length.
|
|
@@ -54,67 +54,67 @@ declare global {
|
|
|
54
54
|
/**
|
|
55
55
|
* Returns a copy of a section of an array.
|
|
56
56
|
*/
|
|
57
|
-
slice(start?:
|
|
57
|
+
slice(start?: int, end?: int): T[];
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
60
|
* Removes elements from an array and, if necessary, inserts new elements, returning deleted elements.
|
|
61
61
|
*/
|
|
62
|
-
splice(start:
|
|
62
|
+
splice(start: int, deleteCount?: int, ...items: T[]): T[];
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
65
|
* Returns the index of the first occurrence of a value in an array, or -1 if it is not present.
|
|
66
66
|
*/
|
|
67
|
-
indexOf(searchElement: T, fromIndex?:
|
|
67
|
+
indexOf(searchElement: T, fromIndex?: int): int;
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
70
|
* Returns the index of the last occurrence of a specified value in an array, or -1 if it is not present.
|
|
71
71
|
*/
|
|
72
|
-
lastIndexOf(searchElement: T, fromIndex?:
|
|
72
|
+
lastIndexOf(searchElement: T, fromIndex?: int): int;
|
|
73
73
|
|
|
74
74
|
/**
|
|
75
75
|
* Determines whether all the members of an array satisfy the specified test.
|
|
76
76
|
*/
|
|
77
|
-
every(predicate: (value: T, index:
|
|
77
|
+
every(predicate: (value: T, index: int, array: T[]) => unknown): boolean;
|
|
78
78
|
|
|
79
79
|
/**
|
|
80
80
|
* Determines whether the specified callback function returns true for any element of an array.
|
|
81
81
|
*/
|
|
82
|
-
some(predicate: (value: T, index:
|
|
82
|
+
some(predicate: (value: T, index: int, array: T[]) => unknown): boolean;
|
|
83
83
|
|
|
84
84
|
/**
|
|
85
85
|
* Performs the specified action for each element in an array.
|
|
86
86
|
*/
|
|
87
|
-
forEach(callbackfn: (value: T, index:
|
|
87
|
+
forEach(callbackfn: (value: T, index: int, array: T[]) => void): void;
|
|
88
88
|
|
|
89
89
|
/**
|
|
90
90
|
* Calls a defined callback function on each element of an array, and returns an array of the results.
|
|
91
91
|
*/
|
|
92
|
-
map<U>(callbackfn: (value: T, index:
|
|
92
|
+
map<U>(callbackfn: (value: T, index: int, array: T[]) => U): U[];
|
|
93
93
|
|
|
94
94
|
/**
|
|
95
95
|
* Returns the elements of an array that meet the condition specified in a callback function.
|
|
96
96
|
*/
|
|
97
|
-
filter(predicate: (value: T, index:
|
|
97
|
+
filter(predicate: (value: T, index: int, array: T[]) => unknown): T[];
|
|
98
98
|
|
|
99
99
|
/**
|
|
100
100
|
* Calls the specified callback function for all the elements in an array. The return value is the accumulated result.
|
|
101
101
|
*/
|
|
102
|
-
reduce<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex:
|
|
102
|
+
reduce<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: int, array: T[]) => U, initialValue: U): U;
|
|
103
103
|
|
|
104
104
|
/**
|
|
105
105
|
* Returns the value of the first element in the array where predicate is true, and undefined otherwise.
|
|
106
106
|
*/
|
|
107
|
-
find(predicate: (value: T, index:
|
|
107
|
+
find(predicate: (value: T, index: int, array: T[]) => unknown): T | undefined;
|
|
108
108
|
|
|
109
109
|
/**
|
|
110
110
|
* Returns the index of the first element in the array where predicate is true, and -1 otherwise.
|
|
111
111
|
*/
|
|
112
|
-
findIndex(predicate: (value: T, index:
|
|
112
|
+
findIndex(predicate: (value: T, index: int, array: T[]) => unknown): int;
|
|
113
113
|
|
|
114
114
|
/**
|
|
115
115
|
* Determines whether an array includes a certain element.
|
|
116
116
|
*/
|
|
117
|
-
includes(searchElement: T, fromIndex?:
|
|
117
|
+
includes(searchElement: T, fromIndex?: int): boolean;
|
|
118
118
|
|
|
119
119
|
/**
|
|
120
120
|
* Sorts an array in place.
|
|
@@ -139,44 +139,44 @@ declare global {
|
|
|
139
139
|
/**
|
|
140
140
|
* Returns the value of the element at the specified index, or undefined if the index is out of bounds.
|
|
141
141
|
*/
|
|
142
|
-
at(index:
|
|
142
|
+
at(index: int): T | undefined;
|
|
143
143
|
|
|
144
144
|
/**
|
|
145
145
|
* Returns a new array with all sub-array elements concatenated into it recursively up to the specified depth.
|
|
146
146
|
*/
|
|
147
|
-
flat<D extends
|
|
147
|
+
flat<D extends int = 1>(depth?: D): any[];
|
|
148
148
|
|
|
149
149
|
/**
|
|
150
150
|
* Calls a defined callback function on each element of an array, and then flattens the result by one level.
|
|
151
151
|
*/
|
|
152
|
-
flatMap<U>(callback: (value: T, index:
|
|
152
|
+
flatMap<U>(callback: (value: T, index: int, array: T[]) => U | U[]): U[];
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
interface ReadonlyArray<T> {
|
|
156
156
|
readonly length: int;
|
|
157
|
-
readonly [n:
|
|
158
|
-
slice(start?:
|
|
159
|
-
indexOf(searchElement: T, fromIndex?:
|
|
160
|
-
lastIndexOf(searchElement: T, fromIndex?:
|
|
161
|
-
every(predicate: (value: T, index:
|
|
162
|
-
some(predicate: (value: T, index:
|
|
163
|
-
forEach(callbackfn: (value: T, index:
|
|
164
|
-
map<U>(callbackfn: (value: T, index:
|
|
165
|
-
filter(predicate: (value: T, index:
|
|
166
|
-
reduce<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex:
|
|
167
|
-
find(predicate: (value: T, index:
|
|
168
|
-
findIndex(predicate: (value: T, index:
|
|
169
|
-
includes(searchElement: T, fromIndex?:
|
|
157
|
+
readonly [n: int]: T;
|
|
158
|
+
slice(start?: int, end?: int): T[];
|
|
159
|
+
indexOf(searchElement: T, fromIndex?: int): int;
|
|
160
|
+
lastIndexOf(searchElement: T, fromIndex?: int): int;
|
|
161
|
+
every(predicate: (value: T, index: int, array: readonly T[]) => unknown): boolean;
|
|
162
|
+
some(predicate: (value: T, index: int, array: readonly T[]) => unknown): boolean;
|
|
163
|
+
forEach(callbackfn: (value: T, index: int, array: readonly T[]) => void): void;
|
|
164
|
+
map<U>(callbackfn: (value: T, index: int, array: readonly T[]) => U): U[];
|
|
165
|
+
filter(predicate: (value: T, index: int, array: readonly T[]) => unknown): T[];
|
|
166
|
+
reduce<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: int, array: readonly T[]) => U, initialValue: U): U;
|
|
167
|
+
find(predicate: (value: T, index: int, array: readonly T[]) => unknown): T | undefined;
|
|
168
|
+
findIndex(predicate: (value: T, index: int, array: readonly T[]) => unknown): int;
|
|
169
|
+
includes(searchElement: T, fromIndex?: int): boolean;
|
|
170
170
|
concat(...items: (T | readonly T[])[]): T[];
|
|
171
171
|
join(separator?: string): string;
|
|
172
|
-
at(index:
|
|
172
|
+
at(index: int): T | undefined;
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
interface ArrayConstructor {
|
|
176
176
|
new <T>(...items: T[]): T[];
|
|
177
177
|
isArray(arg: any): arg is any[];
|
|
178
178
|
from<T>(arrayLike: ArrayLike<T>): T[];
|
|
179
|
-
from<T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k:
|
|
179
|
+
from<T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: int) => U): U[];
|
|
180
180
|
of<T>(...items: T[]): T[];
|
|
181
181
|
}
|
|
182
182
|
|
|
@@ -194,12 +194,12 @@ declare global {
|
|
|
194
194
|
/**
|
|
195
195
|
* Returns the character at the specified index.
|
|
196
196
|
*/
|
|
197
|
-
charAt(pos:
|
|
197
|
+
charAt(pos: int): string;
|
|
198
198
|
|
|
199
199
|
/**
|
|
200
200
|
* Returns the Unicode value of the character at the specified location.
|
|
201
201
|
*/
|
|
202
|
-
charCodeAt(index:
|
|
202
|
+
charCodeAt(index: int): int;
|
|
203
203
|
|
|
204
204
|
/**
|
|
205
205
|
* Returns a string that contains the concatenation of two or more strings.
|
|
@@ -209,42 +209,42 @@ declare global {
|
|
|
209
209
|
/**
|
|
210
210
|
* Returns the position of the first occurrence of a substring.
|
|
211
211
|
*/
|
|
212
|
-
indexOf(searchString: string, position?:
|
|
212
|
+
indexOf(searchString: string, position?: int): int;
|
|
213
213
|
|
|
214
214
|
/**
|
|
215
215
|
* Returns the last occurrence of a substring in the string.
|
|
216
216
|
*/
|
|
217
|
-
lastIndexOf(searchString: string, position?:
|
|
217
|
+
lastIndexOf(searchString: string, position?: int): int;
|
|
218
218
|
|
|
219
219
|
/**
|
|
220
220
|
* Determines whether a string contains another string.
|
|
221
221
|
*/
|
|
222
|
-
includes(searchString: string, position?:
|
|
222
|
+
includes(searchString: string, position?: int): boolean;
|
|
223
223
|
|
|
224
224
|
/**
|
|
225
225
|
* Determines whether a string begins with the characters of a specified string.
|
|
226
226
|
*/
|
|
227
|
-
startsWith(searchString: string, position?:
|
|
227
|
+
startsWith(searchString: string, position?: int): boolean;
|
|
228
228
|
|
|
229
229
|
/**
|
|
230
230
|
* Determines whether a string ends with the characters of a specified string.
|
|
231
231
|
*/
|
|
232
|
-
endsWith(searchString: string, endPosition?:
|
|
232
|
+
endsWith(searchString: string, endPosition?: int): boolean;
|
|
233
233
|
|
|
234
234
|
/**
|
|
235
235
|
* Returns a copy of this string starting at the specified index.
|
|
236
236
|
*/
|
|
237
|
-
slice(start?:
|
|
237
|
+
slice(start?: int, end?: int): string;
|
|
238
238
|
|
|
239
239
|
/**
|
|
240
240
|
* Returns a section of a string.
|
|
241
241
|
*/
|
|
242
|
-
substring(start:
|
|
242
|
+
substring(start: int, end?: int): string;
|
|
243
243
|
|
|
244
244
|
/**
|
|
245
245
|
* Gets a substring beginning at the specified location and having the specified length.
|
|
246
246
|
*/
|
|
247
|
-
substr(from:
|
|
247
|
+
substr(from: int, length?: int): string;
|
|
248
248
|
|
|
249
249
|
/**
|
|
250
250
|
* Converts all the alphabetic characters in a string to lowercase.
|
|
@@ -274,17 +274,17 @@ declare global {
|
|
|
274
274
|
/**
|
|
275
275
|
* Pads the current string with a given string to a given length from the start.
|
|
276
276
|
*/
|
|
277
|
-
padStart(targetLength:
|
|
277
|
+
padStart(targetLength: int, padString?: string): string;
|
|
278
278
|
|
|
279
279
|
/**
|
|
280
280
|
* Pads the current string with a given string to a given length from the end.
|
|
281
281
|
*/
|
|
282
|
-
padEnd(targetLength:
|
|
282
|
+
padEnd(targetLength: int, padString?: string): string;
|
|
283
283
|
|
|
284
284
|
/**
|
|
285
285
|
* Returns a string that is repeated the specified number of times.
|
|
286
286
|
*/
|
|
287
|
-
repeat(count:
|
|
287
|
+
repeat(count: int): string;
|
|
288
288
|
|
|
289
289
|
/**
|
|
290
290
|
* Replaces text in a string, using a regular expression or search string.
|
|
@@ -294,7 +294,7 @@ declare global {
|
|
|
294
294
|
/**
|
|
295
295
|
* Split a string into substrings using the specified separator.
|
|
296
296
|
*/
|
|
297
|
-
split(separator: string | RegExp, limit?:
|
|
297
|
+
split(separator: string | RegExp, limit?: int): string[];
|
|
298
298
|
|
|
299
299
|
/**
|
|
300
300
|
* Matches a string with a regular expression.
|
|
@@ -310,7 +310,7 @@ declare global {
|
|
|
310
310
|
interface StringConstructor {
|
|
311
311
|
new (value?: any): String;
|
|
312
312
|
(value?: any): string;
|
|
313
|
-
fromCharCode(...codes:
|
|
313
|
+
fromCharCode(...codes: int[]): string;
|
|
314
314
|
}
|
|
315
315
|
|
|
316
316
|
const String: StringConstructor;
|
|
@@ -407,7 +407,7 @@ declare global {
|
|
|
407
407
|
readonly global: boolean;
|
|
408
408
|
readonly ignoreCase: boolean;
|
|
409
409
|
readonly multiline: boolean;
|
|
410
|
-
lastIndex:
|
|
410
|
+
lastIndex: int;
|
|
411
411
|
}
|
|
412
412
|
|
|
413
413
|
interface RegExpConstructor {
|
|
@@ -418,12 +418,12 @@ declare global {
|
|
|
418
418
|
const RegExp: RegExpConstructor;
|
|
419
419
|
|
|
420
420
|
interface RegExpExecArray extends Array<string> {
|
|
421
|
-
index:
|
|
421
|
+
index: int;
|
|
422
422
|
input: string;
|
|
423
423
|
}
|
|
424
424
|
|
|
425
425
|
interface RegExpMatchArray extends Array<string> {
|
|
426
|
-
index?:
|
|
426
|
+
index?: int;
|
|
427
427
|
input?: string;
|
|
428
428
|
}
|
|
429
429
|
|
|
@@ -601,14 +601,14 @@ declare global {
|
|
|
601
601
|
* Additional types
|
|
602
602
|
*/
|
|
603
603
|
interface IArguments {
|
|
604
|
-
[index:
|
|
604
|
+
[index: int]: any;
|
|
605
605
|
length: int;
|
|
606
606
|
callee: Function;
|
|
607
607
|
}
|
|
608
608
|
|
|
609
609
|
interface ArrayLike<T> {
|
|
610
610
|
readonly length: int;
|
|
611
|
-
readonly [n:
|
|
611
|
+
readonly [n: int]: T;
|
|
612
612
|
}
|
|
613
613
|
}
|
|
614
614
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsonic/js-globals",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Global type definitions for Tsonic JS mode (noLib: true, JavaScript semantics)",
|
|
5
5
|
"main": "index.d.ts",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"typecheck": "tsc --noEmit"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@tsonic/types": "^0.3.
|
|
15
|
+
"@tsonic/types": "^0.3.1"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"typescript": "^5.0.0"
|