toilscript 0.0.1 → 0.1.1

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.
Files changed (121) hide show
  1. package/LICENSE +201 -201
  2. package/NOTICE +94 -94
  3. package/README.md +101 -114
  4. package/bin/asc.js +0 -0
  5. package/bin/asinit.js +6 -6
  6. package/dist/asc.generated.d.ts +10027 -0
  7. package/dist/asc.js +24474 -0
  8. package/dist/asc.js.map +7 -0
  9. package/dist/importmap.json +9 -0
  10. package/dist/toilscript.generated.d.ts +11242 -0
  11. package/dist/toilscript.js +337 -0
  12. package/dist/toilscript.js.map +7 -0
  13. package/dist/web.js +22 -0
  14. package/lib/binaryen.d.ts +2 -2
  15. package/lib/binaryen.js +2 -2
  16. package/package.json +115 -114
  17. package/std/README.md +6 -6
  18. package/std/assembly/array.ts +550 -550
  19. package/std/assembly/arraybuffer.ts +77 -77
  20. package/std/assembly/atomics.ts +127 -127
  21. package/std/assembly/bindings/asyncify.ts +16 -16
  22. package/std/assembly/bindings/dom.ts +291 -291
  23. package/std/assembly/bindings/node.ts +6 -6
  24. package/std/assembly/bitflags.ts +53 -53
  25. package/std/assembly/builtins.ts +2650 -2650
  26. package/std/assembly/byteslice.ts +177 -177
  27. package/std/assembly/compat.ts +2 -2
  28. package/std/assembly/console.ts +42 -42
  29. package/std/assembly/crypto.ts +9 -9
  30. package/std/assembly/dataview.ts +181 -181
  31. package/std/assembly/date.ts +375 -375
  32. package/std/assembly/diagnostics.ts +11 -11
  33. package/std/assembly/encoding.ts +151 -151
  34. package/std/assembly/endian.ts +45 -45
  35. package/std/assembly/error.ts +44 -44
  36. package/std/assembly/fixedarray.ts +173 -173
  37. package/std/assembly/fixedmap.ts +326 -326
  38. package/std/assembly/fixedset.ts +275 -275
  39. package/std/assembly/function.ts +42 -42
  40. package/std/assembly/index.d.ts +2892 -2891
  41. package/std/assembly/iterator.ts +35 -35
  42. package/std/assembly/map.ts +269 -269
  43. package/std/assembly/math.ts +3289 -3289
  44. package/std/assembly/memory.ts +123 -123
  45. package/std/assembly/number.ts +388 -388
  46. package/std/assembly/object.ts +36 -36
  47. package/std/assembly/performance.ts +9 -9
  48. package/std/assembly/pointer.ts +80 -80
  49. package/std/assembly/polyfills.ts +27 -27
  50. package/std/assembly/process.ts +50 -50
  51. package/std/assembly/reference.ts +48 -48
  52. package/std/assembly/regexp.ts +12 -12
  53. package/std/assembly/rt/README.md +83 -83
  54. package/std/assembly/rt/common.ts +81 -81
  55. package/std/assembly/rt/index-incremental.ts +2 -2
  56. package/std/assembly/rt/index-memory.ts +1 -1
  57. package/std/assembly/rt/index-minimal.ts +2 -2
  58. package/std/assembly/rt/index-stub.ts +1 -1
  59. package/std/assembly/rt/index.d.ts +37 -37
  60. package/std/assembly/rt/itcms.ts +419 -419
  61. package/std/assembly/rt/memory-runtime.ts +94 -94
  62. package/std/assembly/rt/rtrace.ts +15 -15
  63. package/std/assembly/rt/stub.ts +133 -133
  64. package/std/assembly/rt/tcms.ts +254 -254
  65. package/std/assembly/rt/tlsf.ts +592 -592
  66. package/std/assembly/rt.ts +90 -90
  67. package/std/assembly/set.ts +225 -225
  68. package/std/assembly/shared/feature.ts +68 -68
  69. package/std/assembly/shared/runtime.ts +13 -13
  70. package/std/assembly/shared/target.ts +11 -11
  71. package/std/assembly/shared/tsconfig.json +11 -11
  72. package/std/assembly/shared/typeinfo.ts +72 -72
  73. package/std/assembly/staticarray.ts +423 -423
  74. package/std/assembly/string.ts +850 -850
  75. package/std/assembly/symbol.ts +114 -114
  76. package/std/assembly/table.ts +16 -16
  77. package/std/assembly/toilscript.ts +16 -0
  78. package/std/assembly/tsconfig.json +6 -6
  79. package/std/assembly/typedarray.ts +1954 -1954
  80. package/std/assembly/uri.ts +17 -17
  81. package/std/assembly/util/bytes.ts +107 -107
  82. package/std/assembly/util/casemap.ts +497 -497
  83. package/std/assembly/util/error.ts +58 -58
  84. package/std/assembly/util/hash.ts +117 -117
  85. package/std/assembly/util/math.ts +1922 -1922
  86. package/std/assembly/util/memory.ts +290 -290
  87. package/std/assembly/util/number.ts +873 -873
  88. package/std/assembly/util/sort.ts +313 -313
  89. package/std/assembly/util/string.ts +1202 -1202
  90. package/std/assembly/util/uri.ts +275 -275
  91. package/std/assembly/vector.ts +4 -4
  92. package/std/assembly.json +16 -16
  93. package/std/portable/index.d.ts +461 -461
  94. package/std/portable/index.js +416 -416
  95. package/std/portable.json +11 -11
  96. package/std/types/assembly/index.d.ts +1 -1
  97. package/std/types/assembly/package.json +2 -2
  98. package/std/types/portable/index.d.ts +1 -1
  99. package/std/types/portable/package.json +2 -2
  100. package/tsconfig-base.json +13 -13
  101. package/util/README.md +23 -23
  102. package/util/browser/fs.js +1 -1
  103. package/util/browser/module.js +5 -5
  104. package/util/browser/path.js +520 -520
  105. package/util/browser/process.js +59 -59
  106. package/util/browser/url.js +23 -23
  107. package/util/cpu.d.ts +9 -9
  108. package/util/cpu.js +42 -42
  109. package/util/find.d.ts +6 -6
  110. package/util/find.js +20 -20
  111. package/util/node.d.ts +21 -21
  112. package/util/node.js +34 -34
  113. package/util/options.d.ts +70 -70
  114. package/util/options.js +262 -262
  115. package/util/terminal.d.ts +52 -52
  116. package/util/terminal.js +35 -35
  117. package/util/text.d.ts +26 -26
  118. package/util/text.js +114 -114
  119. package/util/tsconfig.json +9 -9
  120. package/util/web.d.ts +11 -11
  121. package/util/web.js +33 -33
