@cgtk/std 0.0.185 → 0.0.187
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/array.d.ts +3 -1
- package/array.js +4 -2
- package/assign.d.ts +1 -1
- package/assign.js +1 -1
- package/async.d.ts +4 -1
- package/async.js +5 -2
- package/checks.d.ts +3 -3
- package/checks.js +5 -5
- package/dom.d.ts +27 -16
- package/dom.js +7 -2
- package/fn.d.ts +11 -7
- package/fn.js +19 -14
- package/http.d.ts +1 -0
- package/http.js +5 -0
- package/iterable.d.ts +1 -0
- package/iterable.js +11 -1
- package/map.d.ts +5 -6
- package/map.js +3 -4
- package/math.d.ts +3 -0
- package/math.js +4 -0
- package/npy.d.ts +10 -0
- package/npy.js +29 -0
- package/number.d.ts +1 -0
- package/number.js +6 -0
- package/object.d.ts +8 -6
- package/object.js +6 -4
- package/package.json +7 -3
- package/port.d.ts +29 -0
- package/port.js +53 -0
- package/progress.d.ts +1 -1
- package/rect.d.ts +5 -0
- package/rect.js +16 -0
- package/resource.d.ts +9 -0
- package/resource.js +20 -0
- package/schedule.d.ts +6 -4
- package/schedule.js +11 -22
- package/set.d.ts +1 -0
- package/set.js +1 -0
- package/signal.d.ts +9 -4
- package/signal.js +28 -5
- package/string.d.ts +3 -1
- package/string.js +6 -0
- package/struct.d.ts +34 -20
- package/struct.js +45 -46
- package/tree.d.ts +1 -10
- package/tree.js +3 -9
- package/treemap.js +1 -1
- package/typedarray.d.ts +12 -4
- package/typedarray.js +4 -3
- package/types.d.ts +30 -10
- package/utils.d.ts +1 -1
- package/utils.js +1 -1
- package/weak.d.ts +1 -1
- package/weak.js +1 -1
package/types.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export type Key = string | number | symbol;
|
|
2
1
|
export interface RecordOf<T> {
|
|
3
|
-
[id:
|
|
2
|
+
[id: PropertyKey]: T;
|
|
4
3
|
}
|
|
5
4
|
export type ValueOf<T> = T[keyof T];
|
|
6
5
|
export type Tuple<T, N extends number, R extends T[] = []> = R['length'] extends N ? R : Tuple<T, N, [T, ...R]>;
|
|
@@ -8,24 +7,39 @@ export type Elements<A extends readonly unknown[]> = A extends readonly (infer T
|
|
|
8
7
|
export type MaybeFirst<T extends unknown[], S = void> = T extends {
|
|
9
8
|
length: 0;
|
|
10
9
|
} ? S : T[0];
|
|
11
|
-
export type Fn<T = any, R = any> = (x: T) => R;
|
|
12
|
-
export type FnP<T = any, R = any> = (x: T) => Promise<R>;
|
|
13
10
|
export type FnV<T extends any[] = any[], R = any> = (...x: T) => R;
|
|
11
|
+
export type Fn<T = any, R = any> = FnV<[T], R>;
|
|
12
|
+
export type FnP<T = any, R = any> = (x: T) => Promise<R>;
|
|
13
|
+
export type Fns<T> = {
|
|
14
|
+
[k in keyof T]: Fn<T[k]>;
|
|
15
|
+
};
|
|
14
16
|
export type FnF = <F extends FnV>(f: F) => (...xs: Parameters<F>) => ReturnType<F>;
|
|
15
|
-
export type
|
|
17
|
+
export type Dispose = Fn<void>;
|
|
18
|
+
export type Reactive<T = unknown, R = any> = Fn<Fn<T, R>, Dispose>;
|
|
19
|
+
export type Resource<T> = Reactive<T, Dispose | void>;
|
|
16
20
|
export type Constantly<T> = () => T;
|
|
17
21
|
export type FirstParam<F extends FnV> = MaybeFirst<Parameters<F>>;
|
|
18
|
-
export type
|
|
22
|
+
export type MaybePromise<T = unknown> = T | PromiseLike<T>;
|
|
19
23
|
export type Last<T extends any[]> = T extends [...any, infer Rest] ? Rest : never;
|
|
20
24
|
export type Tail<T extends any[]> = T extends [any, ...(infer Rest)] ? Rest : never;
|
|
25
|
+
export type Push<T extends any[], V> = [...T, V];
|
|
21
26
|
export type Pop<T extends any[]> = T extends [...infer head, any] ? head : never;
|
|
22
27
|
export type MinusOne<T extends number, A extends any[] = []> = A['length'] extends T ? Pop<A>['length'] : MinusOne<T, [...A, 0]>;
|
|
23
28
|
export type Take<N extends number, T extends any[], R extends any[] = []> = R['length'] extends N ? R : Take<N, Tail<T>, [...R, T[0]]>;
|
|
24
29
|
export type Skip<N extends number, T extends any[]> = N extends 0 ? T : Skip<MinusOne<N>, Tail<T>>;
|
|
25
|
-
export type
|
|
26
|
-
|
|
27
|
-
export type
|
|
28
|
-
export type
|
|
30
|
+
export type Range<N extends number, Acc extends number[] = []> = Acc['length'] extends N ? Acc[number] : Range<N, [...Acc, Acc['length']]>;
|
|
31
|
+
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
32
|
+
export type LastOf<T> = UnionToIntersection<T extends any ? (x: T) => void : never> extends (x: infer L) => void ? L : never;
|
|
33
|
+
export type UnionToTuple<T> = [T] extends [never] ? [] : Push<UnionToTuple<Exclude<T, LastOf<T>>>, LastOf<T>>;
|
|
34
|
+
export type Entry<K extends PropertyKey, V> = [K, V];
|
|
35
|
+
export type Entries<T> = {
|
|
36
|
+
[K in keyof T]: Entry<K, T[K]>;
|
|
37
|
+
}[keyof T];
|
|
38
|
+
export type EntriesTuple<T, K extends UnionToTuple<keyof T> = UnionToTuple<keyof T>> = {
|
|
39
|
+
[I in keyof K]: K[I] extends keyof T ? [K[I], T[K[I]]] : never;
|
|
40
|
+
};
|
|
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 BufferType<T extends TypedArray> = T extends TypedArray<infer S> ? S : never;
|
|
29
43
|
export type Numbers = Array<number> | TypedArray;
|
|
30
44
|
export type Eq<A, B = A> = FnV<[A, B], boolean>;
|
|
31
45
|
export type Pred<T> = Fn<T, boolean>;
|
|
@@ -40,3 +54,9 @@ export type Partials<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
|
40
54
|
export type KeyMap<T extends string> = {
|
|
41
55
|
[K in T]: Extract<K, T>;
|
|
42
56
|
};
|
|
57
|
+
export interface BufferView<T extends ArrayBufferLike = ArrayBufferLike> {
|
|
58
|
+
readonly buffer: T;
|
|
59
|
+
readonly byteLength: number;
|
|
60
|
+
readonly byteOffset: number;
|
|
61
|
+
}
|
|
62
|
+
export {};
|
package/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Tuple } from "./types
|
|
1
|
+
import type { Tuple } from "./types";
|
|
2
2
|
export declare function toposort(nodes: number[]): Generator<number | undefined, void, unknown>;
|
|
3
3
|
export declare const hex2rgb: (hex: string) => number[];
|
|
4
4
|
export declare const rgb2hex: (rgb: Tuple<number, 3>) => string;
|
package/utils.js
CHANGED
package/weak.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Fn, Optional } from "./types
|
|
1
|
+
import type { Fn, Optional } from "./types";
|
|
2
2
|
export declare const deref: <T extends WeakKey, F extends Fn<T>>(r: WeakRef<T>, f: F) => Optional<ReturnType<F>>;
|
package/weak.js
CHANGED