mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-21 02:31:41 +00:00
Add built-in valueof type
This commit is contained in:
2
std/assembly/index.d.ts
vendored
2
std/assembly/index.d.ts
vendored
@ -882,6 +882,8 @@ declare namespace v8x16 {
|
||||
}
|
||||
/** Macro type evaluating to the underlying native WebAssembly type. */
|
||||
declare type native<T> = T;
|
||||
/** Special type evaluating the value type of a collection. */
|
||||
declare type valueof<T extends unknown[]> = T[0];
|
||||
|
||||
/** Pseudo-class representing the backing class of integer types. */
|
||||
declare class _Integer {
|
||||
|
@ -1068,7 +1068,7 @@ function FOREACH<TArray extends ArrayBufferView, T>(
|
||||
|
||||
// @ts-ignore: decorator
|
||||
@inline
|
||||
export function REVERSE<TArray extends ArrayBufferView, T>(array: TArray): TArray {
|
||||
function REVERSE<TArray extends ArrayBufferView, T>(array: TArray): TArray {
|
||||
var dataStart = array.dataStart;
|
||||
for (let front = 0, back = array.length - 1; front < back; ++front, --back) {
|
||||
let frontPtr = dataStart + (<usize>front << alignof<T>());
|
||||
|
3
std/portable/index.d.ts
vendored
3
std/portable/index.d.ts
vendored
@ -28,6 +28,9 @@ declare type usize = number;
|
||||
declare type f32 = number;
|
||||
declare type f64 = number;
|
||||
|
||||
/** Special type evaluating the value type of a collection. */
|
||||
declare type valueof<T extends unknown[]> = T[0];
|
||||
|
||||
// Compiler hints
|
||||
|
||||
/** Compiler target. 0 = JS, 1 = WASM32, 2 = WASM64. */
|
||||
|
Reference in New Issue
Block a user