@the-w1zard/dx 1.0.12 → 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.
Files changed (51) hide show
  1. package/dist/array.d.ts +41 -0
  2. package/dist/boolean_byte.d.ts +12 -0
  3. package/dist/class.d.ts +0 -0
  4. package/dist/date.d.ts +146 -0
  5. package/dist/error.d.ts +16 -0
  6. package/dist/index.d.ts +25 -0
  7. package/dist/index.js +5697 -3907
  8. package/dist/iterator.d.ts +51 -0
  9. package/dist/map.d.ts +69 -0
  10. package/dist/map_bin.d.ts +34 -0
  11. package/dist/map_byte.d.ts +91 -0
  12. package/dist/map_dense.d.ts +33 -0
  13. package/dist/map_rows.d.ts +33 -0
  14. package/dist/number.d.ts +44 -0
  15. package/dist/object.d.ts +35 -0
  16. package/dist/promise.d.ts +62 -0
  17. package/dist/reg_ex.d.ts +72 -0
  18. package/dist/set.d.ts +41 -0
  19. package/dist/set_byte.d.ts +55 -0
  20. package/dist/soa_codec.d.ts +12 -0
  21. package/dist/string.d.ts +39 -0
  22. package/dist/unit8array.d.ts +64 -0
  23. package/dist/url_search_params.d.ts +30 -0
  24. package/dist/weak_map.d.ts +32 -0
  25. package/dist/weak_set.d.ts +20 -0
  26. package/package.json +10 -8
  27. package/src/array.ts +301 -0
  28. package/src/boolean_byte.ts +23 -0
  29. package/src/class.ts +0 -0
  30. package/src/date.ts +660 -0
  31. package/src/dx.d.ts +31 -11
  32. package/src/error.ts +81 -0
  33. package/src/index.ts +57 -0
  34. package/src/iterator.ts +407 -0
  35. package/src/map.ts +513 -0
  36. package/src/map_bin.ts +179 -0
  37. package/src/map_byte.ts +418 -0
  38. package/src/map_dense.ts +167 -0
  39. package/src/map_rows.ts +145 -0
  40. package/src/number.ts +212 -0
  41. package/src/object.ts +291 -0
  42. package/src/promise.ts +309 -0
  43. package/src/reg_ex.ts +423 -0
  44. package/src/set.ts +198 -0
  45. package/src/set_byte.ts +223 -0
  46. package/src/soa_codec.ts +30 -0
  47. package/src/string.ts +175 -0
  48. package/src/unit8array.ts +374 -0
  49. package/src/url_search_params.ts +187 -0
  50. package/src/weak_map.ts +155 -0
  51. package/src/weak_set.ts +101 -0
