From f2cd07b9f237ef832c24bfda6b613c2fb20a3c88 Mon Sep 17 00:00:00 2001 From: Iwo Plaza Date: Thu, 24 Oct 2024 20:57:20 +0200 Subject: [PATCH 1/2] feat: a wider BaseArgType --- src/types.ts | 13 ++++++++++++- src/wgpu-matrix.ts | 3 ++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/types.ts b/src/types.ts index 87cb587..8769bad 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,8 +1,19 @@ +/** + * A type wider than `number[]`, omitting any instance functions + * unused by the API, e.g., map, sort. This allows the math + * functions to operate on a wider range of array-like + * values. + */ +export interface MutableNumberArray { + readonly length: number; + [n: number]: number; +} + /** * The types you can pass to most functions that take an * array of numbers. */ -export type BaseArgType = Float32Array | Float64Array | number[]; +export type BaseArgType = Float32Array | Float64Array | MutableNumberArray; function wrapConstructor any>( OriginalConstructor: T, diff --git a/src/wgpu-matrix.ts b/src/wgpu-matrix.ts index d757056..4f51b2f 100644 --- a/src/wgpu-matrix.ts +++ b/src/wgpu-matrix.ts @@ -2,7 +2,7 @@ * Some docs * @namespace wgpu-matrix */ -import {BaseArgType, ZeroArray} from './types'; +import {MutableNumberArray, BaseArgType, ZeroArray} from './types'; import {Mat3Arg, Mat3Type, getAPI as getMat3API} from './mat3-impl'; import {Mat4Arg, Mat4Type, getAPI as getMat4API} from './mat4-impl'; import {QuatArg, QuatType, getAPI as getQuatAPI, RotationOrder} from './quat-impl'; @@ -15,6 +15,7 @@ export { RotationOrder, utils, + MutableNumberArray, BaseArgType, Mat3Arg, From cc8f3e09641686450196d7b2bb0f338d32b9ca41 Mon Sep 17 00:00:00 2001 From: Iwo Plaza Date: Thu, 24 Oct 2024 21:04:36 +0200 Subject: [PATCH 2/2] Tabs -> Spaces --- src/types.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/types.ts b/src/types.ts index 8769bad..726151a 100644 --- a/src/types.ts +++ b/src/types.ts @@ -5,8 +5,8 @@ * values. */ export interface MutableNumberArray { - readonly length: number; - [n: number]: number; + readonly length: number; + [n: number]: number; } /**