@the-w1zard/dx 1.0.13 → 1.0.14

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.
@@ -0,0 +1,51 @@
1
+ export declare class I2I<T = A> implements I2<T> {
2
+ private source;
3
+ private index;
4
+ private buffer;
5
+ private done;
6
+ constructor(source: Iterable<T> | Iterator<T>);
7
+ n: () => IteratorResult<T>;
8
+ r: (value?: A) => IteratorResult<T>;
9
+ f: (error?: A) => IteratorResult<T>;
10
+ next(): IteratorResult<T>;
11
+ return(value?: A): IteratorResult<T>;
12
+ throw(error?: A): IteratorResult<T>;
13
+ [Symbol.iterator](): this;
14
+ toArray(): AR<T>;
15
+ first(): T | UD;
16
+ last(): T | UD;
17
+ at(index: N): T | UD;
18
+ peek(): T | UD;
19
+ nextValue(): T | UD;
20
+ nextOr(value: T): T;
21
+ nextOrM(make: () => T): T;
22
+ nextOrThrow(error?: Error): T;
23
+ map<G>(fn: (value: T, index: N) => G): I2I<G>;
24
+ filter<S extends T>(pred: (value: T, index: N) => value is S): I2I<S>;
25
+ filter(pred: (value: T, index: N) => B): I2I<T>;
26
+ flatMap<G>(fn: (value: T, index: N) => Iterable<G> | Iterator<G>): I2I<G>;
27
+ flat<G>(this: I2I<Iterable<G> | Iterator<G>>): I2I<G>;
28
+ take(limit: N): I2I<T>;
29
+ drop(limit: N): I2I<T>;
30
+ unique<G = T>(fn?: (value: T, index: N) => G): I2I<T>;
31
+ chunk<G>(size: N): I2I<AR<T>>;
32
+ zip<G>(other: Iterable<G> | Iterator<G>): I2I<[T, G]>;
33
+ concat(...others: (Iterable<T> | Iterator<T>)[]): I2I<T>;
34
+ enumerate<G>(): I2I<[N, T]>;
35
+ find(pred: (value: T, index: N) => B): T | UD;
36
+ findIndex(pred: (value: T, index: N) => B): N;
37
+ some(pred: (value: T, index: N) => B): B;
38
+ every(pred: (value: T, index: N) => B): B;
39
+ reduce<G>(fn: (acc: G, value: T, index: N) => G, initial: G): G;
40
+ forEach(fn: (value: T, index: N) => void): void;
41
+ count(): N;
42
+ sum(fn?: (value: T) => N): N;
43
+ join(separator?: S): S;
44
+ partition(pred: (value: T, index: N) => B): [AR<T>, AR<T>];
45
+ group<G>(fn: (value: T, index: N) => G): Map<G, AR<T>>;
46
+ toSet(): Set<T>;
47
+ toMap<K, V = T>(keyFn: (value: T, index: N) => K, valueFn?: (value: T, index: N) => V): Map<K, V>;
48
+ isEmpty(): B;
49
+ exhaust(): void;
50
+ clone(): I2I<T>;
51
+ }
package/dist/map.d.ts ADDED
@@ -0,0 +1,69 @@
1
+ export declare const rv: <T>(v: UF<T>) => T;
2
+ export declare const sameValue: (a: A, b: A) => B;
3
+ export declare class M2I<H = A, T = A> extends Map<H, T> implements M2<H, T> {
4
+ #private;
5
+ f: (callbackfn: (value: T, key: H, map: Map<H, T>) => void, thisArg?: any) => void;
6
+ [Symbol.iterator](): MapIterator<[H, T]>;
7
+ on(fn: Sub<H, T>): () => V;
8
+ off(fn: Sub<H, T>): V;
9
+ batch(fn: () => V): this;
10
+ s(v: UF<T>, k: H): this;
11
+ mutate(k: H, fn: (old: T, has: true) => T): T | UD;
12
+ d(k: H): B;
13
+ c(): V;
14
+ dv(k: H, deps: AR<H>, fn: (...vals: AR<T>) => T): this;
15
+ dirty(...keys: AR<H>): this;
16
+ g(k: H): T | UD;
17
+ h(k: H): B;
18
+ $debug(limit?: N): this;
19
+ $strict(): this;
20
+ $history(): AR<M2Event<H, T>>;
21
+ $why(k: H): M2Event<H, T> | UD;
22
+ $diff(other: M2I<H, T>): {
23
+ add: AR<[H, T]>;
24
+ del: AR<H>;
25
+ chg: AR<[H, T, T]>;
26
+ };
27
+ entries(): MapIterator<[H, T]>;
28
+ keys(): MapIterator<H>;
29
+ values(): MapIterator<T>;
30
+ swap(value: UF<T>, key: H): T | UD;
31
+ take(k: H): T | UD;
32
+ peek(k: H): T | false;
33
+ getOrI(value: UF<T>, k: H): T;
34
+ getOrM(make: () => T, k: H): T;
35
+ update(k: H, fn: (old: T, has: B) => T, initial?: UF<T>): T;
36
+ setIfAbsent(value: UF<T>, k: H): B;
37
+ setIfPresent(value: UF<T>, k: H): B;
38
+ replace(value: UF<T>, k: H): B;
39
+ inc(key: H, by?: N): N;
40
+ touch(k: H): B;
41
+ mapValues<G>(fn: (v: T, k: H) => G): M2<H, G>;
42
+ mapKeys<G>(fn: (v: T, k: H) => G): M2<G, T>;
43
+ filterKV(pred: (v: T, k: H) => B): this;
44
+ filterKeys(pred: (v: T, k: H) => B): this;
45
+ partition(pred: (v: T, k: H) => B): [M2<H, T>, M2<H, T>];
46
+ find(pred: (v: T, k: H) => B): [H, T] | UD;
47
+ findKey(pred: (v: T, k: H) => B): H | UD;
48
+ findValue(pred: (v: T, k: H) => B): T | UD;
49
+ some(pred: (v: T, k: H) => B): B;
50
+ every(pred: (v: T, k: H) => B): B;
51
+ reduce<G>(fn: (acc: G, v: T, k: H) => G, initial: G): G;
52
+ forEachKV(fn: (v: T, k: H, map: this) => void): void;
53
+ invert(): M2<T, H>;
54
+ unique<G>(fn?: (v: T, k: H) => G): M2<G, T>;
55
+ pick(keys: Iterable<H>): M2<H, T>;
56
+ omit(keys: Iterable<H>): M2<H, T>;
57
+ merge(other: Iterable<readonly [H, T]>): this;
58
+ clearAndSet(entries: Iterable<readonly [H, T]>): this;
59
+ toObject(): OB<T>;
60
+ toValues(): A2I<T>;
61
+ toKeys(): A2I<H>;
62
+ toArray(): A2I<[H, T]>;
63
+ group<G>(fn: (v: T, k: H) => G): M2<G, A2<T>>;
64
+ clone(): this;
65
+ equals(other: M2I<H, T>): B;
66
+ static fromObject<X extends Record<S, A>>(obj: X): M2I<S, X[keyof X]>;
67
+ static fromEntries<H, T>(entries: I<readonly [H, T]>): M2I<H, T>;
68
+ static from<H, T>(map: RM<H, T>): M2I<H, T>;
69
+ }
@@ -0,0 +1,34 @@
1
+ export declare class M2BINI<K = N, V = N> {
2
+ #private;
3
+ constructor(capacity?: number);
4
+ get size(): number;
5
+ get capacity(): number;
6
+ /** live backing buffer: floating-point value of slot i is buffer[i] */
7
+ get buffer(): Float64Array;
8
+ get(k: K): V | undefined;
9
+ has(k: K): boolean;
10
+ set(k: K, v: V): this;
11
+ delete(k: K): boolean;
12
+ clear(): void;
13
+ keys(): MapIterator<K>;
14
+ values(): MapIterator<V>;
15
+ entries(): MapIterator<[K, V]>;
16
+ [Symbol.iterator](): MapIterator<[K, V]>;
17
+ forEach(fn: (v: V, k: K, m: M2BINI<K, V>) => V, thisArg?: unknown): void;
18
+ /** read by pid */
19
+ g(pid: number): V | undefined;
20
+ /** write by pid */
21
+ s(v: number, pid: number): this;
22
+ /** read with fallback — the accumulator primitive */
23
+ getOr(pid: number, dflt?: number): number;
24
+ /** pid += delta, returns the new value */
25
+ add(pid: number, delta: number): number;
26
+ in(pid: number): boolean;
27
+ d(pid: number): boolean;
28
+ /** walk (pid, slot) without allocating an iterator */
29
+ forEachRaw(fn: (pid: number, slot: number) => void): void;
30
+ /** values for a list of pids, NaN where absent */
31
+ gather(pids: ArrayLike<number>, out?: Float64Array<ArrayBuffer>): Float64Array;
32
+ }
33
+ export interface M2BIN<K, V> extends M2BINI {
34
+ }
@@ -0,0 +1,91 @@
1
+ type F64 = Float64Array;
2
+ type V128 = N | F64;
3
+ export type M2BEvent = {
4
+ op: "set" | "upd" | "del" | "dirty";
5
+ pid: N;
6
+ v?: V128;
7
+ prev?: V128;
8
+ has: B;
9
+ batch?: B;
10
+ };
11
+ type Sub = (e: M2BEvent) => V;
12
+ export declare class M2BI {
13
+ #private;
14
+ readonly cap: N;
15
+ readonly stride: N;
16
+ readonly pidToSlot: I32;
17
+ readonly slotToPid: I32;
18
+ readonly vals: F64;
19
+ constructor(maxParticles?: N, stride?: N, seed?: I<readonly [N, V128]>);
20
+ get size(): N;
21
+ on(fn: Sub): () => V;
22
+ off(fn: Sub): V;
23
+ batch(fn: () => V): this;
24
+ s(v: V128, pid: N): this;
25
+ mutate(pid: N, fn: (old: V128, has: true) => V128): V128 | UD;
26
+ d(pid: N): B;
27
+ c(): V;
28
+ dv(pid: N, deps: AR<N>, fn: (...vals: AR<V128>) => V128): this;
29
+ dirty(...pids: AR<N>): this;
30
+ g(pid: N): V128 | UD;
31
+ h(pid: N): B;
32
+ $debug(limit?: N): this;
33
+ $strict(): this;
34
+ $history(): AR<M2BEvent>;
35
+ $why(pid: N): M2BEvent | UD;
36
+ $diff(other: M2BI): {
37
+ add: AR<[number, V128]>;
38
+ del: AR<number>;
39
+ chg: AR<[number, V128, V128]>;
40
+ };
41
+ entries(): Generator<[N, V128]>;
42
+ keys(): Generator<N>;
43
+ values(): Generator<V128>;
44
+ [Symbol.iterator](): Generator<[N, V128]>;
45
+ has: (pid: N) => B;
46
+ get: (pid: N) => V128 | UD;
47
+ delete: (pid: N) => B;
48
+ clear: () => V;
49
+ f: (fn: (v: V128, pid: N, map: this) => V) => V;
50
+ forEach(fn: (v: V128, pid: N, map: this) => V): V;
51
+ swap(value: V128, pid: N): V128 | UD;
52
+ take(pid: N): V128 | UD;
53
+ peek(pid: N): V128 | false;
54
+ getOrI(value: V128, pid: N): V128;
55
+ getOrM(make: () => V128, pid: N): V128;
56
+ update(pid: N, fn: (old: V128, has: B) => V128, initial?: V128): V128;
57
+ setIfAbsent(value: V128, pid: N): B;
58
+ setIfPresent(value: V128, pid: N): B;
59
+ replace(value: V128, pid: N): B;
60
+ inc(pid: N, by?: N): N;
61
+ touch(pid: N): B;
62
+ mapValues(fn: (v: V128, pid: N) => V128): M2BI;
63
+ mapKeys(fn: (v: V128, pid: N) => N): M2BI;
64
+ filterKV(pred: (v: V128, pid: N) => B): this;
65
+ filterKeys(pred: (v: V128, pid: N) => B): this;
66
+ partition(pred: (v: V128, pid: N) => B): [M2BI, M2BI];
67
+ find(pred: (v: V128, pid: N) => B): [N, V128] | UD;
68
+ findKey(pred: (v: V128, pid: N) => B): N | UD;
69
+ findValue(pred: (v: V128, pid: N) => B): V128 | UD;
70
+ some(pred: (v: V128, pid: N) => B): B;
71
+ every(pred: (v: V128, pid: N) => B): B;
72
+ reduce<G>(fn: (acc: G, v: V128, pid: N) => G, initial: G): G;
73
+ forEachKV(fn: (v: V128, pid: N, map: this) => V): V;
74
+ invert(): M2<V128, N>;
75
+ unique(fn?: (v: V128, pid: N) => N): M2BI;
76
+ pick(pids: Iterable<N>): M2BI;
77
+ omit(pids: Iterable<N>): M2BI;
78
+ merge(other: Iterable<readonly [N, V128]>): this;
79
+ clearAndSet(entries: Iterable<readonly [N, V128]>): this;
80
+ toObject(): OB<V128>;
81
+ toValues(): AR<V128>;
82
+ toKeys(): AR<N>;
83
+ toArray(): AR<[N, V128]>;
84
+ group<G>(fn: (v: V128, pid: N) => G): Map<G, AR<V128>>;
85
+ clone(): this;
86
+ equals(other: M2BI): B;
87
+ static fromObject(obj: Record<N, V128>, maxParticles: N, stride?: N): M2BI;
88
+ static fromEntries(entries: I<readonly [N, V128]>, maxParticles: N, stride?: N): M2BI;
89
+ static from(map: RM<N, V128>, maxParticles: N, stride?: N): M2BI;
90
+ }
91
+ export {};
@@ -0,0 +1,33 @@
1
+ export declare class M2DI<Key = A, V = number> {
2
+ #private;
3
+ constructor(capacity?: number);
4
+ get size(): N;
5
+ get capacity(): N;
6
+ /** live backing buffer: value of pid p is buffer[p], valid where live[p] === 1 */
7
+ get buffer(): F64;
8
+ get live(): U8;
9
+ get(k: number): V | UD;
10
+ has(k: number): boolean;
11
+ set(k: number, v: V): this;
12
+ delete(k: number): B;
13
+ clear(): void;
14
+ keys(): MapIterator<N>;
15
+ values(): MapIterator<V>;
16
+ entries(): MapIterator<[N, V]>;
17
+ [Symbol.iterator](): MapIterator<[N, V]>;
18
+ forEach(fn: (v: V, k: N, m: M<N, V>) => V, thisArg?: U): void;
19
+ /** read by pid — no typeof guard: pids are numbers */
20
+ g(pid: N): V | UD;
21
+ /** write by pid */
22
+ s(v: N, pid: N): this;
23
+ getOr(pid: N, dflt?: number): N;
24
+ /** pid += delta, returns the new value */
25
+ add(pid: N, delta: N): N;
26
+ in(pid: N): B;
27
+ /** walk live pids without allocating an iterator */
28
+ forEachRaw(fn: (pid: N, value: N) => V): void;
29
+ /** values for a list of pids, NaN where absent */
30
+ gather(pids: ArrayLike<N>, out?: Float64Array<ArrayBuffer>): Float64Array;
31
+ }
32
+ export interface M2D<K, V> extends M2DI<K, V> {
33
+ }
@@ -0,0 +1,33 @@
1
+ export declare class M2RI<K = N> {
2
+ #private;
3
+ readonly stride: N;
4
+ constructor(capacity?: number, stride?: number);
5
+ get size(): N;
6
+ get capacity(): N;
7
+ get buffer(): Float64Array;
8
+ get(pid: N): Float64Array | UD;
9
+ has(pid: N): boolean;
10
+ set(pid: N, v: Float64Array | ArrayLike<N>): this;
11
+ delete(pid: N): boolean;
12
+ clear(): void;
13
+ /** copy a row in, no validation per component */
14
+ write(pid: N, v: Float64Array | ArrayLike<N>): V;
15
+ /** single component: row[c] = v */
16
+ put(pid: N, c: N, v: N): V;
17
+ /** single component: row[c] */
18
+ at(pid: N, c: N): N;
19
+ /** pid -> slot, or -1 */
20
+ slotOf(pid: N): N;
21
+ /** zero-copy row view you can write through */
22
+ row(pid: N): F64 | UD;
23
+ /** view over the live prefix of the whole table — feed straight to a shader/worker */
24
+ live(): F64;
25
+ keys(): MapIterator<K>;
26
+ values(): MapIterator<F64>;
27
+ entries(): MapIterator<[K, F64]>;
28
+ [Symbol.iterator](): MapIterator<[K, F64]>;
29
+ forEach(fn: (v: F64, k: K, m: M2RI<K>) => V, thisArg?: U): V;
30
+ forEachRaw(fn: (pid: N, slot: N) => V): V;
31
+ }
32
+ export interface M2R<K> extends M2RI {
33
+ }
@@ -0,0 +1,44 @@
1
+ export declare class N2I extends Number implements N2 {
2
+ abs(): N2I;
3
+ sign(): N2I;
4
+ neg(): N2I;
5
+ inv(): N2I;
6
+ clamp(min: N, max: N): N2I;
7
+ wrap(min: N, max: N): N2I;
8
+ lerp(to: N, t: N): N2I;
9
+ map(inMin: N, inMax: N, outMin: N, outMax: N): N2I;
10
+ remap(inMin: N, inMax: N, outMin: N, outMax: N): N2I;
11
+ roundTo(precision?: N): N2I;
12
+ floorTo(precision?: N): N2I;
13
+ ceilTo(precision?: N): N2I;
14
+ truncTo(precision?: N): N2I;
15
+ isFinite(): B;
16
+ isInteger(): B;
17
+ isSafeInteger(): B;
18
+ isNaN(): B;
19
+ isBetween(min: N, max: N, inclusive?: B): B;
20
+ isPositive(): B;
21
+ isNegative(): B;
22
+ isZero(): B;
23
+ isEven(): B;
24
+ isOdd(): B;
25
+ squared(): N2I;
26
+ cubed(): N2I;
27
+ sqrt(): N2I;
28
+ cbrt(): N2I;
29
+ pow(exponent: N): N2I;
30
+ root(degree: N): N2I;
31
+ mod(divisor: N): N2I;
32
+ percentOf(total: N): N2I;
33
+ percentChange(from: N): N2I;
34
+ toRadians(): N2I;
35
+ toDegrees(): N2I;
36
+ toOrdinal(): S;
37
+ toBytes(unit?: N, decimals?: N): S;
38
+ toCompact(locales?: Intl.LocalesArgument): S;
39
+ toCurrency(currency?: S, locales?: Intl.LocalesArgument): S;
40
+ toPercent(decimals?: N, locales?: Intl.LocalesArgument): S;
41
+ times(fn: (index: N) => void): this;
42
+ upTo(end: N, step?: N): AR<N>;
43
+ downTo(end: N, step?: N): AR<N>;
44
+ }
@@ -0,0 +1,35 @@
1
+ export declare class O2I {
2
+ static isEmpty(value: object): B;
3
+ static isNotEmpty(value: object): B;
4
+ static size(value: object): N;
5
+ static isPlainObject(value: unknown): B;
6
+ static isObject(value: unknown): B;
7
+ static get<X = unknown>(value: unknown, path: string | readonly PropertyKey[], fallback?: X): unknown | X;
8
+ static getOr<X>(value: unknown, path: string | readonly PropertyKey[], fallback: X): X;
9
+ static set<T extends object>(value: T, path: string | readonly PropertyKey[], next: unknown): T;
10
+ static unset(value: object, path: string | readonly PropertyKey[]): B;
11
+ static hasPath(value: unknown, path: string | readonly PropertyKey[]): B;
12
+ static clone<T>(value: T): T;
13
+ static deepClone<T>(value: T): T;
14
+ static deepMerge<T extends object, U extends object>(target: T, source: U): T & U;
15
+ static defaults<T extends object, U extends object>(target: T, defaults: U): T & U;
16
+ static getOrCreate<T extends object, K extends PropertyKey, X>(value: T, key: K, create: () => X): T & Record<K, X>;
17
+ static pick<T extends object, K extends keyof T>(value: T, keys: readonly K[]): Pick<T, K>;
18
+ static omit<T extends object, K extends keyof T>(value: T, keys: readonly K[]): Omit<T, K>;
19
+ static pickBy<T extends object>(value: T, predicate: (value: T[keyof T], key: keyof T) => B): Partial<T>;
20
+ static omitBy<T extends object>(value: T, predicate: (value: T[keyof T], key: keyof T) => B): Partial<T>;
21
+ static mapKeys<T extends object, K extends PropertyKey>(value: T, mapper: (key: keyof T, value: T[keyof T]) => K): Partial<Record<K, T[keyof T]>>;
22
+ static mapValues<T extends object, X>(value: T, mapper: (value: T[keyof T], key: keyof T) => X): {
23
+ [K in keyof T]: X;
24
+ };
25
+ static mapEntries<T extends object, K extends PropertyKey, X>(value: T, mapper: (entry: [keyof T, T[keyof T]]) => readonly [K, X]): Partial<Record<K, X>>;
26
+ static filter<T extends object>(value: T, predicate: (value: T[keyof T], key: keyof T) => B): Partial<T>;
27
+ static isEqual(first: unknown, second: unknown): B;
28
+ static isShallowEqual(first: object, second: object): B;
29
+ static hasAll<T extends object>(value: T, keys: readonly PropertyKey[]): B;
30
+ static hasAny<T extends object>(value: T, keys: readonly PropertyKey[]): B;
31
+ static assertKeys<T extends object>(value: T, keys: readonly PropertyKey[]): asserts value is T;
32
+ static with<T extends object, K extends keyof T>(value: T, key: K, next: T[K]): T;
33
+ static without<T extends object, K extends keyof T>(value: T, key: K): Omit<T, K>;
34
+ static update<T extends object, K extends keyof T>(value: T, key: K, updater: (current: T[K]) => T[K]): T;
35
+ }
@@ -0,0 +1,62 @@
1
+ export declare class P2I<T = A> extends Promise<T> implements P2<T> {
2
+ #private;
3
+ constructor(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: A) => void) => void);
4
+ static get [Symbol.species](): PromiseConstructor;
5
+ then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): P2I<TResult1 | TResult2>;
6
+ catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null): P2I<T | TResult>;
7
+ finally(onfinally?: (() => void) | null): P2I<T>;
8
+ status(): "pending" | "fulfilled" | "rejected";
9
+ isPending(): B;
10
+ isFulfilled(): B;
11
+ isRejected(): B;
12
+ value(): T | UD;
13
+ error(): A | UD;
14
+ elapsed(): N | UD;
15
+ static resolve(): P2I<void>;
16
+ static resolve<T>(value: T | PromiseLike<T>): P2I<Awaited<T>>;
17
+ static reject<T = never>(reason?: A): P2I<T>;
18
+ static all<T extends readonly unknown[] | []>(values: T): P2I<{
19
+ -readonly [P in keyof T]: Awaited<T[P]>;
20
+ }>;
21
+ static allSettled<T extends readonly unknown[] | []>(values: T): P2I<{
22
+ -readonly [P in keyof T]: PromiseSettledResult<Awaited<T[P]>>;
23
+ }>;
24
+ static race<T extends readonly unknown[] | []>(values: T): P2I<Awaited<T[number]>>;
25
+ static any<T extends readonly unknown[] | []>(values: T): P2I<Awaited<T[number]>>;
26
+ static retry<T>(fn: () => T | PromiseLike<T>, times?: N, delay?: N): P2I<Awaited<T>>;
27
+ static deferred<T = A>(): {
28
+ promise: P2I<T>;
29
+ resolve: (value: T | PromiseLike<T>) => void;
30
+ reject: (reason?: A) => void;
31
+ };
32
+ static try<T>(fn: () => T | PromiseLike<T>): P2I<Awaited<T>>;
33
+ static sleep(ms: N): P2I<void>;
34
+ static fromCallback<T>(fn: (cb: (err: A, value?: T) => void) => void): P2I<T>;
35
+ static mapLimit<T, G>(items: AR<T>, limit: N, fn: (item: T, index: N) => G | PromiseLike<G>): P2I<AR<G>>;
36
+ static series<T>(fns: AR<() => T | PromiseLike<T>>): P2I<AR<T>>;
37
+ tap(fn: (value: T) => unknown): P2I<T>;
38
+ tapError(fn: (error: A) => unknown): P2I<T>;
39
+ recover(fn: (error: A) => T | PromiseLike<T>): P2I<T>;
40
+ fallback(value: T | PromiseLike<T>): P2I<T>;
41
+ timeout(ms: N, error?: A): P2I<T>;
42
+ delay(ms: N): P2I<T>;
43
+ withDeadline(deadline: N, error?: A): P2I<T>;
44
+ map<G>(fn: (value: T) => G | PromiseLike<G>): P2I<Awaited<G>>;
45
+ flatMap<G>(fn: (value: T) => G | PromiseLike<G>): P2I<Awaited<G>>;
46
+ or<G>(other: G | PromiseLike<G>): P2I<T | Awaited<G>>;
47
+ and<G>(other: G | PromiseLike<G>): P2I<[T, Awaited<G>]>;
48
+ zip<G>(other: PromiseLike<G>): P2I<[T, Awaited<G>]>;
49
+ unwrap(): Promise<T>;
50
+ toResult(): P2I<{
51
+ ok: true;
52
+ value: T;
53
+ } | {
54
+ ok: false;
55
+ error: A;
56
+ }>;
57
+ onResolve(fn: (value: T) => unknown): P2I<T>;
58
+ onReject(fn: (error: A) => unknown): P2I<T>;
59
+ finallyDo(fn: () => unknown): P2I<T>;
60
+ $label(name: S): this;
61
+ $debug(): this;
62
+ }
@@ -0,0 +1,72 @@
1
+ export declare class REC2 implements RE2_IF {
2
+ #private;
3
+ constructor(source: S, flags?: S);
4
+ get source(): S;
5
+ get flags(): S;
6
+ get global(): B;
7
+ get ignoreCase(): B;
8
+ get multiline(): B;
9
+ get sticky(): B;
10
+ get unicode(): B;
11
+ get dotAll(): B;
12
+ get hasIndices(): B;
13
+ toRegExp(): RegExp;
14
+ test(str: S): B;
15
+ h(str: S): B;
16
+ exec(str: S): RegExpExecArray | null;
17
+ g(str: S): S | UD;
18
+ at(str: S, n: N): S | UD;
19
+ groups(str: S): OB<S> | UD;
20
+ group(str: S, name: S | N): S | UD;
21
+ index(str: S): N;
22
+ lastIndexOf(str: S): N;
23
+ span(str: S): [N, N] | UD;
24
+ all(str: S): AR<S>;
25
+ matches(str: S): AR<RE2Match>;
26
+ allGroups(str: S): AR<OB<S>>;
27
+ allSpans(str: S): AR<[N, N]>;
28
+ count(str: S): N;
29
+ positions(str: S): AR<N>;
30
+ replace(str: S, fn: S | RE2ReplaceFn): S;
31
+ replaceFirst(str: S, fn: S | RE2ReplaceFn): S;
32
+ replaceAt(str: S, n: N, fn: S | RE2ReplaceFn): S;
33
+ remove(str: S): S;
34
+ removeFirst(str: S): S;
35
+ split(str: S, limit?: N): AR<S>;
36
+ splitKeep(str: S): AR<S>;
37
+ withFlags(flags: S): RE2_IF;
38
+ addFlag(flag: RE2Flag): RE2_IF;
39
+ removeFlag(flag: RE2Flag): RE2_IF;
40
+ toggleFlag(flag: RE2Flag): RE2_IF;
41
+ withSource(src: S): RE2_IF;
42
+ and(...parts: AR<RE2Input>): RE2_IF;
43
+ or(...parts: AR<RE2Input>): RE2_IF;
44
+ cap(expr?: RE2Input): RE2_IF;
45
+ namedGroup(name: S, expr: RE2Input): RE2_IF;
46
+ nonCap(expr: RE2Input): RE2_IF;
47
+ lookahead(expr: RE2Input): RE2_IF;
48
+ notLookahead(expr: RE2Input): RE2_IF;
49
+ lookbehind(expr: RE2Input): RE2_IF;
50
+ notLookbehind(expr: RE2Input): RE2_IF;
51
+ optional(expr?: RE2Input): RE2_IF;
52
+ many(expr?: RE2Input): RE2_IF;
53
+ maybeMany(expr?: RE2Input): RE2_IF;
54
+ repeat(n: N, max?: N, expr?: RE2Input): RE2_IF;
55
+ /**
56
+ * [BEST-EFFORT] Appends `?` after a trailing `*`/`+`/`?`/`{n,m}` to make it lazy.
57
+ * Only looks at the END of the source — it's not a regex parser, it won't find
58
+ * quantifiers buried mid-pattern. Meant to be chained right after .optional()/
59
+ * .many()/.maybeMany()/.repeat(), where the quantifier IS the last token.
60
+ * If no trailing quantifier is found, returns an unchanged clone.
61
+ */
62
+ lazy(): RE2_IF;
63
+ $trace(str: S): AR<RE2Match>;
64
+ $explain(): AR<S>;
65
+ $risky(): B;
66
+ $bench(str: S, iterations?: N): N;
67
+ toString(): S;
68
+ equals(other: RE2Input): B;
69
+ clone(): RE2_IF;
70
+ static fromRegExp(re: RegExp): REC2;
71
+ }
72
+ export declare const RECC2: RE2Static;
package/dist/set.d.ts ADDED
@@ -0,0 +1,41 @@
1
+ import { M2I } from "./map";
2
+ export declare class SET2I<T = A> extends Set<T> implements SET2<T> {
3
+ s: (value: T) => this;
4
+ take(value: T): T | UD;
5
+ peek(value: T): T | false;
6
+ toggle(value: T): B;
7
+ first(): T | UD;
8
+ last(): T | UD;
9
+ union(other: Iterable<T>): SET2I<T>;
10
+ intersection(other: Iterable<T>): SET2I<T>;
11
+ difference(other: Iterable<T>): SET2I<T>;
12
+ symmetricDifference(other: Iterable<T>): SET2I<T>;
13
+ isSubsetOf(other: Iterable<T>): B;
14
+ isSupersetOf(other: Iterable<T>): B;
15
+ isDisjointFrom(other: Iterable<T>): B;
16
+ equals(other: Iterable<T>): B;
17
+ filter(fn: (v: T, set: this) => B): SET2I<T>;
18
+ map<R>(fn: (v: T, set: this) => R): SET2I<R>;
19
+ partition(fn: (v: T, set: this) => B): [SET2I<T>, SET2I<T>];
20
+ differenceBy<K>(other: Iterable<T>, fn: (v: T) => K): SET2I<T>;
21
+ uniqueBy<K>(fn: (v: T) => K): SET2I<T>;
22
+ find(fn: (v: T, set: this) => B): T | UD;
23
+ every(fn: (v: T, set: this) => B): B;
24
+ some(fn: (v: T, set: this) => B): B;
25
+ reduce<R>(fn: (acc: R, v: T, set: this) => R, initial: R): R;
26
+ addAll(values: Iterable<T>): this;
27
+ deleteAll(values: Iterable<T>): N;
28
+ retainAll(values: Iterable<T>): this;
29
+ update(values: Iterable<T>): this;
30
+ replace(values: Iterable<T>): this;
31
+ swap(a: T, b: T): B;
32
+ clone(): this;
33
+ toArray(): T[];
34
+ toMap<K, R>(fn: (v: T) => readonly [K, R]): M2I<K, R>;
35
+ toObject(fn?: (v: T) => S): OB<T>;
36
+ toJSON(): T[];
37
+ static fromArray<T>(values: T[]): SET2I<T>;
38
+ static fromObject<O extends Record<string, A>>(obj: O): SET2I<O[keyof O]>;
39
+ static fromEntries<T>(entries: Iterable<readonly [unknown, T]>): SET2I<T>;
40
+ static from<T>(values: Iterable<T>): SET2I<T>;
41
+ }
@@ -0,0 +1,55 @@
1
+ export declare class SET2BI {
2
+ #private;
3
+ readonly cap: N;
4
+ readonly flags: Uint8Array;
5
+ readonly slots: I32;
6
+ readonly pidToIdx: I32;
7
+ constructor(maxParticles?: N, seed?: Iterable<N>);
8
+ get size(): N;
9
+ s: (pid: N) => this;
10
+ add(pid: N): this;
11
+ has(pid: N): B;
12
+ delete(pid: N): B;
13
+ clear(): V;
14
+ [Symbol.iterator](): Generator<N>;
15
+ values(): Generator<N>;
16
+ keys(): Generator<N>;
17
+ entries(): Generator<[N, N]>;
18
+ take(pid: N): N | UD;
19
+ peek(pid: N): N | false;
20
+ toggle(pid: N): B;
21
+ first(): N | UD;
22
+ last(): N | UD;
23
+ union(other: Iterable<N>): SET2BI;
24
+ intersection(other: Iterable<N>): SET2BI;
25
+ difference(other: Iterable<N>): SET2BI;
26
+ symmetricDifference(other: Iterable<N>): SET2BI;
27
+ isSubsetOf(other: Iterable<N>): B;
28
+ isSupersetOf(other: Iterable<N>): B;
29
+ isDisjointFrom(other: Iterable<N>): B;
30
+ equals(other: Iterable<N>): B;
31
+ filter(fn: (pid: N, set: this) => B): SET2BI;
32
+ map(fn: (pid: N, set: this) => N): SET2BI;
33
+ partition(fn: (pid: N, set: this) => B): [SET2BI, SET2BI];
34
+ differenceBy<G>(other: Iterable<N>, fn: (pid: N) => G): SET2BI;
35
+ uniqueBy<G>(fn: (pid: N) => G): SET2BI;
36
+ find(fn: (pid: N, set: this) => B): N | UD;
37
+ every(fn: (pid: N, set: this) => B): B;
38
+ some(fn: (pid: N, set: this) => B): B;
39
+ reduce<G>(fn: (acc: G, pid: N, set: this) => G, initial: G): G;
40
+ addAll(pids: Iterable<N>): this;
41
+ deleteAll(pids: Iterable<N>): N;
42
+ retainAll(pids: Iterable<N>): this;
43
+ update(pids: Iterable<N>): this;
44
+ replace(pids: Iterable<N>): this;
45
+ swap(a: N, b: N): B;
46
+ clone(): SET2BI;
47
+ toArray(): AR<N>;
48
+ toMap<K, T>(fn: (pid: N) => [K, T]): Map<K, T>;
49
+ toObject(fn?: (pid: N) => S): OB<N>;
50
+ toJSON(): AR<N>;
51
+ static fromArray(pids: AR<N>, maxParticles?: N): SET2BI;
52
+ static fromObject(obj: Record<S, N>, maxParticles?: N): SET2BI;
53
+ static fromEntries(entries: I<readonly [A, N]>, maxParticles?: N): SET2BI;
54
+ static from(pids: Iterable<N>, maxParticles?: N): SET2BI;
55
+ }
@@ -0,0 +1,12 @@
1
+ export declare class SOA_CODEC {
2
+ readonly maxPids: number;
3
+ readonly channelMap: Int32Array;
4
+ readonly subChannelMap: Int32Array;
5
+ readonly tripChannelMap: Int32Array;
6
+ readonly keyMap: Int32Array;
7
+ readonly listeners: Array<((pid: number, val?: number) => void) | undefined>;
8
+ nextPid: number;
9
+ constructor(maxPids?: number);
10
+ allocatePid(rId: number, mId: number, sId: number, kId: number): number;
11
+ }
12
+ export declare const soa_codeci: SOA_CODEC;