@cgtk/std 0.0.188 → 0.0.189
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/http.d.ts +1 -1
- package/package.json +1 -1
- package/struct.d.ts +5 -3
- package/struct.js +2 -0
- package/typedarray.d.ts +4 -4
- package/types.d.ts +2 -1
package/http.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare const assertStatus: (status: number) => (resp: Response) => void;
|
|
2
2
|
export declare const contentLength: (response: Response) => number;
|
|
3
3
|
export declare const toByteArray: (stream: ReadableStream<Uint8Array>) => Promise<Uint8Array<ArrayBufferLike>>;
|
|
4
|
-
export declare const fetchBuffer: (url: string, init?: RequestInit) => Promise<Uint8Array<ArrayBufferLike>>;
|
|
4
|
+
export declare const fetchBuffer: (url: string | URL | Request, init?: RequestInit) => Promise<Uint8Array<ArrayBufferLike>>;
|
|
5
5
|
export declare const fetchText: (url: string, init?: RequestInit) => Promise<string>;
|
|
6
6
|
export declare const fetchDOM: (url: string, init?: RequestInit) => Promise<HTMLElement>;
|
|
7
7
|
export declare const fetchImage: (src: string) => Promise<HTMLImageElement>;
|
package/package.json
CHANGED
package/struct.d.ts
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import type { TypedArray, Fn } from "./types";
|
|
1
|
+
import type { TypedArray, BigIntArray, Fn } from "./types";
|
|
2
2
|
import type { Constructor } from "./typedarray";
|
|
3
3
|
export interface Type {
|
|
4
4
|
size: number;
|
|
5
5
|
align: number;
|
|
6
6
|
}
|
|
7
|
-
export type Vec<T extends TypedArray, N extends number> = Type & {
|
|
7
|
+
export type Vec<T extends TypedArray | BigIntArray, N extends number> = Type & {
|
|
8
8
|
length: N;
|
|
9
9
|
type: Constructor<T>;
|
|
10
10
|
};
|
|
11
11
|
export declare const u8: <N extends number = 1>(length?: N, align?: number) => Vec<Uint8Array<ArrayBufferLike>, N>;
|
|
12
12
|
export declare const u16: <N extends number = 1>(length?: N, align?: number) => Vec<Uint16Array<ArrayBufferLike>, N>;
|
|
13
13
|
export declare const u32: <N extends number = 1>(length?: N, align?: number) => Vec<Uint32Array<ArrayBufferLike>, N>;
|
|
14
|
+
export declare const u64: <N extends number = 1>(length?: N, align?: number) => Vec<BigUint64Array<ArrayBufferLike>, N>;
|
|
14
15
|
export declare const i8: <N extends number = 1>(length?: N, align?: number) => Vec<Int8Array<ArrayBufferLike>, N>;
|
|
15
16
|
export declare const i16: <N extends number = 1>(length?: N, align?: number) => Vec<Int16Array<ArrayBufferLike>, N>;
|
|
16
17
|
export declare const i32: <N extends number = 1>(length?: N, align?: number) => Vec<Int32Array<ArrayBufferLike>, N>;
|
|
18
|
+
export declare const i64: <N extends number = 1>(length?: N, align?: number) => Vec<BigInt64Array<ArrayBufferLike>, N>;
|
|
17
19
|
export declare const f16: <N extends number = 1>(length?: N, align?: number) => Vec<Float16Array<ArrayBufferLike>, N>;
|
|
18
20
|
export declare const f32: <N extends number = 1>(length?: N, align?: number) => Vec<Float32Array<ArrayBufferLike>, N>;
|
|
19
21
|
export declare const f64: <N extends number = 1>(length?: N, align?: number) => Vec<Float64Array<ArrayBufferLike>, N>;
|
|
@@ -24,7 +26,7 @@ export type Array<T extends Type> = Type & {
|
|
|
24
26
|
};
|
|
25
27
|
export declare const isArray: (t: any) => t is Array<any>;
|
|
26
28
|
export declare const array: <T extends Type>(type: T, length: number, align?: number) => Array<T>;
|
|
27
|
-
type Field<T extends Type> = readonly [name: string, type: T,
|
|
29
|
+
type Field<T extends Type> = readonly [name: string, type: T, align?: number];
|
|
28
30
|
export type Struct<T extends ReadonlyArray<Field<any>>> = Type & {
|
|
29
31
|
fields: {
|
|
30
32
|
[K in T[number] as K[0]]: K[1];
|
package/struct.js
CHANGED
|
@@ -6,9 +6,11 @@ const vec = (type) => (length = 1, align = type.BYTES_PER_ELEMENT) => ({
|
|
|
6
6
|
export const u8 = vec(Uint8Array);
|
|
7
7
|
export const u16 = vec(Uint16Array);
|
|
8
8
|
export const u32 = vec(Uint32Array);
|
|
9
|
+
export const u64 = vec(BigUint64Array);
|
|
9
10
|
export const i8 = vec(Int8Array);
|
|
10
11
|
export const i16 = vec(Int16Array);
|
|
11
12
|
export const i32 = vec(Int32Array);
|
|
13
|
+
export const i64 = vec(BigInt64Array);
|
|
12
14
|
export const f16 = vec(Float16Array);
|
|
13
15
|
export const f32 = vec(Float32Array);
|
|
14
16
|
export const f64 = vec(Float64Array);
|
package/typedarray.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { Fn, FnV, TypedArray, BufferType, Numbers } from "./types";
|
|
2
|
-
export interface Constructor<T extends TypedArray> {
|
|
1
|
+
import type { Fn, FnV, TypedArray, BigIntArray, BufferType, Numbers } from "./types";
|
|
2
|
+
export interface Constructor<T extends TypedArray | BigIntArray> {
|
|
3
3
|
new (length: number): T;
|
|
4
4
|
new (buffer: BufferType<T> | ArrayBufferLike, byteOffset?: number, length?: number): T;
|
|
5
5
|
readonly BYTES_PER_ELEMENT: number;
|
|
6
|
-
of(...items: number[]): T;
|
|
7
|
-
from(arrayLike: ArrayLike<number>): T;
|
|
6
|
+
of(...items: number[] | bigint[]): T;
|
|
7
|
+
from(arrayLike: ArrayLike<number | bigint>): T;
|
|
8
8
|
}
|
|
9
9
|
export type View<T extends TypedArray> = FnV<[BufferType<T>?, number?], T>;
|
|
10
10
|
export declare const view: <T extends TypedArray>(type: Constructor<T>, length: number) => View<T>;
|
package/types.d.ts
CHANGED
|
@@ -39,7 +39,8 @@ export type EntriesTuple<T, K extends UnionToTuple<keyof T> = UnionToTuple<keyof
|
|
|
39
39
|
[I in keyof K]: K[I] extends keyof T ? [K[I], T[K[I]]] : never;
|
|
40
40
|
};
|
|
41
41
|
export type TypedArray<T extends ArrayBufferLike = ArrayBufferLike> = Uint8Array<T> | Uint16Array<T> | Uint32Array<T> | Int8Array<T> | Int16Array<T> | Int32Array<T> | Float16Array<T> | Float32Array<T> | Float64Array<T>;
|
|
42
|
-
export type
|
|
42
|
+
export type BigIntArray<T extends ArrayBufferLike = ArrayBufferLike> = BigUint64Array<T> | BigInt64Array<T>;
|
|
43
|
+
export type BufferType<T extends TypedArray | BigIntArray> = T extends TypedArray<infer S> ? S : T extends BigIntArray<infer S> ? S : never;
|
|
43
44
|
export type Numbers = Array<number> | TypedArray;
|
|
44
45
|
export type Eq<A, B = A> = FnV<[A, B], boolean>;
|
|
45
46
|
export type Pred<T> = Fn<T, boolean>;
|