From d32391055d976e16c8ceec423955c2d8dcb196fa Mon Sep 17 00:00:00 2001 From: dcode Date: Sat, 25 May 2019 14:48:58 +0200 Subject: [PATCH] getArrayView typings --- lib/loader/index.d.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/loader/index.d.ts b/lib/loader/index.d.ts index 3e394b96..a2a05a4a 100644 --- a/lib/loader/index.d.ts +++ b/lib/loader/index.d.ts @@ -11,6 +11,17 @@ interface ImportsObject { } } +type TypedArray + = Int8Array + | Uint8Array + | Uint8ClampedArray + | Int16Array + | Uint16Array + | Int32Array + | Uint32Array + | Float32Array + | Float64Array; + /** Utility mixed in by the loader. */ interface ASUtil { /** An 8-bit signed integer view on the memory. */ @@ -35,12 +46,14 @@ interface ASUtil { readonly F64: Float64Array; /** Allocates a new string in the module's memory and returns a reference (pointer) to it. */ __allocString(str: string): number; - /** Gets the value of a string from the module's memory. */ + /** Reads (copies) the value of a string from the module's memory. */ __getString(ref: number): string; /** Allocates a new array in the module's memory and returns a reference (pointer) to it. */ __allocArray(id: number, values: number[]): number; - /** Gets the values of an array from the module's memory. */ + /** Reads (copies) the values of an array from the module's memory. */ __getArray(ref: number): number[]; + /** Gets a view on the values of an array in the module's memory. */ + __getArrayView(ref: number): TypedArray; /** Retains a reference externally, making sure that it doesn't become collected prematurely. Returns the reference. */ __retain(ref: number): number; /** Releases a previously retained reference to an object, allowing the runtime to collect it once its reference count reaches zero. */