@cgtk/std 0.0.194 → 0.0.195
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/async.d.ts +2 -2
- package/dom.d.ts +1 -0
- package/dom.js +5 -0
- package/fn.d.ts +3 -4
- package/fn.js +1 -2
- package/math.d.ts +1 -0
- package/math.js +1 -0
- package/package.json +1 -4
- package/resource.d.ts +3 -0
- package/resource.js +6 -0
- package/types.d.ts +2 -2
- package/src/array.d.ts +0 -14
- package/src/array.js +0 -21
- package/src/assign.d.ts +0 -8
- package/src/assign.js +0 -26
- package/src/async.d.ts +0 -8
- package/src/async.js +0 -31
- package/src/base64.d.ts +0 -1
- package/src/base64.js +0 -7
- package/src/basen.d.ts +0 -12
- package/src/basen.js +0 -31
- package/src/buffer.d.ts +0 -14
- package/src/buffer.js +0 -54
- package/src/checks.d.ts +0 -29
- package/src/checks.js +0 -44
- package/src/constants.d.ts +0 -5
- package/src/constants.js +0 -1
- package/src/dom.d.ts +0 -50
- package/src/dom.js +0 -36
- package/src/fn.d.ts +0 -33
- package/src/fn.js +0 -61
- package/src/http.d.ts +0 -9
- package/src/http.js +0 -33
- package/src/index.d.ts +0 -1
- package/src/index.js +0 -1
- package/src/iterable.d.ts +0 -43
- package/src/iterable.js +0 -158
- package/src/json.d.ts +0 -1
- package/src/json.js +0 -1
- package/src/map.d.ts +0 -12
- package/src/map.js +0 -35
- package/src/math.d.ts +0 -34
- package/src/math.js +0 -43
- package/src/npy.d.ts +0 -10
- package/src/npy.js +0 -29
- package/src/number.d.ts +0 -4
- package/src/number.js +0 -13
- package/src/object.d.ts +0 -15
- package/src/object.js +0 -13
- package/src/port.d.ts +0 -30
- package/src/port.js +0 -56
- package/src/progress.d.ts +0 -6
- package/src/progress.js +0 -1
- package/src/rect.d.ts +0 -5
- package/src/rect.js +0 -16
- package/src/resource.d.ts +0 -12
- package/src/resource.js +0 -28
- package/src/schedule.d.ts +0 -10
- package/src/schedule.js +0 -33
- package/src/set.d.ts +0 -2
- package/src/set.js +0 -2
- package/src/signal.d.ts +0 -37
- package/src/signal.js +0 -89
- package/src/stream.d.ts +0 -6
- package/src/stream.js +0 -26
- package/src/string.d.ts +0 -8
- package/src/string.js +0 -29
- package/src/struct.d.ts +0 -42
- package/src/struct.js +0 -58
- package/src/tree.d.ts +0 -11
- package/src/tree.js +0 -25
- package/src/treemap.d.ts +0 -13
- package/src/treemap.js +0 -71
- package/src/typedarray.d.ts +0 -31
- package/src/typedarray.js +0 -39
- package/src/types.d.ts +0 -63
- package/src/types.js +0 -1
- package/src/utils.d.ts +0 -4
- package/src/utils.js +0 -30
- package/src/weak.d.ts +0 -2
- package/src/weak.js +0 -5
package/async.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Fn,
|
|
1
|
+
import type { Fn, Lazy, Maybe, Dispose, MaybePromise } from "./types.js";
|
|
2
2
|
export declare const timeout: (ms: number, signal?: AbortSignal) => Promise<unknown>;
|
|
3
3
|
export declare const delay: (ms: number, signal?: AbortSignal) => <T>(x: T) => Promise<T>;
|
|
4
|
-
export declare const probing: <T>(p: Promise<T>) =>
|
|
4
|
+
export declare const probing: <T>(p: Promise<T>) => Lazy<Maybe<T>>;
|
|
5
5
|
export declare const resolved: <T>(p: Promise<T>) => (f: Fn<T>) => () => void;
|
|
6
6
|
export declare const promise: <T>(x: MaybePromise<T>) => Promise<any>;
|
|
7
7
|
export declare const then: <T>(p: Promise<T>) => <R>(f: Fn<T, R>) => Promise<R>;
|
package/dom.d.ts
CHANGED
|
@@ -47,4 +47,5 @@ export declare const preventDefault: <T extends Event>(e: T) => void;
|
|
|
47
47
|
export declare const loadImage: (img: HTMLImageElement, src: string) => Promise<HTMLImageElement>;
|
|
48
48
|
export declare const pushState: (path: string, query?: RecordOf<string>, data?: any) => void;
|
|
49
49
|
export declare const qs: (search?: string) => Maybe<RecordOf<string>>;
|
|
50
|
+
export declare const imageData: (img: HTMLImageElement) => ImageData;
|
|
50
51
|
export {};
|
package/dom.js
CHANGED
|
@@ -34,3 +34,8 @@ export const pushState = (path, query, data) => history.pushState(data, EMPTY.ST
|
|
|
34
34
|
export const qs = (search = location.search) => search.length > 0
|
|
35
35
|
? Object.fromEntries(new URLSearchParams(search).entries())
|
|
36
36
|
: undefined;
|
|
37
|
+
export const imageData = (img) => {
|
|
38
|
+
const ctx = new OffscreenCanvas(img.width, img.height).getContext("2d");
|
|
39
|
+
ctx.drawImage(img, 0, 0);
|
|
40
|
+
return ctx.getImageData(0, 0, img.width, img.height);
|
|
41
|
+
};
|
package/fn.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import type { Fn, FnV, FnF, Pred, TPred, FirstParam, Last,
|
|
1
|
+
import type { Fn, FnV, FnF, Pred, TPred, FirstParam, Last, Lazy, Maybe, Dispose, Reactive } from "./types.js";
|
|
2
2
|
export declare const tee: <T>(f: Fn<T, void>) => Fn<T, T>;
|
|
3
3
|
export declare const comp: <Fs extends Fn[]>(...fs: Fs) => (x: FirstParam<Fs[0]>) => Last<Fs> extends Fn<any, infer R> ? R : never;
|
|
4
4
|
export declare const pipe: <T, Fs extends [Fn<T>, ...Fn[]]>(x: T, ...fs: Fs) => Last<Fs> extends Fn<any, infer R> ? R : never;
|
|
5
5
|
export declare const forEach: <T, R = any>(...fs: Fn<T, R>[]) => (x: T) => void;
|
|
6
|
-
export declare const map: <T,
|
|
6
|
+
export declare const map: <T, S, U>(f: Fn<T, S>, g: Fn<S, U>) => Fn<T, U>;
|
|
7
7
|
export declare const and: <T>(...fs: Pred<T>[]) => (x: T) => boolean;
|
|
8
8
|
export declare const or: <T>(...fs: Pred<T>[]) => (x: T) => boolean;
|
|
9
9
|
export declare const not: <T>(p: Pred<T>) => (x: T) => boolean;
|
|
10
10
|
export declare const comb: <C extends FnV<Fn[]>>(c: C) => (...fs: Fn<FirstParam<FirstParam<C>>, ReturnType<FirstParam<C>>>[]) => (x: FirstParam<FirstParam<C>>) => ReturnType<C>;
|
|
11
11
|
export declare const noop: () => void;
|
|
12
12
|
export declare const identity: <S, T = S>(x: S) => T;
|
|
13
|
-
export declare const constantly: <T>(x: T) =>
|
|
13
|
+
export declare const constantly: <T>(x: T) => Lazy<T>;
|
|
14
14
|
export declare const apply: <F extends FnV>(f: F) => (x: Parameters<F>) => ReturnType<F>;
|
|
15
15
|
export declare const call: <T extends unknown[]>(f: Fn<T>) => (...xs: T) => ReturnType<typeof f>;
|
|
16
16
|
export declare const bind: <A extends unknown[], B extends unknown[], R>(f: (...args: [...A, ...B]) => R, ...args: A) => (...args: B) => R;
|
|
@@ -18,7 +18,6 @@ export declare const lazy: <F extends FnV>(f: F, ...xs: Parameters<F>) => Fn<voi
|
|
|
18
18
|
export declare const where: <T, U, V>(p: Pred<T>, f: Fn<T, U>, g: Fn<T, V>) => (x: T) => U | V;
|
|
19
19
|
export declare const before: <F extends Fn<void>>(f: F) => FnF;
|
|
20
20
|
export declare const after: <F extends Fn<void>>(f: F) => FnF;
|
|
21
|
-
export declare const mapForEach: <T, R>(...fs: Fn<T, Fn<R>>[]) => (x: T) => (x: R) => void;
|
|
22
21
|
export declare const filter: <T>(p: Pred<T>, f: Fn<T>) => (x: T) => void;
|
|
23
22
|
export declare const filterT: <T>(p: TPred<T>, f: Fn<T>) => <S>(x: S) => void;
|
|
24
23
|
export declare const scan: <T, S>(f: FnV<[S, T], S>, a: S) => Fn<T, S>;
|
package/fn.js
CHANGED
|
@@ -3,7 +3,7 @@ export const tee = f => x => (f(x), x);
|
|
|
3
3
|
export const comp = (...fs) => (x) => fs.reduce((x, f) => f(x), x);
|
|
4
4
|
export const pipe = (x, ...fs) => fs.reduce((x, f) => f(x), x);
|
|
5
5
|
export const forEach = (...fs) => (x) => fs.forEach(f => f(x));
|
|
6
|
-
export const map = (
|
|
6
|
+
export const map = (f, g) => comp(f, g);
|
|
7
7
|
export const and = (...fs) => (x) => fs.reduce((a, f) => a && f(x), true);
|
|
8
8
|
export const or = (...fs) => (x) => fs.reduce((a, f) => a || f(x), false);
|
|
9
9
|
export const not = (p) => (x) => !p(x);
|
|
@@ -22,7 +22,6 @@ export const after = (f) => g => (...xs) => {
|
|
|
22
22
|
f();
|
|
23
23
|
return r;
|
|
24
24
|
};
|
|
25
|
-
export const mapForEach = (...fs) => comp(map(...fs), apply((forEach)));
|
|
26
25
|
export const filter = (p, f) => (x) => { if (p(x))
|
|
27
26
|
f(x); };
|
|
28
27
|
export const filterT = (p, f) => (x) => { if (p(x))
|
package/math.d.ts
CHANGED
|
@@ -32,3 +32,4 @@ export declare const zoom: (x: number, s: number, p: number) => number;
|
|
|
32
32
|
export declare const align: (x: number, b: number) => number;
|
|
33
33
|
export declare const sign11: (x: number) => 1 | -1;
|
|
34
34
|
export declare const nudge: (x: number, v?: number, eps?: number) => number;
|
|
35
|
+
export declare const divCeil: (a: number, b: number) => number;
|
package/math.js
CHANGED
|
@@ -41,3 +41,4 @@ export const zoom = (x, s, p) => (x - p) * s + p;
|
|
|
41
41
|
export const align = (x, b) => (x + b - 1) & -b;
|
|
42
42
|
export const sign11 = (x) => x >= 0 ? 1 : -1;
|
|
43
43
|
export const nudge = (x, v = 0, eps = EPS) => isclose(x, v, eps) ? sign11(x - v) * eps + v : x;
|
|
44
|
+
export const divCeil = (a, b) => Math.ceil(a / b);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cgtk/std",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.195",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"exports": {
|
|
@@ -40,9 +40,6 @@
|
|
|
40
40
|
"./resource": "./resource.js",
|
|
41
41
|
"./utils": "./utils.js"
|
|
42
42
|
},
|
|
43
|
-
"devDependencies": {
|
|
44
|
-
"typescript": "^6.0.2"
|
|
45
|
-
},
|
|
46
43
|
"publishConfig": {
|
|
47
44
|
"access": "public"
|
|
48
45
|
}
|
package/resource.d.ts
CHANGED
|
@@ -3,8 +3,11 @@ export type Resource<T> = Reactive<T, Dispose | void> & {
|
|
|
3
3
|
value: T;
|
|
4
4
|
dispose: Dispose;
|
|
5
5
|
map<S>(f: Fn<T, S>): Resource<S>;
|
|
6
|
+
flatMap<S>(f: Fn<T, Resource<S>>): Resource<S>;
|
|
7
|
+
promise(f: Fn<T, Promise<Dispose | void>>): Promise<Dispose>;
|
|
6
8
|
};
|
|
7
9
|
export declare const resource: <T>(value: T, dispose?: Dispose) => Resource<T>;
|
|
10
|
+
export declare const awaited: <T>({ value, dispose }: Resource<Promise<T>>) => Promise<Resource<Awaited<T>>>;
|
|
8
11
|
type Unwrapped<T> = T extends Resource<infer U> ? U : {
|
|
9
12
|
[K in keyof T]: Unwrapped<T[K]>;
|
|
10
13
|
};
|
package/resource.js
CHANGED
|
@@ -5,8 +5,14 @@ export const resource = (value, dispose = noop) => {
|
|
|
5
5
|
res.value = value;
|
|
6
6
|
res.dispose = dispose;
|
|
7
7
|
res.map = (f) => resource(f(value), dispose);
|
|
8
|
+
res.flatMap = (f) => {
|
|
9
|
+
const res = f(value);
|
|
10
|
+
return resource(res.value, forEach(res.dispose, dispose));
|
|
11
|
+
};
|
|
12
|
+
res.promise = async (f) => forEach((await f(value)) ?? noop, dispose);
|
|
8
13
|
return res;
|
|
9
14
|
};
|
|
15
|
+
export const awaited = async ({ value, dispose }) => resource(await value, dispose);
|
|
10
16
|
const isResource = (r) => isFunction(r)
|
|
11
17
|
&& Object.hasOwn(r, "value")
|
|
12
18
|
&& Object.hasOwn(r, "dispose")
|
package/types.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export type Fns<T> = {
|
|
|
18
18
|
export type FnF = <F extends FnV>(f: F) => (...xs: Parameters<F>) => ReturnType<F>;
|
|
19
19
|
export type Dispose = Fn<void>;
|
|
20
20
|
export type Reactive<T = unknown, R = any> = Fn<Fn<T, R>, Dispose>;
|
|
21
|
-
export type
|
|
21
|
+
export type Lazy<T> = () => T;
|
|
22
22
|
export type FirstParam<F extends FnV> = MaybeFirst<Parameters<F>>;
|
|
23
23
|
export type MaybePromise<T = unknown> = T | PromiseLike<T>;
|
|
24
24
|
export type Last<T extends any[]> = T extends [...any, infer Rest] ? Rest : never;
|
|
@@ -39,7 +39,7 @@ export type Entries<T> = {
|
|
|
39
39
|
export type EntriesTuple<T, K extends UnionToTuple<keyof T> = UnionToTuple<keyof T>> = {
|
|
40
40
|
[I in keyof K]: K[I] extends keyof T ? [K[I], T[K[I]]] : never;
|
|
41
41
|
};
|
|
42
|
-
export type UintArray<T extends ArrayBufferLike = ArrayBufferLike> = Uint8Array<T> | Uint16Array<T> | Uint32Array<T>;
|
|
42
|
+
export type UintArray<T extends ArrayBufferLike = ArrayBufferLike> = Uint8Array<T> | Uint8ClampedArray<T> | Uint16Array<T> | Uint32Array<T>;
|
|
43
43
|
export type IntArray<T extends ArrayBufferLike = ArrayBufferLike> = Int8Array<T> | Int16Array<T> | Int32Array<T>;
|
|
44
44
|
export type FloatArray<T extends ArrayBufferLike = ArrayBufferLike> = Float16Array<T> | Float32Array<T> | Float64Array<T>;
|
|
45
45
|
export type BigIntArray<T extends ArrayBufferLike = ArrayBufferLike> = BigUint64Array<T> | BigInt64Array<T>;
|
package/src/array.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { Fn, Tuple } from "./types.js";
|
|
2
|
-
export declare const empty: <T>() => T[];
|
|
3
|
-
export declare const push: <T>(xs: T[], x: T) => T[];
|
|
4
|
-
export declare const unshift: <T>(xs: T[], x: T) => T[];
|
|
5
|
-
export declare const get: (i: number) => <T>(xs: T[]) => T;
|
|
6
|
-
export declare const pop: <T>(xs: T[]) => T[];
|
|
7
|
-
export declare const shift: <T>(xs: T[]) => T[];
|
|
8
|
-
export declare const first: <T>(xs: T[]) => T;
|
|
9
|
-
export declare const cap: <T>(n: number, f: Fn<T[]>) => Fn<T[], T[]>;
|
|
10
|
-
export declare const retain: <T>(n: number, xs?: T[]) => (x: T) => T[];
|
|
11
|
-
export declare const tuple: <T, N extends number>(...xs: T[] & {
|
|
12
|
-
length: N;
|
|
13
|
-
}) => Tuple<T, N>;
|
|
14
|
-
export declare const seek: <T>(arr: ArrayLike<T>, vals: Set<T | number>, offset?: number) => number;
|
package/src/array.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { comp, scan } from "./fn.js";
|
|
2
|
-
export const empty = () => [];
|
|
3
|
-
export const push = (xs, x) => (xs.push(x), xs);
|
|
4
|
-
export const unshift = (xs, x) => (xs.unshift(x), xs);
|
|
5
|
-
export const get = (i) => (xs) => xs[i];
|
|
6
|
-
export const pop = (xs) => (xs.pop(), xs);
|
|
7
|
-
export const shift = (xs) => (xs.shift(), xs);
|
|
8
|
-
export const first = (xs) => xs[0];
|
|
9
|
-
export const cap = (n, f) => xs => {
|
|
10
|
-
while (xs.length > n)
|
|
11
|
-
f(xs);
|
|
12
|
-
return xs;
|
|
13
|
-
};
|
|
14
|
-
export const retain = (n, xs = []) => comp(scan((push), xs), cap(n, shift));
|
|
15
|
-
export const tuple = (...xs) => xs;
|
|
16
|
-
export const seek = (arr, vals, offset = 0) => {
|
|
17
|
-
for (let i = offset, n = arr.length; i < n; i++)
|
|
18
|
-
if (vals.has(arr[i]))
|
|
19
|
-
return i;
|
|
20
|
-
return -1;
|
|
21
|
-
};
|
package/src/assign.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { RecordOf } from "./types.js";
|
|
2
|
-
type PO = RecordOf<unknown>;
|
|
3
|
-
type Merge<T extends PO, S extends PO> = {
|
|
4
|
-
[K in keyof (T & S)]: K extends keyof S ? (K extends keyof T ? (S[K] extends PO ? (T[K] extends PO ? Merge<T[K], S[K]> : S[K]) : S[K]) : S[K]) : (K extends keyof T ? T[K] : never);
|
|
5
|
-
};
|
|
6
|
-
type Assign<T extends PO, Ts extends PO[]> = Ts extends [infer A extends PO, ...infer R extends PO[]] ? Assign<Merge<T, A>, R> : T;
|
|
7
|
-
export declare const assign: <T extends PO, Ts extends PO[]>(target: T, ...sources: Ts) => Assign<T, Ts>;
|
|
8
|
-
export {};
|
package/src/assign.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { isUndefined, isNull } from "./checks.js";
|
|
2
|
-
const isPrimitive = (x) => {
|
|
3
|
-
const t = typeof x;
|
|
4
|
-
return t === "string" || t === "number" || t === "boolean";
|
|
5
|
-
};
|
|
6
|
-
function isPlainObject(x) {
|
|
7
|
-
if (typeof x !== 'object')
|
|
8
|
-
return false;
|
|
9
|
-
const prototype = Object.getPrototypeOf(x);
|
|
10
|
-
return !!prototype && prototype.constructor === Object && prototype === Object.prototype;
|
|
11
|
-
}
|
|
12
|
-
const canClone = (x) => isPrimitive(x) || isPlainObject(x) &&
|
|
13
|
-
Object.values(x).every(x => isUndefined(x) || isNull(x) || isPrimitive(x) || canClone(x));
|
|
14
|
-
const merge = (target, source) => {
|
|
15
|
-
Object.keys(source).forEach(key => {
|
|
16
|
-
const s = source[key], t = target[key];
|
|
17
|
-
if (isPlainObject(t) && isPlainObject(s))
|
|
18
|
-
target[key] = merge(t, s);
|
|
19
|
-
else if (canClone(s))
|
|
20
|
-
target[key] = structuredClone(s);
|
|
21
|
-
else
|
|
22
|
-
target[key] = s;
|
|
23
|
-
});
|
|
24
|
-
return target;
|
|
25
|
-
};
|
|
26
|
-
export const assign = (target, ...sources) => sources.reduce(merge, target);
|
package/src/async.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { Fn, Constantly, Maybe, Dispose, MaybePromise } from "./types.js";
|
|
2
|
-
export declare const timeout: (ms: number, signal?: AbortSignal) => Promise<unknown>;
|
|
3
|
-
export declare const delay: (ms: number, signal?: AbortSignal) => <T>(x: T) => Promise<T>;
|
|
4
|
-
export declare const probing: <T>(p: Promise<T>) => Constantly<Maybe<T>>;
|
|
5
|
-
export declare const resolved: <T>(p: Promise<T>) => (f: Fn<T>) => () => void;
|
|
6
|
-
export declare const promise: <T>(x: MaybePromise<T>) => Promise<any>;
|
|
7
|
-
export declare const then: <T>(p: Promise<T>) => <R>(f: Fn<T, R>) => Promise<R>;
|
|
8
|
-
export declare const dispose: (p: Promise<Dispose>) => Dispose;
|
package/src/async.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { filterT, disposable } from "./fn.js";
|
|
2
|
-
import { isDefined } from "./checks.js";
|
|
3
|
-
export const timeout = (ms, signal) => new Promise((resolve, reject) => {
|
|
4
|
-
if (signal?.aborted)
|
|
5
|
-
reject(signal.reason);
|
|
6
|
-
else {
|
|
7
|
-
const t = setTimeout(() => {
|
|
8
|
-
if (signal?.aborted)
|
|
9
|
-
reject(signal.reason);
|
|
10
|
-
else
|
|
11
|
-
resolve(undefined);
|
|
12
|
-
}, ms);
|
|
13
|
-
signal?.addEventListener("abort", () => (clearTimeout(t), reject(signal.reason)), { once: true });
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
export const delay = (ms, signal) => async (x) => (await timeout(ms, signal), x);
|
|
17
|
-
export const probing = (p) => {
|
|
18
|
-
let value = undefined;
|
|
19
|
-
p.then(x => value = x);
|
|
20
|
-
return () => value;
|
|
21
|
-
};
|
|
22
|
-
export const resolved = (p) => {
|
|
23
|
-
const val = probing(p);
|
|
24
|
-
return (f) => {
|
|
25
|
-
const g = (filterT((isDefined), f));
|
|
26
|
-
return () => g(val());
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
export const promise = (x) => (x instanceof Promise) ? x : Promise.resolve(x);
|
|
30
|
-
export const then = (p) => (f) => p.then(f);
|
|
31
|
-
export const dispose = (p) => disposable(async (dispose) => dispose(await p));
|
package/src/base64.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const decodeBytes: (str: string) => Uint8Array<ArrayBuffer>;
|
package/src/base64.js
DELETED
package/src/basen.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export type Base<N extends number> = [n: N, m: number, d: number];
|
|
2
|
-
export declare const basen: <B extends number>(b: B) => (m?: number, n?: number) => Base<B>;
|
|
3
|
-
export declare const base10: (m?: number, n?: number) => Base<10>;
|
|
4
|
-
export declare const normalize: <B extends number>(x: Base<B>) => Base<B>;
|
|
5
|
-
export declare const add: <B extends number>([b, m0, n0]: Base<B>, [_, m1, n1]: Base<B>) => Base<B>;
|
|
6
|
-
export declare const mul: <B extends number>([b, m0, n0]: Base<B>, [_, m1, n1]: Base<B>) => Base<B>;
|
|
7
|
-
export declare const addN: <B extends number>(x: Base<B>, a: number) => Base<B>;
|
|
8
|
-
export declare const mulN: <B extends number>(x: Base<B>, a: number) => Base<B>;
|
|
9
|
-
export declare const change: <B extends number, D extends number>([b, m, n]: Base<B>, d: D) => Base<D>;
|
|
10
|
-
export declare const toNumber: <B extends number>([b, m, n]: Base<B>) => number;
|
|
11
|
-
export declare const toString: <B extends number>([b, m, n]: Base<B>, d?: number) => string;
|
|
12
|
-
export declare const toExponential: ([_, m, n]: Base<10>, digits?: number, dMax?: number) => string;
|
package/src/basen.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { toFixedMax } from "./number.js";
|
|
2
|
-
export const basen = (b) => (m = 0, n = 0) => [b, m, n];
|
|
3
|
-
export const base10 = basen(10);
|
|
4
|
-
export const normalize = (x) => {
|
|
5
|
-
if (!Number.isInteger(x[2])) {
|
|
6
|
-
const n = Math.floor(x[2]);
|
|
7
|
-
x[1] *= x[0] ** (x[2] - n);
|
|
8
|
-
x[2] = n;
|
|
9
|
-
}
|
|
10
|
-
const d = x[1] != 0 ? Math.floor(Math.log(Math.abs(x[1])) / Math.log(x[0])) : 0;
|
|
11
|
-
x[1] /= x[0] ** d;
|
|
12
|
-
x[2] += d;
|
|
13
|
-
return x;
|
|
14
|
-
};
|
|
15
|
-
export const add = ([b, m0, n0], [_, m1, n1]) => {
|
|
16
|
-
const n = Math.max(n0, n1);
|
|
17
|
-
const m = m0 * b ** (n0 - n) + m1 * b ** (n1 - n);
|
|
18
|
-
return [b, m, n];
|
|
19
|
-
};
|
|
20
|
-
export const mul = ([b, m0, n0], [_, m1, n1]) => [b, m0 * m1, n0 + n1];
|
|
21
|
-
export const addN = (x, a) => (x[1] += a, normalize(x));
|
|
22
|
-
export const mulN = (x, a) => (x[1] *= a, normalize(x));
|
|
23
|
-
export const change = ([b, m, n], d) => {
|
|
24
|
-
const k = n * Math.log(b) / Math.log(d);
|
|
25
|
-
return basen(d)(m, k);
|
|
26
|
-
};
|
|
27
|
-
export const toNumber = ([b, m, n]) => m * b ** n;
|
|
28
|
-
export const toString = ([b, m, n], d = 2) => `${m.toFixed(d)}x${b}^${n}`;
|
|
29
|
-
export const toExponential = ([_, m, n], digits = 2, dMax = 2) => Math.abs(n) <= dMax
|
|
30
|
-
? toFixedMax(m * 10 ** n, digits)
|
|
31
|
-
: `${toFixedMax(m, digits)}e${n.toFixed(0)}`;
|
package/src/buffer.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { Fn } from "./types.js";
|
|
2
|
-
export interface BufReader {
|
|
3
|
-
offset: number;
|
|
4
|
-
line: Fn<void, string>;
|
|
5
|
-
u8: Fn<void, number>;
|
|
6
|
-
u16: Fn<boolean, number>;
|
|
7
|
-
u32: Fn<boolean, number>;
|
|
8
|
-
i8: Fn<void, number>;
|
|
9
|
-
i16: Fn<boolean, number>;
|
|
10
|
-
i32: Fn<boolean, number>;
|
|
11
|
-
f32: Fn<boolean, number>;
|
|
12
|
-
f64: Fn<boolean, number>;
|
|
13
|
-
}
|
|
14
|
-
export declare const bufReader: (data: Uint8Array, offset?: number) => BufReader;
|
package/src/buffer.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { readLine } from './string.js';
|
|
2
|
-
export const bufReader = (data, offset = 0) => {
|
|
3
|
-
const rl = readLine();
|
|
4
|
-
const dv = new DataView(data.buffer, data.byteOffset);
|
|
5
|
-
return {
|
|
6
|
-
get offset() { return offset; },
|
|
7
|
-
set offset(x) { offset = x; },
|
|
8
|
-
line() {
|
|
9
|
-
const line = rl(data, offset);
|
|
10
|
-
offset += line.length;
|
|
11
|
-
return line;
|
|
12
|
-
},
|
|
13
|
-
u8() {
|
|
14
|
-
const x = dv.getUint8(offset);
|
|
15
|
-
offset += 1;
|
|
16
|
-
return x;
|
|
17
|
-
},
|
|
18
|
-
u16(littleEndian = true) {
|
|
19
|
-
const x = dv.getUint16(offset, littleEndian);
|
|
20
|
-
offset += 2;
|
|
21
|
-
return x;
|
|
22
|
-
},
|
|
23
|
-
u32(littleEndian = true) {
|
|
24
|
-
const x = dv.getUint16(offset, littleEndian);
|
|
25
|
-
offset += 4;
|
|
26
|
-
return x;
|
|
27
|
-
},
|
|
28
|
-
i8() {
|
|
29
|
-
const x = dv.getInt8(offset);
|
|
30
|
-
offset += 1;
|
|
31
|
-
return x;
|
|
32
|
-
},
|
|
33
|
-
i16(littleEndian = true) {
|
|
34
|
-
const x = dv.getInt16(offset, littleEndian);
|
|
35
|
-
offset += 2;
|
|
36
|
-
return x;
|
|
37
|
-
},
|
|
38
|
-
i32(littleEndian = true) {
|
|
39
|
-
const x = dv.getInt32(offset, littleEndian);
|
|
40
|
-
offset += 4;
|
|
41
|
-
return x;
|
|
42
|
-
},
|
|
43
|
-
f32(littleEndian = true) {
|
|
44
|
-
const x = dv.getFloat32(offset, littleEndian);
|
|
45
|
-
offset += 4;
|
|
46
|
-
return x;
|
|
47
|
-
},
|
|
48
|
-
f64(littleEndian = true) {
|
|
49
|
-
const x = dv.getFloat64(offset, littleEndian);
|
|
50
|
-
offset += 8;
|
|
51
|
-
return x;
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
};
|
package/src/checks.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { TypedArray, NumberArray, BigIntArray, Pred, TPred, Maybe } from "./types.js";
|
|
2
|
-
export declare const isTypedArray: (x: any) => x is TypedArray;
|
|
3
|
-
export declare const isNumberArray: (x: any) => x is NumberArray;
|
|
4
|
-
export declare const isBigIntArray: (x: any) => x is BigIntArray;
|
|
5
|
-
export declare const isUndefined: (x: any) => x is undefined;
|
|
6
|
-
export declare const isNull: (x: any) => x is null;
|
|
7
|
-
export declare const isDefined: <T>(x: Maybe<T>) => x is T;
|
|
8
|
-
export declare function assert(condition: boolean, msg: string): asserts condition;
|
|
9
|
-
export declare function assertType<T>(x: any, pred: TPred<T>, msg: string): asserts x is T;
|
|
10
|
-
export declare const isObject: TPred<Object>;
|
|
11
|
-
export declare const isString: TPred<string>;
|
|
12
|
-
export declare const isNumber: TPred<number>;
|
|
13
|
-
export declare const isBigInt: TPred<bigint>;
|
|
14
|
-
export declare const isPositive: Pred<number>;
|
|
15
|
-
export declare const isTs: <T>(p: TPred<T>) => TPred<T[]>;
|
|
16
|
-
export declare const isclose: (a: number, b: number, eps?: number) => boolean;
|
|
17
|
-
export declare const allclose: (a: Array<number> | NumberArray, b: Array<number> | NumberArray, eps?: number) => boolean;
|
|
18
|
-
export declare const equal: <T>(a: T, b?: T) => boolean;
|
|
19
|
-
export declare const strictEqual: <T>(a: T, b?: T) => boolean;
|
|
20
|
-
export declare const isDiffPrev: <T>(eq?: (a: T, b?: T | undefined) => boolean) => Pred<T>;
|
|
21
|
-
export declare const isLonger: <T>(delta: number) => Pred<T>;
|
|
22
|
-
export declare const isFunction: <T extends Function>(x: any) => x is T;
|
|
23
|
-
export declare const isAborted: (signal: AbortSignal) => () => boolean;
|
|
24
|
-
export declare const isArrayBufferLike: (x: any) => x is ArrayBufferLike;
|
|
25
|
-
export declare const isArrayBufferView: (x: any) => x is ArrayBufferView;
|
|
26
|
-
export declare const isEmpty: (x: {
|
|
27
|
-
length: number;
|
|
28
|
-
}) => boolean;
|
|
29
|
-
export declare const counted: (n: number) => () => boolean;
|
package/src/checks.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { comp, not, apply, and } from "./fn.js";
|
|
2
|
-
import { retain } from "./array.js";
|
|
3
|
-
export const isTypedArray = (x) => x && (x instanceof Uint8Array || x instanceof Uint8ClampedArray ||
|
|
4
|
-
x instanceof Uint16Array || x instanceof Uint32Array ||
|
|
5
|
-
x instanceof Int8Array || x instanceof Int16Array || x instanceof Int32Array ||
|
|
6
|
-
x instanceof Float16Array || x instanceof Float32Array || x instanceof Float64Array ||
|
|
7
|
-
x instanceof BigUint64Array || x instanceof BigInt64Array);
|
|
8
|
-
export const isNumberArray = (x) => x && (x instanceof Uint8Array || x instanceof Uint8ClampedArray ||
|
|
9
|
-
x instanceof Uint16Array || x instanceof Uint32Array ||
|
|
10
|
-
x instanceof Int8Array || x instanceof Int16Array || x instanceof Int32Array ||
|
|
11
|
-
x instanceof Float16Array || x instanceof Float32Array || x instanceof Float64Array);
|
|
12
|
-
export const isBigIntArray = (x) => x && (x instanceof BigUint64Array || x instanceof BigInt64Array);
|
|
13
|
-
export const isUndefined = (x) => x === undefined;
|
|
14
|
-
export const isNull = (x) => x === null;
|
|
15
|
-
export const isDefined = (x) => !isUndefined(x);
|
|
16
|
-
export function assert(condition, msg) {
|
|
17
|
-
if (!condition)
|
|
18
|
-
throw new Error(msg);
|
|
19
|
-
}
|
|
20
|
-
export function assertType(x, pred, msg) { assert(pred(x), msg); }
|
|
21
|
-
export const isObject = (x) => x !== null && typeof x === "object";
|
|
22
|
-
export const isString = (x) => typeof x === "string";
|
|
23
|
-
export const isNumber = (x) => typeof x === 'number';
|
|
24
|
-
export const isBigInt = (x) => typeof x === "bigint";
|
|
25
|
-
export const isPositive = (x) => x > 0;
|
|
26
|
-
export const isTs = (p) => and(Array.isArray, (xs) => xs.every(p));
|
|
27
|
-
export const isclose = (a, b, eps = Number.EPSILON) => Math.abs(a - b) < eps;
|
|
28
|
-
export const allclose = (a, b, eps) => a.length == b.length && a.every((x, i) => isclose(x, b[i], eps));
|
|
29
|
-
export const equal = (a, b) => a == b;
|
|
30
|
-
export const strictEqual = (a, b) => a === b;
|
|
31
|
-
export const isDiffPrev = (eq = (strictEqual)) => comp(retain(2), not(apply(eq)));
|
|
32
|
-
export const isLonger = (delta) => comp((x) => [performance.now(), x], retain(2), (xs) => xs.length < 2 || xs[1][0] - xs[0][0] > delta);
|
|
33
|
-
export const isFunction = (x) => typeof x === "function";
|
|
34
|
-
export const isAborted = (signal) => () => signal.aborted;
|
|
35
|
-
export const isArrayBufferLike = (x) => x instanceof ArrayBuffer || x instanceof SharedArrayBuffer;
|
|
36
|
-
export const isArrayBufferView = (x) => x != null &&
|
|
37
|
-
isArrayBufferLike(x.buffer) &&
|
|
38
|
-
isNumber(x.byteOffset) &&
|
|
39
|
-
isNumber(x.byteLength);
|
|
40
|
-
export const isEmpty = (x) => x.length == 0;
|
|
41
|
-
export const counted = (n) => {
|
|
42
|
-
let m = 0;
|
|
43
|
-
return () => m++ < n;
|
|
44
|
-
};
|
package/src/constants.d.ts
DELETED
package/src/constants.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const EMPTY = Object.freeze({ OBJ: {}, STR: "", LIST: [] });
|
package/src/dom.d.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import type { Fn, Dispose, RecordOf, Maybe } from "./types.js";
|
|
2
|
-
export declare const customEvent: <T>(type: string, detail: T, { composed, bubbles, cancelable }?: EventInit) => CustomEvent<T>;
|
|
3
|
-
type ListenOpts = boolean | AddEventListenerOptions;
|
|
4
|
-
export declare const on: {
|
|
5
|
-
<T extends HTMLElement, K extends keyof HTMLElementEventMap>(el: T, name: K, listener: Fn<HTMLElementEventMap[K]>, opts?: ListenOpts): Dispose;
|
|
6
|
-
<T extends SVGGraphicsElement, K extends keyof SVGElementEventMap>(el: T, name: K, listener: Fn<SVGElementEventMap[K]>, opts?: ListenOpts): Dispose;
|
|
7
|
-
<T, K extends keyof MessageEventTargetEventMap>(el: MessageEventTarget<T>, name: K, listener: Fn<MessageEventTargetEventMap[K]>, opts?: ListenOpts): Dispose;
|
|
8
|
-
<K extends keyof DocumentEventMap>(el: Document, name: K, listener: Fn<DocumentEventMap[K]>, opts?: ListenOpts): Dispose;
|
|
9
|
-
<K extends keyof WindowEventMap>(el: Window, name: K, listener: Fn<WindowEventMap[K]>, opts?: ListenOpts): Dispose;
|
|
10
|
-
<K extends keyof WorkerEventMap>(el: Worker, name: K, listener: Fn<WorkerEventMap[K]>, opts?: ListenOpts): Dispose;
|
|
11
|
-
<K extends keyof AbortSignalEventMap>(el: AbortSignal, name: K, listener: Fn<AbortSignalEventMap[K]>, opts?: ListenOpts): Dispose;
|
|
12
|
-
};
|
|
13
|
-
export declare const onAll: {
|
|
14
|
-
<T extends keyof HTMLElementEventMap>(el: HTMLElement, listeners: {
|
|
15
|
-
[k in T]: Fn<HTMLElementEventMap[k]>;
|
|
16
|
-
}, opts?: ListenOpts): Dispose;
|
|
17
|
-
<T extends keyof SVGElementEventMap>(el: SVGGraphicsElement, listeners: {
|
|
18
|
-
[k in T]: Fn<SVGElementEventMap[k]>;
|
|
19
|
-
}, opts?: ListenOpts): Dispose;
|
|
20
|
-
<T, K extends keyof MessageEventTargetEventMap>(el: MessageEventTarget<T>, listeners: {
|
|
21
|
-
[k in K]: Fn<MessageEventTargetEventMap[k]>;
|
|
22
|
-
}, opts?: ListenOpts): Dispose;
|
|
23
|
-
<T extends keyof DocumentEventMap>(el: Document, listeners: {
|
|
24
|
-
[k in T]: Fn<DocumentEventMap[k]>;
|
|
25
|
-
}, opts?: ListenOpts): Dispose;
|
|
26
|
-
<T extends keyof WindowEventMap>(el: Window, listeners: {
|
|
27
|
-
[k in T]: Fn<WindowEventMap[k]>;
|
|
28
|
-
}, opts?: ListenOpts): Dispose;
|
|
29
|
-
<T extends keyof WorkerEventMap>(el: Worker, listeners: {
|
|
30
|
-
[k in T]: Fn<WorkerEventMap[k]>;
|
|
31
|
-
}, opts?: ListenOpts): Dispose;
|
|
32
|
-
<T extends keyof AbortSignalEventMap>(el: AbortSignal, listeners: {
|
|
33
|
-
[k in T]: Fn<AbortSignalEventMap[k]>;
|
|
34
|
-
}, opts?: ListenOpts): Dispose;
|
|
35
|
-
};
|
|
36
|
-
type DragHandlers = Record<'down' | 'move' | 'up', Fn<PointerEvent>>;
|
|
37
|
-
export declare const onDrag: {
|
|
38
|
-
(el: HTMLElement, fns: Partial<DragHandlers>): Dispose;
|
|
39
|
-
(el: SVGGraphicsElement, fns: Partial<DragHandlers>): Dispose;
|
|
40
|
-
};
|
|
41
|
-
export declare const onDragMove: {
|
|
42
|
-
(el: HTMLElement, f: Fn<PointerEvent>): Dispose;
|
|
43
|
-
(el: SVGGraphicsElement, f: Fn<PointerEvent>): Dispose;
|
|
44
|
-
};
|
|
45
|
-
export declare const onResize: (el: Element, f: Fn<ResizeObserverEntry[]>, options?: ResizeObserverOptions) => Dispose;
|
|
46
|
-
export declare const preventDefault: <T extends Event>(e: T) => void;
|
|
47
|
-
export declare const loadImage: (img: HTMLImageElement, src: string) => Promise<HTMLImageElement>;
|
|
48
|
-
export declare const pushState: (path: string, query?: RecordOf<string>, data?: any) => void;
|
|
49
|
-
export declare const qs: (search?: string) => Maybe<RecordOf<string>>;
|
|
50
|
-
export {};
|
package/src/dom.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { forEach, noop } from "./fn.js";
|
|
2
|
-
import { isDefined } from "./checks.js";
|
|
3
|
-
import { EMPTY } from "./constants.js";
|
|
4
|
-
export const customEvent = (type, detail, { composed = false, bubbles = false, cancelable = false } = EMPTY.OBJ) => new CustomEvent(type, { bubbles, cancelable, composed, detail });
|
|
5
|
-
export const on = (el, name, listener, opts = false) => {
|
|
6
|
-
el.addEventListener(name, listener, opts);
|
|
7
|
-
return () => el.removeEventListener(name, listener, opts);
|
|
8
|
-
};
|
|
9
|
-
export const onAll = (el, fs, opts) => forEach(...Object.keys(fs).map(k => on(el, k, fs[k], opts)));
|
|
10
|
-
export const onDrag = (el, { down = noop, move = noop, up = noop }) => on(el, 'pointerdown', e => {
|
|
11
|
-
const pointerId = e.pointerId;
|
|
12
|
-
el.setPointerCapture(pointerId);
|
|
13
|
-
down(e);
|
|
14
|
-
const offMove = on(el, 'pointermove', move);
|
|
15
|
-
const offUp = on(el, 'pointerup', e => {
|
|
16
|
-
up(e);
|
|
17
|
-
el.releasePointerCapture(pointerId);
|
|
18
|
-
offMove();
|
|
19
|
-
offUp();
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
export const onDragMove = (el, move) => onDrag(el, { move });
|
|
23
|
-
export const onResize = (el, f, options) => {
|
|
24
|
-
const ro = new ResizeObserver(f);
|
|
25
|
-
ro.observe(el, options);
|
|
26
|
-
return () => ro.disconnect();
|
|
27
|
-
};
|
|
28
|
-
export const preventDefault = (e) => e.preventDefault();
|
|
29
|
-
export const loadImage = (img, src) => new Promise((resolve) => {
|
|
30
|
-
const off = on(img, "load", () => (off(), resolve(img)));
|
|
31
|
-
img.src = src;
|
|
32
|
-
});
|
|
33
|
-
export const pushState = (path, query, data) => history.pushState(data, EMPTY.STR, isDefined(query) ? `${path}?${new URLSearchParams(query).toString()}` : path);
|
|
34
|
-
export const qs = (search = location.search) => search.length > 0
|
|
35
|
-
? Object.fromEntries(new URLSearchParams(search).entries())
|
|
36
|
-
: undefined;
|
package/src/fn.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { Fn, FnV, FnF, Pred, TPred, FirstParam, Last, Constantly, Maybe, Dispose, Reactive } from "./types.js";
|
|
2
|
-
export declare const tee: <T>(f: Fn<T, void>) => Fn<T, T>;
|
|
3
|
-
export declare const comp: <Fs extends Fn[]>(...fs: Fs) => (x: FirstParam<Fs[0]>) => Last<Fs> extends Fn<any, infer R> ? R : never;
|
|
4
|
-
export declare const pipe: <T, Fs extends [Fn<T>, ...Fn[]]>(x: T, ...fs: Fs) => Last<Fs> extends Fn<any, infer R> ? R : never;
|
|
5
|
-
export declare const forEach: <T, R = any>(...fs: Fn<T, R>[]) => (x: T) => void;
|
|
6
|
-
export declare const map: <T, R>(...fs: Fn<T, R>[]) => (x: T) => R[];
|
|
7
|
-
export declare const and: <T>(...fs: Pred<T>[]) => (x: T) => boolean;
|
|
8
|
-
export declare const or: <T>(...fs: Pred<T>[]) => (x: T) => boolean;
|
|
9
|
-
export declare const not: <T>(p: Pred<T>) => (x: T) => boolean;
|
|
10
|
-
export declare const comb: <C extends FnV<Fn[]>>(c: C) => (...fs: Fn<FirstParam<FirstParam<C>>, ReturnType<FirstParam<C>>>[]) => (x: FirstParam<FirstParam<C>>) => ReturnType<C>;
|
|
11
|
-
export declare const noop: () => void;
|
|
12
|
-
export declare const identity: <S, T = S>(x: S) => T;
|
|
13
|
-
export declare const constantly: <T>(x: T) => Constantly<T>;
|
|
14
|
-
export declare const apply: <F extends FnV>(f: F) => (x: Parameters<F>) => ReturnType<F>;
|
|
15
|
-
export declare const call: <T extends unknown[]>(f: Fn<T>) => (...xs: T) => ReturnType<typeof f>;
|
|
16
|
-
export declare const bind: <A extends unknown[], B extends unknown[], R>(f: (...args: [...A, ...B]) => R, ...args: A) => (...args: B) => R;
|
|
17
|
-
export declare const lazy: <F extends FnV>(f: F, ...xs: Parameters<F>) => Fn<void, ReturnType<F>>;
|
|
18
|
-
export declare const where: <T, U, V>(p: Pred<T>, f: Fn<T, U>, g: Fn<T, V>) => (x: T) => U | V;
|
|
19
|
-
export declare const before: <F extends Fn<void>>(f: F) => FnF;
|
|
20
|
-
export declare const after: <F extends Fn<void>>(f: F) => FnF;
|
|
21
|
-
export declare const mapForEach: <T, R>(...fs: Fn<T, Fn<R>>[]) => (x: T) => (x: R) => void;
|
|
22
|
-
export declare const filter: <T>(p: Pred<T>, f: Fn<T>) => (x: T) => void;
|
|
23
|
-
export declare const filterT: <T>(p: TPred<T>, f: Fn<T>) => <S>(x: S) => void;
|
|
24
|
-
export declare const scan: <T, S>(f: FnV<[S, T], S>, a: S) => Fn<T, S>;
|
|
25
|
-
export declare const memoize: <T extends any[], K, V>(f: FnV<T, V>, key?: FnV<T, K>, cache?: Map<K, V>) => (...xs: T) => NonNullable<V>;
|
|
26
|
-
export declare const abortable: <T = any>(f: Fn<AbortSignal>) => (reason?: T) => void;
|
|
27
|
-
export declare const disposable: (f: Fn<Fn<Dispose, Dispose>>, disposes?: Set<Dispose>) => Dispose;
|
|
28
|
-
export declare const disposing: () => <F extends FnV<any[], Maybe<Dispose>>>(f: F) => FnV<Parameters<F>, Dispose>;
|
|
29
|
-
export declare const disposeWith: <T>(f: Fn<T, Dispose>) => (g: Fn<Fn<T>>) => Dispose;
|
|
30
|
-
export declare const idemp: <F extends FnV<any[], Dispose | void>>(d: Fn<Dispose, Dispose>, f: F) => FnV<Parameters<F>, Dispose>;
|
|
31
|
-
export declare const toggler: (f: Fn<void, Dispose>) => (x: boolean) => Dispose;
|
|
32
|
-
export declare const voidify: <F extends FnV>(f: F) => (...xs: Parameters<F>) => void;
|
|
33
|
-
export declare const effectual: <T>(f: Reactive<T>, g: Fn<T>) => Dispose;
|