@@ -0,0 +1,41 @@
1
+ export declare class A2I<T = A> extends Array<T> implements A2<T> {
2
+ constructor(...items: T[]);
3
+ static get [Symbol.species](): ArrayConstructor;
4
+ static from<T>(arrayLike: ArrayLike<T> | Iterable<T>): A2<T>;
5
+ static of<T>(...items: T[]): A2<T>;
6
+ first(): T | UD;
7
+ last(): T | UD;
8
+ isEmpty(): B;
9
+ isNotEmpty(): B;
10
+ clear(): this;
11
+ clone(): A2<T>;
12
+ unique(): A2<T>;
13
+ compact(): A2<NonNullable<T>>;
14
+ take(count: N): A2<T>;
15
+ takeLast(count: N): A2<T>;
16
+ drop(count: N): A2<T>;
17
+ dropLast(count: N): A2<T>;
18
+ chunk(size: N): A2<A2<T>>;
19
+ flatten<X>(depth?: N): A2<X>;
20
+ flatMap<U>(callback: (value: T, index: N, array: this) => U | readonly U[]): A2<U>;
21
+ distinctBy<K>(callback: (value: T, index: N) => K): A2<T>;
22
+ groupBy<K extends PropertyKey>(callback: (value: T, index: N) => K): Map<K, A2<T>>;
23
+ partition(callback: (value: T, index: N) => B): [A2<T>, A2<T>];
24
+ insert(index: N, ...items: T[]): this;
25
+ removeAt(index: N): T | UD;
26
+ remove(value: T): B;
27
+ removeAll(value: T): N;
28
+ replaceAt(index: N, value: T): T | UD;
29
+ move(from: N, to: N): this;
30
+ swap(first: N, second: N): this;
31
+ sample(): T | UD;
32
+ shuffle(): this;
33
+ countBy(callback: (value: T, index: N) => B): N;
34
+ sum(callback?: (value: T, index: N) => N): N;
35
+ average(callback?: (value: T, index: N) => N): N;
36
+ min(callback?: (value: T, index: N) => N): T | UD;
37
+ max(callback?: (value: T, index: N) => N): T | UD;
38
+ equals(array: readonly T[]): B;
39
+ includesAll(values: readonly T[]): B;
40
+ intersects(values: readonly T[]): B;
41
+ }
@@ -0,0 +1,12 @@
1
+ export declare class B2BI {
2
+ readonly flags: Uint8Array;
3
+ constructor(maxParticles?: number); /** Set a boolean flag for a PID. O(1) time complexity. */
4
+ set(pid: number, value: boolean): void;
5
+ true(pid: number, value: boolean): void;
6
+ false(pid: number, value: boolean): void;
7
+ /** Get the boolean state for a PID. O(1) time complexity. */
8
+ get(pid: number): boolean;
9
+ /** Toggle the boolean state for a PID. O(1) time complexity. */
10
+ toggle(pid: number): boolean; /** Clear all flags instantly without reallocating memory. */
11
+ clear(): void;
12
+ }
File without changes
package/dist/date.d.ts ADDED
@@ -0,0 +1,146 @@
1
+ export declare const DATE_TAG = 17458;
2
+ export declare const D2_CODEC: {
3
+ tag: number;
4
+ test(v: A): v is D2;
5
+ enc(d: D): N;
6
+ dec(ms: N): D2;
7
+ };
8
+ export declare class D2I extends Date implements D2 {
9
+ constructor(value?: S | N | D);
10
+ toLocalString(format?: A): S;
11
+ static now(): N;
12
+ static fromUnix(seconds: N): D2;
13
+ static fromUnixMs(ms: N): D2;
14
+ static fromParts(year: N, month: N, day: N, hour?: number, minute?: number, second?: number, ms?: number): D2;
15
+ static today(): D2;
16
+ static min(...dates: D[]): D2;
17
+ static max(...dates: D[]): D2;
18
+ clone(): D2;
19
+ isValid(): B;
20
+ month(): N;
21
+ dateOfWeek(): N;
22
+ dayOfYear(): N;
23
+ quarter(): N;
24
+ unix(): N;
25
+ addMs(amount: N): D2;
26
+ addSeconds(amount: N): D2;
27
+ addMinutes(amount: N): D2;
28
+ addHours(amount: N): D2;
29
+ addDays(amount: N): D2;
30
+ addWeeks(amount: N): D2;
31
+ addMonths(amount: N): D2;
32
+ addYears(amount: N): D2;
33
+ subDays(amount: N): D2;
34
+ subMonths(amount: N): D2;
35
+ subYears(amount: N): D2;
36
+ startOfDay(): D2;
37
+ endOfDay(): D2;
38
+ startOfWeek(weekStartsOn?: number): D2;
39
+ endOfWeek(weekStartsOn?: number): D2;
40
+ startOfMonth(): D2;
41
+ endOfMonth(): D2;
42
+ startOfQuarter(): D2;
43
+ endOfQuarter(): D2;
44
+ startOfYear(): D2;
45
+ endOfYear(): D2;
46
+ daysInMonth(): N;
47
+ daysInYear(): N;
48
+ isLeapYear(): B;
49
+ isWeekend(): B;
50
+ isWeekday(): B;
51
+ isBefore(other: D): B;
52
+ isAfter(other: D): B;
53
+ isEqual(other: D): B;
54
+ isBetween(start: D, end: D): B;
55
+ diffMs(other: D): N;
56
+ diffSeconds(other: D): N;
57
+ diffMinutes(other: D): N;
58
+ diffHours(other: D): N;
59
+ diffDays(other: D): N;
60
+ sameDay(other: D): B;
61
+ sameMonth(other: D): B;
62
+ sameYear(other: D): B;
63
+ toUnixMs(): N;
64
+ toUnix(): N;
65
+ toD2(): D2;
66
+ ago(): S;
67
+ fromNow(): S;
68
+ from(other: D): S;
69
+ static from(v: A): D2;
70
+ toInputDate(): S;
71
+ toInputTime(): S;
72
+ toInputDateTime(): S;
73
+ toInputTimeWithSeconds(): S;
74
+ next(unit: DAYSD2): D2;
75
+ prev(unit: Parameters<D2["next"]>[0]): D2;
76
+ nextWeek(): D2;
77
+ prevWeek(): D2;
78
+ nextMonth(): D2;
79
+ prevMonth(): D2;
80
+ nextQuarter(): D2;
81
+ prevQuarter(): D2;
82
+ nextYear(): D2;
83
+ prevYear(): D2;
84
+ subWeeks(n: N): D2;
85
+ at(hour: N, minute?: number, second?: number, ms?: number): D2;
86
+ atNoon(): D2;
87
+ midnight(): D2;
88
+ addBusinessDays(n: N): D2;
89
+ nextBusinessDay(): D2;
90
+ prevBusinessDay(): D2;
91
+ isBusinessDay(): B;
92
+ calendarDays(other: D): N;
93
+ businessDays(other: D): N;
94
+ diffHuman(other?: D): S;
95
+ fmt(format: S): S;
96
+ static parseDate(v: S): D2;
97
+ static parseDateTime(v: S): D2;
98
+ set(f: Partial<{
99
+ year: N;
100
+ month: N;
101
+ day: N;
102
+ hour: N;
103
+ minute: N;
104
+ second: N;
105
+ ms: N;
106
+ }>): D2;
107
+ withDate(year: N, month: N, day: N): D2;
108
+ sameTimeOn(other: D): D2;
109
+ to(other: D): R2;
110
+ isSameOrBefore(other: D): B;
111
+ isSameOrAfter(other: D): B;
112
+ clamp(min: D, max: D): D2;
113
+ isSame(unit: "day" | "week" | "month" | "quarter" | "year", other: D): B;
114
+ isToday(): B;
115
+ isTomorrow(): B;
116
+ isYesterday(): B;
117
+ age(unit?: "years" | "months" | "days"): N;
118
+ }
119
+ export declare class R2I implements R2 {
120
+ start: D2;
121
+ end: D2;
122
+ constructor(start: D2, end: D2);
123
+ contains(d: D): B;
124
+ overlaps(other: R2): B;
125
+ durationMs(): N;
126
+ days(): N;
127
+ eachDay(fn: (d: D2, i: N) => void): void;
128
+ toArray(): A2I<D2>;
129
+ }
130
+ export declare const R2II: (start: D, end: D) => R2;
131
+ /**
132
+ * enc(value:A) {
133
+ if (D2_CODEC.test(value)) {
134
+ writeTag(DATE_TAG);
135
+ writeI64(value.getTime());
136
+ return;
137
+ }
138
+
139
+ // existing object / array / string / map handling
140
+ }
141
+ dec(value:A) {
142
+ if (tag === DATE_TAG) { return new D2(readI64()); }
143
+
144
+ // existing revival paths
145
+ }
146
+ */
@@ -0,0 +1,16 @@
1
+ export declare class ER2I extends Error implements ER2 {
2
+ constructor(message?: string, options?: ErrorOptions);
3
+ clone(): ER2I;
4
+ toJSON(): {
5
+ name: string;
6
+ message: string;
7
+ stack?: string;
8
+ cause?: unknown;
9
+ };
10
+ toString(): string;
11
+ static is(value: unknown): value is Error;
12
+ static isER2(value: unknown): value is ER2I;
13
+ static from(value: unknown, fallback?: string): ER2I;
14
+ static wrap(value: unknown, message?: string): ER2I;
15
+ static aggregate(errors: Iterable<unknown>, message?: string): AggregateError;
16
+ }
@@ -0,0 +1,25 @@
1
+ import { M2RI } from "./map_rows";
2
+ import { M2DI } from "./map_dense";
3
+ import { M2BINI } from "./map_bin";
4
+ import { B2BI } from "./boolean_byte";
5
+ import { M2I } from "./map";
6
+ import { M2BI } from "./map_byte";
7
+ import { A2I } from './array';
8
+ import { D2I, R2I, R2II } from './date';
9
+ import { ER2I } from './error';
10
+ import { I2I } from './iterator';
11
+ import { N2I } from './number';
12
+ import { O2I } from './object';
13
+ import { P2I } from './promise';
14
+ import { REC2, RECC2 } from './reg_ex';
15
+ import { SET2I } from './set';
16
+ import { SET2BI } from './set_byte';
17
+ import { SOA_CODEC, soa_codeci } from './soa_codec';
18
+ import { S2I } from './string';
19
+ import { U82I } from './unit8array';
20
+ import { USP2I } from './url_search_params';
21
+ import { WM2I } from './weak_map';
22
+ import { WS2I } from './weak_set';
23
+ export type MaybePromise<R = any> = R;
24
+ export declare function MaybePromisei<R = any>(v: R): MaybePromise;
25
+ export { M2RI as M2R, M2DI as M2D, M2BINI as M2BIN, A2I as A2, B2BI as B2B, D2I as D2, ER2I as ER2, I2I as I2, M2BI as M2B, M2I as M2, N2I as N2, O2I as O2, P2I as P2, REC2 as RE2, RECC2 as RES2, SET2I as SET2, SET2BI as SET2B, SOA_CODEC, soa_codeci as soa_codec, S2I as S2, U82I as U82, USP2I as USP2, WM2I as WM2, WS2I as WS2, R2I as R2, R2II as R2I };