Skip to content

Commit 1925821

Browse files
iwoplazagreggman
authored andcommitted
feat: a wider BaseArgType
1 parent 571d055 commit 1925821

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/types.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
1+
/**
2+
* A type wider than `number[]`, omitting any instance functions
3+
* unused by the API, e.g., map, sort. This allows the math
4+
* functions to operate on a wider range of array-like
5+
* values.
6+
*/
7+
export interface MutableNumberArray {
8+
readonly length: number;
9+
[n: number]: number;
10+
}
11+
112
/**
213
* The types you can pass to most functions that take an
314
* array of numbers.
415
*/
5-
export type BaseArgType = Float32Array | Float64Array | number[];
16+
export type BaseArgType = Float32Array | Float64Array | MutableNumberArray;
617

718
function wrapConstructor<T extends new(...args: any[]) => any>(
819
OriginalConstructor: T,

src/wgpu-matrix.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Some docs
33
* @namespace wgpu-matrix
44
*/
5-
import {BaseArgType, ZeroArray} from './types';
5+
import {MutableNumberArray, BaseArgType, ZeroArray} from './types';
66
import {Mat3Arg, Mat3Type, getAPI as getMat3API} from './mat3-impl';
77
import {Mat4Arg, Mat4Type, getAPI as getMat4API} from './mat4-impl';
88
import {QuatArg, QuatType, getAPI as getQuatAPI, RotationOrder} from './quat-impl';
@@ -15,6 +15,7 @@ export {
1515
RotationOrder,
1616
utils,
1717

18+
MutableNumberArray,
1819
BaseArgType,
1920

2021
Mat3Arg,

0 commit comments

Comments
 (0)