@@ -1,461 +1,461 @@
1
- /**
2
- * Environment definitions for compiling AssemblyScript to JavaScript using tsc.
3
- *
4
- * Note that semantic differences require additional explicit conversions for full compatibility.
5
- * For example, when casting an i32 to an u8, doing `<u8>(someI32 & 0xff)` will yield the same
6
- * result when compiling to WebAssembly or JS while `<u8>someI32` alone does nothing in JS.
7
- *
8
- * Note that i64's are not portable (JS numbers are IEEE754 doubles with a maximum safe integer
9
- * value of 2^53-1) and instead require a compatibility layer to work in JS as well, as for example
10
- * {@link glue/js/i64} respectively {@link glue/wasm/i64}.
11
- *
12
- * @module std/portable
13
- *//***/
14
-
15
- // Types
16
-
17
- declare type bool = boolean;
18
- declare type i8 = number;
19
- declare type i16 = number;
20
- declare type i32 = number;
21
- declare type isize = number;
22
- declare type u8 = number;
23
- declare type u16 = number;
24
- declare type u32 = number;
25
- declare type usize = number;
26
- declare type f32 = number;
27
- declare type f64 = number;
28
-
29
- /** Special type evaluating the indexed access index type. */
30
- declare type indexof<T extends unknown[]> = keyof T;
31
- /** Special type evaluating the indexed access value type. */
32
- declare type valueof<T extends unknown[]> = T[0];
33
-
34
- // Compiler hints
35
-
36
- /** Compiler target. 0 = JS, 1 = WASM32, 2 = WASM64. */
37
- declare const ASC_TARGET: i32;
38
- /** Runtime type. 0 = Stub, 1 = Minimal, 2 = Incremental. */
39
- declare const ASC_RUNTIME: i32;
40
- /** Provided noAssert option. */
41
- declare const ASC_NO_ASSERT: bool;
42
- /** Provided memoryBase option. */
43
- declare const ASC_MEMORY_BASE: i32;
44
- /** Provided optimizeLevel option. */
45
- declare const ASC_OPTIMIZE_LEVEL: i32;
46
- /** Provided shrinkLevel option. */
47
- declare const ASC_SHRINK_LEVEL: i32;
48
- /** Whether the mutable global feature is enabled. */
49
- declare const ASC_FEATURE_MUTABLE_GLOBAL: bool;
50
- /** Whether the sign extension feature is enabled. */
51
- declare const ASC_FEATURE_SIGN_EXTENSION: bool;
52
-
53
- // Builtins
54
-
55
- /** Performs the sign-agnostic reverse bytes **/
56
- declare function bswap<T = i32 | u32 | isize | usize>(value: T): T;
57
- /** Performs the sign-agnostic count leading zero bits operation on a 32-bit integer. All zero bits are considered leading if the value is zero. */
58
- declare function clz<T = i32>(value: T): T;
59
- /** Performs the sign-agnostic count tailing zero bits operation on a 32-bit integer. All zero bits are considered trailing if the value is zero. */
60
- declare function ctz<T = i32>(value: T): T;
61
- /** Performs the sign-agnostic count number of one bits operation on a 32-bit integer. */
62
- declare function popcnt<T = i32>(value: T): T;
63
- /** Performs the sign-agnostic rotate left operation on a 32-bit integer. */
64
- declare function rotl<T = i32>(value: T, shift: T): T;
65
- /** Performs the sign-agnostic rotate right operation on a 32-bit integer. */
66
- declare function rotr<T = i32>(value: T, shift: T): T;
67
- /** Computes the absolute value of an integer or float. */
68
- declare function abs<T = i32 | f32 | f64>(value: T): T;
69
- /** Determines the maximum of two integers or floats. If either operand is `NaN`, returns `NaN`. */
70
- declare function max<T = i32 | f32 | f64>(left: T, right: T): T;
71
- /** Determines the minimum of two integers or floats. If either operand is `NaN`, returns `NaN`. */
72
- declare function min<T = i32 | f32 | f64>(left: T, right: T): T;
73
- /** Composes a 32-bit or 64-bit float from the magnitude of `x` and the sign of `y`. */
74
- declare function copysign<T = f32 | f64>(x: T, y: T): T;
75
- /** Performs the ceiling operation on a 32-bit or 64-bit float. */
76
- declare function ceil<T = f32 | f64>(value: T): T;
77
- /** Performs the floor operation on a 32-bit or 64-bit float. */
78
- declare function floor<T = f32 | f64>(value: T): T;
79
- /** Rounds to the nearest integer tied to even of a 32-bit or 64-bit float. */
80
- declare function nearest<T = f32 | f64>(value: T): T;
81
- /** Selects one of two pre-evaluated values depending on the condition. */
82
- declare function select<T>(ifTrue: T, ifFalse: T, condition: bool): T;
83
- /** Calculates the square root of a 32-bit or 64-bit float. */
84
- declare function sqrt<T = f32 | f64>(value: T): T;
85
- /** Rounds to the nearest integer towards zero of a 32-bit or 64-bit float. */
86
- declare function trunc<T = f32 | f64>(value: T): T;
87
- /** Emits an unreachable operation that results in a runtime error when executed. */
88
- declare function unreachable(): any; // sic
89
-
90
- /** Changes the type of any value of `usize` kind to another one of `usize` kind. Useful for casting class instances to their pointer values and vice-versa. Beware that this is unsafe.*/
91
- declare function changetype<T>(value: any): T;
92
- /** Explicitly requests no bounds checks on the provided expression. Useful for array accesses. */
93
- declare function unchecked<T>(value: T): T;
94
- /** Tests if the specified value is a valid integer. Can't distinguish an integer from an integral float. */
95
- declare function isInteger(value: any): value is number;
96
- /** Tests if the specified value is a valid float. Can't distinguish a float from an integer. */
97
- declare function isFloat(value: any): value is number;
98
- /** Tests if the specified value is of a nullable reference type. */
99
- declare function isNullable(value: any): bool;
100
- /** Tests if the specified value is of a reference type. */
101
- declare function isReference(value: any): value is object | string;
102
- /** Tests if the specified value is of a function type */
103
- declare function isFunction(value: any): value is Function;
104
- /** Tests if the specified value can be used as a string. */
105
- declare function isString(value: any): value is string | String;
106
- /** Tests if the specified value can be used as an array. */
107
- declare function isArray(value: any): value is Array<any>;
108
- /** Tests if the specified type *or* expression can be used as an array like object. */
109
- declare function isArrayLike(value: any): value is ArrayLike<any>;
110
- /** Tests if the specified expression resolves to a defined element. */
111
- declare function isDefined(expression: any): bool;
112
- /** Tests if the specified expression evaluates to a constant value. */
113
- declare function isConstant(expression: any): bool;
114
- /** Traps if the specified value is not true-ish, otherwise returns the value. */
115
- declare function assert<T>(isTrueish: T, message?: string): T & (object | string | number); // any better way to model `: T != null`?
116
- /** Parses an integer string to a 64-bit float. */
117
- declare function parseInt(str: string, radix?: i32): f64;
118
- /** Parses a floating point string to a 64-bit float. */
119
- declare function parseFloat(str: string): f64;
120
- /** Returns the 64-bit floating-point remainder of `x/y`. */
121
- declare function fmod(x: f64, y: f64): f64;
122
- /** Returns the 32-bit floating-point remainder of `x/y`. */
123
- declare function fmodf(x: f32, y: f32): f32;
124
-
125
- /** Converts any other numeric value to an 8-bit signed integer. */
126
- declare function i8(value: any): i8;
127
- declare namespace i8 {
128
- /** Smallest representable value. */
129
- export const MIN_VALUE: i8;
130
- /** Largest representable value. */
131
- export const MAX_VALUE: i8;
132
- /** Converts a string to a floating-point number and cast to target integer after. */
133
- export function parseFloat(string: string): i8;
134
- /** Parses a string as an integer. */
135
- export function parseInt(string: string, radix?: i32): i8;
136
- /** Parses a string as an i8. */
137
- export function parse(value: string, radix?: i32): i8;
138
- }
139
- /** Converts any other numeric value to a 16-bit signed integer. */
140
- declare function i16(value: any): i16;
141
- declare namespace i16 {
142
- /** Smallest representable value. */
143
- export const MIN_VALUE: i16;
144
- /** Largest representable value. */
145
- export const MAX_VALUE: i16;
146
- /** Converts a string to a floating-point number and cast to target integer after. */
147
- export function parseFloat(string: string): i16;
148
- /** Parses a string as an integer. */
149
- export function parseInt(string: string, radix?: i32): i16;
150
- /** Parses a string as an i16. */
151
- export function parse(value: string, radix?: i32): i16;
152
- }
153
- /** Converts any other numeric value to a 32-bit signed integer. */
154
- declare function i32(value: any): i32;
155
- declare namespace i32 {
156
- /** Smallest representable value. */
157
- export const MIN_VALUE: i32;
158
- /** Largest representable value. */
159
- export const MAX_VALUE: i32;
160
- /** Converts a string to a floating-point number and cast to target integer after. */
161
- export function parseFloat(string: string): i32;
162
- /** Parses a string as an integer. */
163
- export function parseInt(string: string, radix?: i32): i32;
164
- /** Parses a string as an i32. */
165
- export function parse(value: string, radix?: i32): i32;
166
- }
167
- /** Converts any other numeric value to a 32-bit (in WASM32) respectivel 64-bit (in WASM64) signed integer. */
168
- declare function isize(value: any): isize;
169
- declare namespace isize {
170
- /** Smallest representable value. */
171
- export const MIN_VALUE: isize;
172
- /** Largest representable value. */
173
- export const MAX_VALUE: isize;
174
- /** Converts a string to a floating-point number and cast to target integer after. */
175
- export function parseFloat(string: string): isize;
176
- /** Parses a string as an integer. */
177
- export function parseInt(string: string, radix?: i32): isize;
178
- /** Parses a string as an iszie. */
179
- export function parse(value: string, radix?: i32): isize;
180
- }
181
- /** Converts any other numeric value to an 8-bit unsigned integer. */
182
- declare function u8(value: any): u8;
183
- declare namespace u8 {
184
- /** Smallest representable value. */
185
- export const MIN_VALUE: u8;
186
- /** Largest representable value. */
187
- export const MAX_VALUE: u8;
188
- /** Converts a string to a floating-point number and cast to target integer after. */
189
- export function parseFloat(string: string): u8;
190
- /** Parses a string as an integer. */
191
- export function parseInt(string: string, radix?: i32): u8;
192
- /** Parses a string as an u8. */
193
- export function parse(value: string, radix?: i32): u8;
194
- }
195
- /** Converts any other numeric value to a 16-bit unsigned integer. */
196
- declare function u16(value: any): u16;
197
- declare namespace u16 {
198
- /** Smallest representable value. */
199
- export const MIN_VALUE: u16;
200
- /** Largest representable value. */
201
- export const MAX_VALUE: u16;
202
- /** Converts a string to a floating-point number and cast to target integer after. */
203
- export function parseFloat(string: string): u16;
204
- /** Parses a string as an integer. */
205
- export function parseInt(string: string, radix?: i32): u16;
206
- /** Parses a string as an u16. */
207
- export function parse(value: string, radix?: i32): u16;
208
- }
209
- /** Converts any other numeric value to a 32-bit unsigned integer. */
210
- declare function u32(value: any): u32;
211
- declare namespace u32 {
212
- /** Smallest representable value. */
213
- export const MIN_VALUE: u32;
214
- /** Largest representable value. */
215
- export const MAX_VALUE: u32;
216
- /** Converts a string to a floating-point number and cast to target integer after. */
217
- export function parseFloat(string: string): u32;
218
- /** Parses a string as an integer. */
219
- export function parseInt(string: string, radix?: i32): u32;
220
- /** Parses a string as an u32. */
221
- export function parse(value: string, radix?: i32): u32;
222
- }
223
- /** Converts any other numeric value to a 32-bit (in WASM32) respectivel 64-bit (in WASM64) unsigned integer. */
224
- declare function usize(value: any): isize;
225
- declare namespace usize {
226
- /** Smallest representable value. */
227
- export const MIN_VALUE: usize;
228
- /** Largest representable value. */
229
- export const MAX_VALUE: usize;
230
- /** Converts a string to a floating-point number and cast to target integer after. */
231
- export function parseFloat(string: string): usize;
232
- /** Parses a string as an integer. */
233
- export function parseInt(string: string, radix?: i32): usize;
234
- /** Parses a string as an usize. */
235
- export function parse(value: string, radix?: i32): usize;
236
- }
237
- /** Converts any other numeric value to a 1-bit unsigned integer. */
238
- declare function bool(value: any): bool;
239
- declare namespace bool {
240
- /** Smallest representable value. */
241
- export const MIN_VALUE: bool;
242
- /** Largest representable value. */
243
- export const MAX_VALUE: bool;
244
- /** Parses a string as a bool. */
245
- export function parse(value: string): bool;
246
- }
247
- /** Converts any other numeric value to a 32-bit float. */
248
- declare function f32(value: any): f32;
249
- declare namespace f32 {
250
- /** Smallest representable value. */
251
- export const MIN_VALUE: f32;
252
- /** Largest representable value. */
253
- export const MAX_VALUE: f32;
254
- /** Smallest normalized positive value. */
255
- export const MIN_NORMAL_VALUE: f32;
256
- /** Smallest safely representable integer value. */
257
- export const MIN_SAFE_INTEGER: f32;
258
- /** Largest safely representable integer value. */
259
- export const MAX_SAFE_INTEGER: f32;
260
- /** Positive infinity value. */
261
- export const POSITIVE_INFINITY: f32;
262
- /** Negative infinity value. */
263
- export const NEGATIVE_INFINITY: f32;
264
- /** Not a number value. */
265
- /* eslint no-shadow-restricted-names: "off" */
266
- export const NaN: f32;
267
- /** Difference between 1 and the smallest representable value greater than 1. */
268
- export const EPSILON: f32;
269
- /** Returns a boolean value that indicates whether a value is the reserved value NaN (not a number). */
270
- export function isNaN(value: f32): bool;
271
- /** Returns true if passed value is finite. */
272
- export function isFinite(value: f32): bool;
273
- /** Returns true if the value passed is a safe integer. */
274
- export function isSafeInteger(value: f32): bool;
275
- /** Returns true if the value passed is an integer, false otherwise. */
276
- export function isInteger(value: f32): bool;
277
- /** Converts a string to a floating-point number. */
278
- export function parseFloat(string: string): f32;
279
- /** Parses a string as an integer and convert to an f32. */
280
- export function parseInt(string: string, radix?: i32): f32;
281
- /** Parses a string as an f32. */
282
- export function parse(value: string): f32;
283
- }
284
- /** Converts any other numeric value to a 64-bit float. */
285
- declare function f64(value: any): f64;
286
- declare namespace f64 {
287
- /** Smallest representable value. */
288
- export const MIN_VALUE: f64;
289
- /** Largest representable value. */
290
- export const MAX_VALUE: f64;
291
- /** Smallest normalized positive value. */
292
- export const MIN_NORMAL_VALUE: f64;
293
- /** Smallest safely representable integer value. */
294
- export const MIN_SAFE_INTEGER: f64;
295
- /** Largest safely representable integer value. */
296
- export const MAX_SAFE_INTEGER: f64;
297
- /** Positive infinity value. */
298
- export const POSITIVE_INFINITY: f64;
299
- /** Negative infinity value. */
300
- export const NEGATIVE_INFINITY: f64;
301
- /** Not a number value. */
302
- export const NaN: f64;
303
- /** Difference between 1 and the smallest representable value greater than 1. */
304
- export const EPSILON: f64;
305
- /** Returns a boolean value that indicates whether a value is the reserved value NaN (not a number). */
306
- export function isNaN(value: f32): bool;
307
- /** Returns true if passed value is finite. */
308
- export function isFinite(value: f32): bool;
309
- /** Returns true if the value passed is a safe integer. */
310
- export function isSafeInteger(value: f64): bool;
311
- /** Returns true if the value passed is an integer, false otherwise. */
312
- export function isInteger(value: f64): bool;
313
- /** Converts a string to a floating-point number. */
314
- export function parseFloat(string: string): f64;
315
- /** Parses a string as an integer and convert to an f64. */
316
- export function parseInt(string: string, radix?: i32): f64;
317
- /** Parses a string as an f64. */
318
- export function parse(value: string): f64;
319
- }
320
-
321
- // Standard library
322
-
323
- declare const Mathf: typeof Math;
324
- declare const JSMath: typeof Math;
325
-
326
- declare interface StringConstructor {
327
- /** Equivalent to calling `String.fromCharCode` with multiple arguments. */
328
- fromCharCodes(arr: i32[]): string;
329
- /** Equivalent to calling `String.fromCodePoint` with multiple arguments. */
330
- fromCodePoints(arr: i32[]): string;
331
- }
332
-
333
- declare interface String {
334
- /** Returns value using relative indexing. Index may be negative */
335
- at(index: i32): string;
336
- }
337
-
338
- /** Annotates a class as being unmanaged with limited capabilities. */
339
- declare function unmanaged(constructor: Function): void;
340
-
341
- /** Environmental tracing function. */
342
- declare function trace(msg: string, n?: i32, a0?: f64, a1?: f64, a2?: f64, a3?: f64, a4?: f64): void;
343
-
344
- declare interface Array<T> {
345
- /** Returns value using relative indexing. Index may be negative */
346
- at(index: i32): T;
347
- /** Returns an index start searching from the end in the array */
348
- findLastIndex(callbackfn: (value: T, index: i32, self: Array<T>) => bool): i32;
349
- }
350
-
351
- declare interface Int8ArrayConstructor {
352
- /** Equivalent to calling `new Int8Array` with multiple arguments. */
353
- wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Int8Array;
354
- }
355
-
356
- declare interface Int8Array {
357
- /** Returns value using relative indexing. Index may be negative */
358
- at(index: i32): i8;
359
- /** Returns an index start searching from the end in the typedarray */
360
- findLastIndex(callbackfn: (value: i8, index: i32, self: Int8Array) => bool): i32;
361
- }
362
-
363
- declare interface Uint8ArrayConstructor {
364
- /** Equivalent to calling `new Uint8Array` with multiple arguments. */
365
- wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Uint8Array;
366
- }
367
-
368
- declare interface Uint8Array {
369
- /** Returns value using relative indexing. Index may be negative */
370
- at(index: i32): u8;
371
- /** Returns an index start searching from the end in the typedarray */
372
- findLastIndex(callbackfn: (value: u8, index: i32, self: Uint8Array) => bool): i32;
373
- }
374
-
375
- declare interface Uint8ClampedArrayConstructor {
376
- /** Equivalent to calling `new Uint8ClampedArray` with multiple arguments. */
377
- wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Uint8ClampedArray;
378
- }
379
-
380
- declare interface Uint8ClampedArray {
381
- /** Returns value using relative indexing. Index may be negative */
382
- at(index: i32): u8;
383
- /** Returns an index start searching from the end in the typedarray */
384
- findLastIndex(callbackfn: (value: u8, index: i32, self: Uint8ClampedArray) => bool): i32;
385
- }
386
-
387
- declare interface Int16ArrayConstructor {
388
- /** Equivalent to calling `new Int16Array` with multiple arguments. */
389
- wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Int16Array;
390
- }
391
-
392
- declare interface Int16Array {
393
- /** Returns value using relative indexing. Index may be negative */
394
- at(index: i32): i16;
395
- /** Returns an index start searching from the end in the typedarray */
396
- findLastIndex(callbackfn: (value: i16, index: i32, self: Int16Array) => bool): i32;
397
- }
398
-
399
- declare interface Uint16ArrayConstructor {
400
- /** Equivalent to calling `new Uint16Array` with multiple arguments. */
401
- wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Uint16Array;
402
- }
403
-
404
- declare interface Uint16Array {
405
- /** Returns value using relative indexing. Index may be negative */
406
- at(index: i32): u16;
407
- /** Returns an index start searching from the end in the typedarray */
408
- findLastIndex(callbackfn: (value: u16, index: i32, self: Uint16Array) => bool): i32;
409
- }
410
-
411
- declare interface Int32ArrayConstructor {
412
- /** Equivalent to calling `new Int32Array` with multiple arguments. */
413
- wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Int32Array;
414
- }
415
-
416
- declare interface Int32Array {
417
- /** Returns value using relative indexing. Index may be negative */
418
- at(index: i32): i32;
419
- /** Returns an index start searching from the end in the typedarray */
420
- findLastIndex(callbackfn: (value: i32, index: i32, self: Int32Array) => bool): i32;
421
- }
422
-
423
- declare interface Uint32ArrayConstructor {
424
- /** Equivalent to calling `new Uint32Array` with multiple arguments. */
425
- wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Uint32Array;
426
- }
427
-
428
- declare interface Uint32Array {
429
- /** Returns value using relative indexing. Index may be negative */
430
- at(index: i32): u32;
431
- /** Returns an index start searching from the end in the typedarray */
432
- findLastIndex(callbackfn: (value: u32, index: i32, self: Uint32Array) => bool): i32;
433
- }
434
-
435
- declare interface Float32ArrayConstructor {
436
- /** Equivalent to calling `new Float32Array` with multiple arguments. */
437
- wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Float32Array;
438
- }
439
-
440
- declare interface Float32Array {
441
- /** Returns value using relative indexing. Index may be negative */
442
- at(index: i32): f32;
443
- /** Returns an index start searching from the end in the typedarray */
444
- findLastIndex(callbackfn: (value: f32, index: i32, self: Float32Array) => bool): i32;
445
- }
446
-
447
- declare interface Float64ArrayConstructor {
448
- /** Equivalent to calling `new Float64Array` with multiple arguments. */
449
- wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Float64Array;
450
- }
451
-
452
- declare interface Float64Array {
453
- /** Returns value using relative indexing. Index may be negative */
454
- at(index: i32): f64;
455
- /** Returns an index start searching from the end in the typedarray */
456
- findLastIndex(callbackfn: (value: f64, index: i32, self: Float64Array) => bool): i32;
457
- }
458
-
459
- // FIXME: remove
460
- declare function offsetof<T>(fieldName?: string): usize;
461
- declare function idof<T>(): u32;
1
+ /**
2
+ * Environment definitions for compiling AssemblyScript to JavaScript using tsc.
3
+ *
4
+ * Note that semantic differences require additional explicit conversions for full compatibility.
5
+ * For example, when casting an i32 to an u8, doing `<u8>(someI32 & 0xff)` will yield the same
6
+ * result when compiling to WebAssembly or JS while `<u8>someI32` alone does nothing in JS.
7
+ *
8
+ * Note that i64's are not portable (JS numbers are IEEE754 doubles with a maximum safe integer
9
+ * value of 2^53-1) and instead require a compatibility layer to work in JS as well, as for example
10
+ * {@link glue/js/i64} respectively {@link glue/wasm/i64}.
11
+ *
12
+ * @module std/portable
13
+ *//***/
14
+
15
+ // Types
16
+
17
+ declare type bool = boolean;
18
+ declare type i8 = number;
19
+ declare type i16 = number;
20
+ declare type i32 = number;
21
+ declare type isize = number;
22
+ declare type u8 = number;
23
+ declare type u16 = number;
24
+ declare type u32 = number;
25
+ declare type usize = number;
26
+ declare type f32 = number;
27
+ declare type f64 = number;
28
+
29
+ /** Special type evaluating the indexed access index type. */
30
+ declare type indexof<T extends unknown[]> = keyof T;
31
+ /** Special type evaluating the indexed access value type. */
32
+ declare type valueof<T extends unknown[]> = T[0];
33
+
34
+ // Compiler hints
35
+
36
+ /** Compiler target. 0 = JS, 1 = WASM32, 2 = WASM64. */
37
+ declare const ASC_TARGET: i32;
38
+ /** Runtime type. 0 = Stub, 1 = Minimal, 2 = Incremental. */
39
+ declare const ASC_RUNTIME: i32;
40
+ /** Provided noAssert option. */
41
+ declare const ASC_NO_ASSERT: bool;
42
+ /** Provided memoryBase option. */
43
+ declare const ASC_MEMORY_BASE: i32;
44
+ /** Provided optimizeLevel option. */
45
+ declare const ASC_OPTIMIZE_LEVEL: i32;
46
+ /** Provided shrinkLevel option. */
47
+ declare const ASC_SHRINK_LEVEL: i32;
48
+ /** Whether the mutable global feature is enabled. */
49
+ declare const ASC_FEATURE_MUTABLE_GLOBAL: bool;
50
+ /** Whether the sign extension feature is enabled. */
51
+ declare const ASC_FEATURE_SIGN_EXTENSION: bool;
52
+
53
+ // Builtins
54
+
55
+ /** Performs the sign-agnostic reverse bytes **/
56
+ declare function bswap<T = i32 | u32 | isize | usize>(value: T): T;
57
+ /** Performs the sign-agnostic count leading zero bits operation on a 32-bit integer. All zero bits are considered leading if the value is zero. */
58
+ declare function clz<T = i32>(value: T): T;
59
+ /** Performs the sign-agnostic count tailing zero bits operation on a 32-bit integer. All zero bits are considered trailing if the value is zero. */
60
+ declare function ctz<T = i32>(value: T): T;
61
+ /** Performs the sign-agnostic count number of one bits operation on a 32-bit integer. */
62
+ declare function popcnt<T = i32>(value: T): T;
63
+ /** Performs the sign-agnostic rotate left operation on a 32-bit integer. */
64
+ declare function rotl<T = i32>(value: T, shift: T): T;
65
+ /** Performs the sign-agnostic rotate right operation on a 32-bit integer. */
66
+ declare function rotr<T = i32>(value: T, shift: T): T;
67
+ /** Computes the absolute value of an integer or float. */
68
+ declare function abs<T = i32 | f32 | f64>(value: T): T;
69
+ /** Determines the maximum of two integers or floats. If either operand is `NaN`, returns `NaN`. */
70
+ declare function max<T = i32 | f32 | f64>(left: T, right: T): T;
71
+ /** Determines the minimum of two integers or floats. If either operand is `NaN`, returns `NaN`. */
72
+ declare function min<T = i32 | f32 | f64>(left: T, right: T): T;
73
+ /** Composes a 32-bit or 64-bit float from the magnitude of `x` and the sign of `y`. */
74
+ declare function copysign<T = f32 | f64>(x: T, y: T): T;
75
+ /** Performs the ceiling operation on a 32-bit or 64-bit float. */
76
+ declare function ceil<T = f32 | f64>(value: T): T;
77
+ /** Performs the floor operation on a 32-bit or 64-bit float. */
78
+ declare function floor<T = f32 | f64>(value: T): T;
79
+ /** Rounds to the nearest integer tied to even of a 32-bit or 64-bit float. */
80
+ declare function nearest<T = f32 | f64>(value: T): T;
81
+ /** Selects one of two pre-evaluated values depending on the condition. */
82
+ declare function select<T>(ifTrue: T, ifFalse: T, condition: bool): T;
83
+ /** Calculates the square root of a 32-bit or 64-bit float. */
84
+ declare function sqrt<T = f32 | f64>(value: T): T;
85
+ /** Rounds to the nearest integer towards zero of a 32-bit or 64-bit float. */
86
+ declare function trunc<T = f32 | f64>(value: T): T;
87
+ /** Emits an unreachable operation that results in a runtime error when executed. */
88
+ declare function unreachable(): any; // sic
89
+
90
+ /** Changes the type of any value of `usize` kind to another one of `usize` kind. Useful for casting class instances to their pointer values and vice-versa. Beware that this is unsafe.*/
91
+ declare function changetype<T>(value: any): T;
92
+ /** Explicitly requests no bounds checks on the provided expression. Useful for array accesses. */
93
+ declare function unchecked<T>(value: T): T;
94
+ /** Tests if the specified value is a valid integer. Can't distinguish an integer from an integral float. */
95
+ declare function isInteger(value: any): value is number;
96
+ /** Tests if the specified value is a valid float. Can't distinguish a float from an integer. */
97
+ declare function isFloat(value: any): value is number;
98
+ /** Tests if the specified value is of a nullable reference type. */
99
+ declare function isNullable(value: any): bool;
100
+ /** Tests if the specified value is of a reference type. */
101
+ declare function isReference(value: any): value is object | string;
102
+ /** Tests if the specified value is of a function type */
103
+ declare function isFunction(value: any): value is Function;
104
+ /** Tests if the specified value can be used as a string. */
105
+ declare function isString(value: any): value is string | String;
106
+ /** Tests if the specified value can be used as an array. */
107
+ declare function isArray(value: any): value is Array<any>;
108
+ /** Tests if the specified type *or* expression can be used as an array like object. */
109
+ declare function isArrayLike(value: any): value is ArrayLike<any>;
110
+ /** Tests if the specified expression resolves to a defined element. */
111
+ declare function isDefined(expression: any): bool;
112
+ /** Tests if the specified expression evaluates to a constant value. */
113
+ declare function isConstant(expression: any): bool;
114
+ /** Traps if the specified value is not true-ish, otherwise returns the value. */
115
+ declare function assert<T>(isTrueish: T, message?: string): T & (object | string | number); // any better way to model `: T != null`?
116
+ /** Parses an integer string to a 64-bit float. */
117
+ declare function parseInt(str: string, radix?: i32): f64;
118
+ /** Parses a floating point string to a 64-bit float. */
119
+ declare function parseFloat(str: string): f64;
120
+ /** Returns the 64-bit floating-point remainder of `x/y`. */
121
+ declare function fmod(x: f64, y: f64): f64;
122
+ /** Returns the 32-bit floating-point remainder of `x/y`. */
123
+ declare function fmodf(x: f32, y: f32): f32;
124
+
125
+ /** Converts any other numeric value to an 8-bit signed integer. */
126
+ declare function i8(value: any): i8;
127
+ declare namespace i8 {
128
+ /** Smallest representable value. */
129
+ export const MIN_VALUE: i8;
130
+ /** Largest representable value. */
131
+ export const MAX_VALUE: i8;
132
+ /** Converts a string to a floating-point number and cast to target integer after. */
133
+ export function parseFloat(string: string): i8;
134
+ /** Parses a string as an integer. */
135
+ export function parseInt(string: string, radix?: i32): i8;
136
+ /** Parses a string as an i8. */
137
+ export function parse(value: string, radix?: i32): i8;
138
+ }
139
+ /** Converts any other numeric value to a 16-bit signed integer. */
140
+ declare function i16(value: any): i16;
141
+ declare namespace i16 {
142
+ /** Smallest representable value. */
143
+ export const MIN_VALUE: i16;
144
+ /** Largest representable value. */
145
+ export const MAX_VALUE: i16;
146
+ /** Converts a string to a floating-point number and cast to target integer after. */
147
+ export function parseFloat(string: string): i16;
148
+ /** Parses a string as an integer. */
149
+ export function parseInt(string: string, radix?: i32): i16;
150
+ /** Parses a string as an i16. */
151
+ export function parse(value: string, radix?: i32): i16;
152
+ }
153
+ /** Converts any other numeric value to a 32-bit signed integer. */
154
+ declare function i32(value: any): i32;
155
+ declare namespace i32 {
156
+ /** Smallest representable value. */
157
+ export const MIN_VALUE: i32;
158
+ /** Largest representable value. */
159
+ export const MAX_VALUE: i32;
160
+ /** Converts a string to a floating-point number and cast to target integer after. */
161
+ export function parseFloat(string: string): i32;
162
+ /** Parses a string as an integer. */
163
+ export function parseInt(string: string, radix?: i32): i32;
164
+ /** Parses a string as an i32. */
165
+ export function parse(value: string, radix?: i32): i32;
166
+ }
167
+ /** Converts any other numeric value to a 32-bit (in WASM32) respectivel 64-bit (in WASM64) signed integer. */
168
+ declare function isize(value: any): isize;
169
+ declare namespace isize {
170
+ /** Smallest representable value. */
171
+ export const MIN_VALUE: isize;
172
+ /** Largest representable value. */
173
+ export const MAX_VALUE: isize;
174
+ /** Converts a string to a floating-point number and cast to target integer after. */
175
+ export function parseFloat(string: string): isize;
176
+ /** Parses a string as an integer. */
177
+ export function parseInt(string: string, radix?: i32): isize;
178
+ /** Parses a string as an iszie. */
179
+ export function parse(value: string, radix?: i32): isize;
180
+ }
181
+ /** Converts any other numeric value to an 8-bit unsigned integer. */
182
+ declare function u8(value: any): u8;
183
+ declare namespace u8 {
184
+ /** Smallest representable value. */
185
+ export const MIN_VALUE: u8;
186
+ /** Largest representable value. */
187
+ export const MAX_VALUE: u8;
188
+ /** Converts a string to a floating-point number and cast to target integer after. */
189
+ export function parseFloat(string: string): u8;
190
+ /** Parses a string as an integer. */
191
+ export function parseInt(string: string, radix?: i32): u8;
192
+ /** Parses a string as an u8. */
193
+ export function parse(value: string, radix?: i32): u8;
194
+ }
195
+ /** Converts any other numeric value to a 16-bit unsigned integer. */
196
+ declare function u16(value: any): u16;
197
+ declare namespace u16 {
198
+ /** Smallest representable value. */
199
+ export const MIN_VALUE: u16;
200
+ /** Largest representable value. */
201
+ export const MAX_VALUE: u16;
202
+ /** Converts a string to a floating-point number and cast to target integer after. */
203
+ export function parseFloat(string: string): u16;
204
+ /** Parses a string as an integer. */
205
+ export function parseInt(string: string, radix?: i32): u16;
206
+ /** Parses a string as an u16. */
207
+ export function parse(value: string, radix?: i32): u16;
208
+ }
209
+ /** Converts any other numeric value to a 32-bit unsigned integer. */
210
+ declare function u32(value: any): u32;
211
+ declare namespace u32 {
212
+ /** Smallest representable value. */
213
+ export const MIN_VALUE: u32;
214
+ /** Largest representable value. */
215
+ export const MAX_VALUE: u32;
216
+ /** Converts a string to a floating-point number and cast to target integer after. */
217
+ export function parseFloat(string: string): u32;
218
+ /** Parses a string as an integer. */
219
+ export function parseInt(string: string, radix?: i32): u32;
220
+ /** Parses a string as an u32. */
221
+ export function parse(value: string, radix?: i32): u32;
222
+ }
223
+ /** Converts any other numeric value to a 32-bit (in WASM32) respectivel 64-bit (in WASM64) unsigned integer. */
224
+ declare function usize(value: any): isize;
225
+ declare namespace usize {
226
+ /** Smallest representable value. */
227
+ export const MIN_VALUE: usize;
228
+ /** Largest representable value. */
229
+ export const MAX_VALUE: usize;
230
+ /** Converts a string to a floating-point number and cast to target integer after. */
231
+ export function parseFloat(string: string): usize;
232
+ /** Parses a string as an integer. */
233
+ export function parseInt(string: string, radix?: i32): usize;
234
+ /** Parses a string as an usize. */
235
+ export function parse(value: string, radix?: i32): usize;
236
+ }
237
+ /** Converts any other numeric value to a 1-bit unsigned integer. */
238
+ declare function bool(value: any): bool;
239
+ declare namespace bool {
240
+ /** Smallest representable value. */
241
+ export const MIN_VALUE: bool;
242
+ /** Largest representable value. */
243
+ export const MAX_VALUE: bool;
244
+ /** Parses a string as a bool. */
245
+ export function parse(value: string): bool;
246
+ }
247
+ /** Converts any other numeric value to a 32-bit float. */
248
+ declare function f32(value: any): f32;
249
+ declare namespace f32 {
250
+ /** Smallest representable value. */
251
+ export const MIN_VALUE: f32;
252
+ /** Largest representable value. */
253
+ export const MAX_VALUE: f32;
254
+ /** Smallest normalized positive value. */
255
+ export const MIN_NORMAL_VALUE: f32;
256
+ /** Smallest safely representable integer value. */
257
+ export const MIN_SAFE_INTEGER: f32;
258
+ /** Largest safely representable integer value. */
259
+ export const MAX_SAFE_INTEGER: f32;
260
+ /** Positive infinity value. */
261
+ export const POSITIVE_INFINITY: f32;
262
+ /** Negative infinity value. */
263
+ export const NEGATIVE_INFINITY: f32;
264
+ /** Not a number value. */
265
+ /* eslint no-shadow-restricted-names: "off" */
266
+ export const NaN: f32;
267
+ /** Difference between 1 and the smallest representable value greater than 1. */
268
+ export const EPSILON: f32;
269
+ /** Returns a boolean value that indicates whether a value is the reserved value NaN (not a number). */
270
+ export function isNaN(value: f32): bool;
271
+ /** Returns true if passed value is finite. */
272
+ export function isFinite(value: f32): bool;
273
+ /** Returns true if the value passed is a safe integer. */
274
+ export function isSafeInteger(value: f32): bool;
275
+ /** Returns true if the value passed is an integer, false otherwise. */
276
+ export function isInteger(value: f32): bool;
277
+ /** Converts a string to a floating-point number. */
278
+ export function parseFloat(string: string): f32;
279
+ /** Parses a string as an integer and convert to an f32. */
280
+ export function parseInt(string: string, radix?: i32): f32;
281
+ /** Parses a string as an f32. */
282
+ export function parse(value: string): f32;
283
+ }
284
+ /** Converts any other numeric value to a 64-bit float. */
285
+ declare function f64(value: any): f64;
286
+ declare namespace f64 {
287
+ /** Smallest representable value. */
288
+ export const MIN_VALUE: f64;
289
+ /** Largest representable value. */
290
+ export const MAX_VALUE: f64;
291
+ /** Smallest normalized positive value. */
292
+ export const MIN_NORMAL_VALUE: f64;
293
+ /** Smallest safely representable integer value. */
294
+ export const MIN_SAFE_INTEGER: f64;
295
+ /** Largest safely representable integer value. */
296
+ export const MAX_SAFE_INTEGER: f64;
297
+ /** Positive infinity value. */
298
+ export const POSITIVE_INFINITY: f64;
299
+ /** Negative infinity value. */
300
+ export const NEGATIVE_INFINITY: f64;
301
+ /** Not a number value. */
302
+ export const NaN: f64;
303
+ /** Difference between 1 and the smallest representable value greater than 1. */
304
+ export const EPSILON: f64;
305
+ /** Returns a boolean value that indicates whether a value is the reserved value NaN (not a number). */
306
+ export function isNaN(value: f32): bool;
307
+ /** Returns true if passed value is finite. */
308
+ export function isFinite(value: f32): bool;
309
+ /** Returns true if the value passed is a safe integer. */
310
+ export function isSafeInteger(value: f64): bool;
311
+ /** Returns true if the value passed is an integer, false otherwise. */
312
+ export function isInteger(value: f64): bool;
313
+ /** Converts a string to a floating-point number. */
314
+ export function parseFloat(string: string): f64;
315
+ /** Parses a string as an integer and convert to an f64. */
316
+ export function parseInt(string: string, radix?: i32): f64;
317
+ /** Parses a string as an f64. */
318
+ export function parse(value: string): f64;
319
+ }
320
+
321
+ // Standard library
322
+
323
+ declare const Mathf: typeof Math;
324
+ declare const JSMath: typeof Math;
325
+
326
+ declare interface StringConstructor {
327
+ /** Equivalent to calling `String.fromCharCode` with multiple arguments. */
328
+ fromCharCodes(arr: i32[]): string;
329
+ /** Equivalent to calling `String.fromCodePoint` with multiple arguments. */
330
+ fromCodePoints(arr: i32[]): string;
331
+ }
332
+
333
+ declare interface String {
334
+ /** Returns value using relative indexing. Index may be negative */
335
+ at(index: i32): string;
336
+ }
337
+
338
+ /** Annotates a class as being unmanaged with limited capabilities. */
339
+ declare function unmanaged(constructor: Function): void;
340
+
341
+ /** Environmental tracing function. */
342
+ declare function trace(msg: string, n?: i32, a0?: f64, a1?: f64, a2?: f64, a3?: f64, a4?: f64): void;
343
+
344
+ declare interface Array<T> {
345
+ /** Returns value using relative indexing. Index may be negative */
346
+ at(index: i32): T;
347
+ /** Returns an index start searching from the end in the array */
348
+ findLastIndex(callbackfn: (value: T, index: i32, self: Array<T>) => bool): i32;
349
+ }
350
+
351
+ declare interface Int8ArrayConstructor {
352
+ /** Equivalent to calling `new Int8Array` with multiple arguments. */
353
+ wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Int8Array;
354
+ }
355
+
356
+ declare interface Int8Array {
357
+ /** Returns value using relative indexing. Index may be negative */
358
+ at(index: i32): i8;
359
+ /** Returns an index start searching from the end in the typedarray */
360
+ findLastIndex(callbackfn: (value: i8, index: i32, self: Int8Array) => bool): i32;
361
+ }
362
+
363
+ declare interface Uint8ArrayConstructor {
364
+ /** Equivalent to calling `new Uint8Array` with multiple arguments. */
365
+ wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Uint8Array;
366
+ }
367
+
368
+ declare interface Uint8Array {
369
+ /** Returns value using relative indexing. Index may be negative */
370
+ at(index: i32): u8;
371
+ /** Returns an index start searching from the end in the typedarray */
372
+ findLastIndex(callbackfn: (value: u8, index: i32, self: Uint8Array) => bool): i32;
373
+ }
374
+
375
+ declare interface Uint8ClampedArrayConstructor {
376
+ /** Equivalent to calling `new Uint8ClampedArray` with multiple arguments. */
377
+ wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Uint8ClampedArray;
378
+ }
379
+
380
+ declare interface Uint8ClampedArray {
381
+ /** Returns value using relative indexing. Index may be negative */
382
+ at(index: i32): u8;
383
+ /** Returns an index start searching from the end in the typedarray */
384
+ findLastIndex(callbackfn: (value: u8, index: i32, self: Uint8ClampedArray) => bool): i32;
385
+ }
386
+
387
+ declare interface Int16ArrayConstructor {
388
+ /** Equivalent to calling `new Int16Array` with multiple arguments. */
389
+ wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Int16Array;
390
+ }
391
+
392
+ declare interface Int16Array {
393
+ /** Returns value using relative indexing. Index may be negative */
394
+ at(index: i32): i16;
395
+ /** Returns an index start searching from the end in the typedarray */
396
+ findLastIndex(callbackfn: (value: i16, index: i32, self: Int16Array) => bool): i32;
397
+ }
398
+
399
+ declare interface Uint16ArrayConstructor {
400
+ /** Equivalent to calling `new Uint16Array` with multiple arguments. */
401
+ wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Uint16Array;
402
+ }
403
+
404
+ declare interface Uint16Array {
405
+ /** Returns value using relative indexing. Index may be negative */
406
+ at(index: i32): u16;
407
+ /** Returns an index start searching from the end in the typedarray */
408
+ findLastIndex(callbackfn: (value: u16, index: i32, self: Uint16Array) => bool): i32;
409
+ }
410
+
411
+ declare interface Int32ArrayConstructor {
412
+ /** Equivalent to calling `new Int32Array` with multiple arguments. */
413
+ wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Int32Array;
414
+ }
415
+
416
+ declare interface Int32Array {
417
+ /** Returns value using relative indexing. Index may be negative */
418
+ at(index: i32): i32;
419
+ /** Returns an index start searching from the end in the typedarray */
420
+ findLastIndex(callbackfn: (value: i32, index: i32, self: Int32Array) => bool): i32;
421
+ }
422
+
423
+ declare interface Uint32ArrayConstructor {
424
+ /** Equivalent to calling `new Uint32Array` with multiple arguments. */
425
+ wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Uint32Array;
426
+ }
427
+
428
+ declare interface Uint32Array {
429
+ /** Returns value using relative indexing. Index may be negative */
430
+ at(index: i32): u32;
431
+ /** Returns an index start searching from the end in the typedarray */
432
+ findLastIndex(callbackfn: (value: u32, index: i32, self: Uint32Array) => bool): i32;
433
+ }
434
+
435
+ declare interface Float32ArrayConstructor {
436
+ /** Equivalent to calling `new Float32Array` with multiple arguments. */
437
+ wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Float32Array;
438
+ }
439
+
440
+ declare interface Float32Array {
441
+ /** Returns value using relative indexing. Index may be negative */
442
+ at(index: i32): f32;
443
+ /** Returns an index start searching from the end in the typedarray */
444
+ findLastIndex(callbackfn: (value: f32, index: i32, self: Float32Array) => bool): i32;
445
+ }
446
+
447
+ declare interface Float64ArrayConstructor {
448
+ /** Equivalent to calling `new Float64Array` with multiple arguments. */
449
+ wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Float64Array;
450
+ }
451
+
452
+ declare interface Float64Array {
453
+ /** Returns value using relative indexing. Index may be negative */
454
+ at(index: i32): f64;
455
+ /** Returns an index start searching from the end in the typedarray */
456
+ findLastIndex(callbackfn: (value: f64, index: i32, self: Float64Array) => bool): i32;
457
+ }
458
+
459
+ // FIXME: remove
460
+ declare function offsetof<T>(fieldName?: string): usize;
461
+ declare function idof<T>(): u32;