@cgtk/std 0.0.191 → 0.0.192

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cgtk/std",
3
- "version": "0.0.191",
3
+ "version": "0.0.192",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "exports": {
package/struct.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { TypedArray, Fn } from "./types";
1
+ import type { TypedArray, Fn, NumberArray } from "./types";
2
2
  import type { Constructor } from "./typedarray";
3
3
  export interface Type {
4
4
  size: number;
@@ -36,7 +36,7 @@ export type Struct<T extends ReadonlyArray<Field<any>>> = Type & {
36
36
  export declare const isStruct: (t: any) => t is Struct<any>;
37
37
  export declare const struct: <T extends ReadonlyArray<Field<any>>>(fs: T, align?: number, offset?: number) => Struct<T>;
38
38
  export type View<T extends Type> = T extends Vec<infer C, any> ? C : T extends Array<infer S> ? View<S>[] : T extends Struct<infer F> ? {
39
- [K in F[number] as K[0]]: K[1] extends Vec<infer C, infer N> ? (N extends 1 ? (C extends TypedArray ? number : bigint) : C) : View<K[1]>;
39
+ [K in F[number] as K[0]]: K[1] extends Vec<infer C, infer N> ? (N extends 1 ? (C extends NumberArray ? number : bigint) : C) : View<K[1]>;
40
40
  } : never;
41
41
  export declare const view: <T extends Vec<any, any> | Array<any> | Struct<any>>(t: T, buf?: ArrayBufferLike, offset?: number) => View<T>;
42
42
  export {};
package/struct.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { align as _align } from "./math";
2
- import { isTypedArray, isBigIntArray } from "./checks";
2
+ import { isBigIntArray, isNumberArray } from "./checks";
3
3
  const vec = (type) => (length = 1, align = type.BYTES_PER_ELEMENT) => ({
4
4
  type, align, length, size: type.BYTES_PER_ELEMENT * length,
5
5
  });
@@ -42,7 +42,7 @@ export const struct = (fs, align = 0, offset = 0) => {
42
42
  };
43
43
  const property = (value) => ({
44
44
  enumerable: true,
45
- ...((isTypedArray(value) || isBigIntArray(value)) && value.length == 1 ? {
45
+ ...((isNumberArray(value) || isBigIntArray(value)) && value.length == 1 ? {
46
46
  get: () => value[0],
47
47
  set: (x) => value[0] = x,
48
48
  } : { value })