@esmalley/ts-utils 6.4.6 → 7.0.0
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/README.md +435 -24
- package/dist/cjs/index.js +7 -7
- package/dist/cjs/index.js.map +4 -4
- package/dist/esm/index.js +7 -7
- package/dist/esm/index.js.map +4 -4
- package/dist/types/Arithmetic.d.ts +92 -0
- package/dist/types/Arithmetic.d.ts.map +1 -1
- package/dist/types/Arrayifier.d.ts +83 -6
- package/dist/types/Arrayifier.d.ts.map +1 -1
- package/dist/types/CSV.d.ts +14 -0
- package/dist/types/CSV.d.ts.map +1 -1
- package/dist/types/Color.d.ts +21 -5
- package/dist/types/Color.d.ts.map +1 -1
- package/dist/types/Dates.d.ts +39 -0
- package/dist/types/Dates.d.ts.map +1 -1
- package/dist/types/Kontororu/Socket.d.ts.map +1 -1
- package/dist/types/Kontororu/Store.d.ts.map +1 -1
- package/dist/types/Kontororu.d.ts +12 -5
- package/dist/types/Kontororu.d.ts.map +1 -1
- package/dist/types/Numbers.d.ts +78 -0
- package/dist/types/Numbers.d.ts.map +1 -0
- package/dist/types/Objector.d.ts +14 -0
- package/dist/types/Objector.d.ts.map +1 -1
- package/dist/types/Sorter.d.ts.map +1 -1
- package/dist/types/Style.d.ts.map +1 -1
- package/dist/types/Tasker.d.ts +109 -0
- package/dist/types/Tasker.d.ts.map +1 -0
- package/dist/types/Textor.d.ts +10 -0
- package/dist/types/Textor.d.ts.map +1 -1
- package/dist/types/Toaster.d.ts +26 -1
- package/dist/types/Toaster.d.ts.map +1 -1
- package/dist/types/UuidService.d.ts +7 -0
- package/dist/types/UuidService.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +7 -2
|
@@ -1,4 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bounding, interpolation, and descriptive statistics.
|
|
3
|
+
*
|
|
4
|
+
* Every aggregate ignores nothing and validates nothing: pass it clean numbers.
|
|
5
|
+
* Aggregates over an empty list return NaN rather than 0, so an empty data set
|
|
6
|
+
* is visibly empty instead of silently reading as a real zero.
|
|
7
|
+
*
|
|
8
|
+
* That split holds across the package: an aggregate with nothing to work on
|
|
9
|
+
* yields NaN, because the caller is asking about data rather than supplying a
|
|
10
|
+
* bad argument, while an argument that cannot be honoured at all -- a chunk
|
|
11
|
+
* size below 1, a step of 0 -- throws.
|
|
12
|
+
*/
|
|
1
13
|
export declare class Arithmetic {
|
|
14
|
+
/**
|
|
15
|
+
* Restrict a number to the inclusive range [min, max].
|
|
16
|
+
*/
|
|
2
17
|
static clamp(number: number, min: number, max: number): number;
|
|
18
|
+
/**
|
|
19
|
+
* Linearly interpolate between `a` and `b`.
|
|
20
|
+
*
|
|
21
|
+
* `amount` is clamped to 0..1, so the result never overshoots the endpoints.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* Arithmetic.lerp(0, 100, 0.25); // 25
|
|
25
|
+
*/
|
|
26
|
+
static lerp(a: number, b: number, amount: number): number;
|
|
27
|
+
/**
|
|
28
|
+
* Round to a fixed number of decimal places.
|
|
29
|
+
*
|
|
30
|
+
* Uses exponent shifting rather than `Math.round(v * 10 ** p) / 10 ** p`,
|
|
31
|
+
* which misrounds the common half-way cases (0.5 at the target precision).
|
|
32
|
+
* A negative precision rounds to tens, hundreds, and so on.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* Arithmetic.round(1.005, 2); // 1.01
|
|
36
|
+
* Arithmetic.round(1234, -2); // 1200
|
|
37
|
+
*/
|
|
38
|
+
static round(value: number, precision?: number): number;
|
|
39
|
+
/**
|
|
40
|
+
* Re-map a number from one range onto another.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* // A rating of 1500 on a 1000..2000 scale, as a 0..100 score.
|
|
44
|
+
* Arithmetic.mapRange(1500, 1000, 2000, 0, 100); // 50
|
|
45
|
+
*/
|
|
46
|
+
static mapRange(value: number, inMin: number, inMax: number, outMin: number, outMax: number): number;
|
|
47
|
+
/**
|
|
48
|
+
* Scale a value within [min, max] onto 0..1. The inverse of `lerp`.
|
|
49
|
+
*
|
|
50
|
+
* Returns 0 for a zero-width range rather than dividing by zero.
|
|
51
|
+
*/
|
|
52
|
+
static normalize(value: number, min: number, max: number): number;
|
|
53
|
+
/**
|
|
54
|
+
* Total of every value. An empty list sums to 0.
|
|
55
|
+
*/
|
|
56
|
+
static sum(values: number[]): number;
|
|
57
|
+
/**
|
|
58
|
+
* Arithmetic mean. NaN when the list is empty.
|
|
59
|
+
*/
|
|
60
|
+
static mean(values: number[]): number;
|
|
61
|
+
/**
|
|
62
|
+
* Middle value, averaging the two middle values for an even-length list.
|
|
63
|
+
* NaN when the list is empty.
|
|
64
|
+
*/
|
|
65
|
+
static median(values: number[]): number;
|
|
66
|
+
/**
|
|
67
|
+
* The most frequent values, in first-seen order.
|
|
68
|
+
*
|
|
69
|
+
* Returns every tied value rather than picking one arbitrarily, and an empty
|
|
70
|
+
* array for an empty list.
|
|
71
|
+
*/
|
|
72
|
+
static mode(values: number[]): number[];
|
|
73
|
+
/**
|
|
74
|
+
* Variance. Sample variance (dividing by n - 1) by default; pass
|
|
75
|
+
* `population` to divide by n instead.
|
|
76
|
+
*
|
|
77
|
+
* NaN when there are too few values to be meaningful — fewer than 2 for a
|
|
78
|
+
* sample, or none at all for a population.
|
|
79
|
+
*/
|
|
80
|
+
static variance(values: number[], population?: boolean): number;
|
|
81
|
+
/**
|
|
82
|
+
* Standard deviation, the square root of the variance.
|
|
83
|
+
*/
|
|
84
|
+
static stdDev(values: number[], population?: boolean): number;
|
|
85
|
+
/**
|
|
86
|
+
* The value at the given percentile (0-100), interpolating linearly between
|
|
87
|
+
* the two neighbouring values when the percentile falls between them.
|
|
88
|
+
*
|
|
89
|
+
* NaN when the list is empty.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* Arithmetic.percentile([1, 2, 3, 4], 50); // 2.5
|
|
93
|
+
*/
|
|
94
|
+
static percentile(values: number[], p: number): number;
|
|
3
95
|
}
|
|
4
96
|
//# sourceMappingURL=Arithmetic.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Arithmetic.d.ts","sourceRoot":"","sources":["../../src/Arithmetic.ts"],"names":[],"mappings":"AAcA,qBAAa,UAAU;
|
|
1
|
+
{"version":3,"file":"Arithmetic.d.ts","sourceRoot":"","sources":["../../src/Arithmetic.ts"],"names":[],"mappings":"AAcA;;;;;;;;;;;GAWG;AACH,qBAAa,UAAU;IACrB;;OAEG;WACW,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM;IAIrE;;;;;;;OAOG;WACW,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM;IAIhE;;;;;;;;;;OAUG;WACW,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,GAAE,MAAU,GAAG,MAAM;IAajE;;;;;;OAMG;WACW,QAAQ,CACpB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GACb,MAAM;IAQT;;;;OAIG;WACW,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM;IAQxE;;OAEG;WACW,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM;IAI3C;;OAEG;WACW,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM;IAQ5C;;;OAGG;WACW,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM;IAI9C;;;;;OAKG;WACW,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE;IA+B9C;;;;;;OAMG;WACW,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,UAAU,GAAE,OAAe,GAAG,MAAM;IAgB7E;;OAEG;WACW,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,UAAU,GAAE,OAAe,GAAG,MAAM;IAI3E;;;;;;;;OAQG;WACW,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM;CAqB9D"}
|
|
@@ -23,12 +23,89 @@ export declare class Arrayifier {
|
|
|
23
23
|
*/
|
|
24
24
|
static combination<T>(arr: T[], n: number, r: number, index: number, data: T[], i: number, results: T[][]): T[][];
|
|
25
25
|
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
* Get all combinations of size `r` from the provided array.
|
|
27
|
+
*
|
|
28
|
+
* @param arr The source array
|
|
29
|
+
* @param r The size of each combination
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* Arrayifier.getCombinations([1, 2, 3], 2);
|
|
33
|
+
* // [[1, 2], [1, 3], [2, 3]]
|
|
34
|
+
*/
|
|
35
|
+
static getCombinations<T>(arr: T[], r: number): T[][];
|
|
36
|
+
/**
|
|
37
|
+
* Get all combinations of size `r`, considering only the first `n` elements.
|
|
38
|
+
*
|
|
39
|
+
* @param arr The source array
|
|
40
|
+
* @param n How many leading elements to draw from
|
|
41
|
+
* @param r The size of each combination
|
|
42
|
+
*/
|
|
32
43
|
static getCombinations<T>(arr: T[], n: number, r: number): T[][];
|
|
44
|
+
/**
|
|
45
|
+
* Split an array into consecutive chunks of at most `size`.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* Arrayifier.chunk([1, 2, 3, 4, 5], 2); // [[1, 2], [3, 4], [5]]
|
|
49
|
+
*/
|
|
50
|
+
static chunk<T>(arr: T[], size: number): T[][];
|
|
51
|
+
/**
|
|
52
|
+
* Remove duplicate values, keeping the first occurrence of each.
|
|
53
|
+
*
|
|
54
|
+
* Compares by identity, so it suits primitives; use `uniqueBy` for objects.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* Arrayifier.unique([1, 2, 2, 3, 1]); // [1, 2, 3]
|
|
58
|
+
*/
|
|
59
|
+
static unique<T>(arr: T[]): T[];
|
|
60
|
+
/**
|
|
61
|
+
* Remove duplicates by a derived key, keeping the first of each key.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* Arrayifier.uniqueBy(players, (p) => p.team_id);
|
|
65
|
+
*/
|
|
66
|
+
static uniqueBy<T, K>(arr: T[], keyFn: (item: T, index: number) => K): T[];
|
|
67
|
+
/**
|
|
68
|
+
* Bucket items by a derived key.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* Arrayifier.groupBy(games, (g) => g.season);
|
|
72
|
+
* // { 2025: [...], 2026: [...] }
|
|
73
|
+
*/
|
|
74
|
+
static groupBy<T, K extends string | number>(arr: T[], keyFn: (item: T, index: number) => K): Record<K, T[]>;
|
|
75
|
+
/**
|
|
76
|
+
* Count items by a derived key.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* Arrayifier.countBy(games, (g) => g.status); // { final: 12, live: 3 }
|
|
80
|
+
*/
|
|
81
|
+
static countBy<T, K extends string | number>(arr: T[], keyFn: (item: T, index: number) => K): Record<K, number>;
|
|
82
|
+
/**
|
|
83
|
+
* Sort by a derived value, without mutating the input.
|
|
84
|
+
*
|
|
85
|
+
* Numbers compare numerically and everything else as strings. Null and
|
|
86
|
+
* undefined keys sort last regardless of direction.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* Arrayifier.sortBy(teams, (t) => t.rating, 'desc');
|
|
90
|
+
*/
|
|
91
|
+
static sortBy<T>(arr: T[], keyFn: (item: T) => string | number | null | undefined, direction?: 'asc' | 'desc'): T[];
|
|
92
|
+
/**
|
|
93
|
+
* Split into the items that satisfy the predicate and those that do not.
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* const [wins, losses] = Arrayifier.partition(games, (g) => g.won);
|
|
97
|
+
*/
|
|
98
|
+
static partition<T>(arr: T[], predicate: (item: T, index: number) => boolean): [T[], T[]];
|
|
99
|
+
/**
|
|
100
|
+
* A sequence of numbers from `start` up to but excluding `end`.
|
|
101
|
+
*
|
|
102
|
+
* Called with one argument, counts from 0 up to it.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* Arrayifier.range(4); // [0, 1, 2, 3]
|
|
106
|
+
* Arrayifier.range(1, 4); // [1, 2, 3]
|
|
107
|
+
* Arrayifier.range(0, 10, 5); // [0, 5]
|
|
108
|
+
*/
|
|
109
|
+
static range(start: number, end?: number, step?: number): number[];
|
|
33
110
|
}
|
|
34
111
|
//# sourceMappingURL=Arrayifier.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Arrayifier.d.ts","sourceRoot":"","sources":["../../src/Arrayifier.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Arrayifier.d.ts","sourceRoot":"","sources":["../../src/Arrayifier.ts"],"names":[],"mappings":"AAkBA,qBAAa,UAAU;IAKrB;;;;QAII;WACU,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE;IAmBzC;;;;;;;;;;;;;;;OAeG;WACW,WAAW,CAAC,CAAC,EACzB,GAAG,EAAE,CAAC,EAAE,EACR,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,CAAC,EAAE,EACT,CAAC,EAAE,MAAM,EACT,OAAO,EAAE,CAAC,EAAE,EAAE,GACb,CAAC,EAAE,EAAE;IAkBR;;;;;;;;;OASG;WACW,eAAe,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,CAAC,EAAE,EAAE;IA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AAS,CAAC,CAAC,EACvB,GAAG,EAAE,CAAC,EAAE,EACR,SAAS,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,GAC7C,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;IAeb;;;;;;;;;OASG;WACW,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,IAAI,GAAE,MAAU,GAAG,MAAM,EAAE;CAsB7E"}
|
package/dist/types/CSV.d.ts
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
* Everything to help with CSV generation
|
|
3
3
|
*/
|
|
4
4
|
export declare class CSV {
|
|
5
|
+
/**
|
|
6
|
+
* Escape a single value for CSV.
|
|
7
|
+
*
|
|
8
|
+
* RFC 4180 escapes an embedded quote by doubling it, so JSON.stringify()
|
|
9
|
+
* (which uses a backslash) cannot be used here.
|
|
10
|
+
*/
|
|
11
|
+
private static escape;
|
|
12
|
+
/**
|
|
13
|
+
* Convert an object of rows into a CSV string.
|
|
14
|
+
*
|
|
15
|
+
* Headers are the union of every row's keys, so rows that carry extra
|
|
16
|
+
* columns are not silently truncated to the shape of the first row.
|
|
17
|
+
*/
|
|
18
|
+
static stringify(data: Record<string, Record<string, unknown>>): string;
|
|
5
19
|
/**
|
|
6
20
|
* Convert an object to a CSV file and then download it
|
|
7
21
|
*/
|
package/dist/types/CSV.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CSV.d.ts","sourceRoot":"","sources":["../../src/CSV.ts"],"names":[],"mappings":"AAcA;;GAEG;AACH,qBAAa,GAAG;IACd;;OAEG;WACW,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"CSV.d.ts","sourceRoot":"","sources":["../../src/CSV.ts"],"names":[],"mappings":"AAcA;;GAEG;AACH,qBAAa,GAAG;IACd;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,MAAM;IAcrB;;;;;OAKG;WACW,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,MAAM;IA6B9E;;OAEG;WACW,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI;CAgB5E"}
|
package/dist/types/Color.d.ts
CHANGED
|
@@ -76,17 +76,33 @@ export declare class Color {
|
|
|
76
76
|
* @param {string} hex
|
|
77
77
|
* @return {Array} rgb
|
|
78
78
|
*/
|
|
79
|
-
static hexToRgb(hex: string):
|
|
79
|
+
static hexToRgb(hex: string): [number, number, number];
|
|
80
80
|
/**
|
|
81
|
-
* Convert rgb to hex
|
|
81
|
+
* Convert rgb to hex.
|
|
82
|
+
*
|
|
83
|
+
* Channels are rounded and clamped to 0..255, so a value outside that range
|
|
84
|
+
* cannot overflow into the packed integer and produce a malformed string.
|
|
85
|
+
*
|
|
82
86
|
* @param {number} r
|
|
83
87
|
* @param {number} g
|
|
84
88
|
* @param {number} b
|
|
85
89
|
* @return {string}
|
|
86
90
|
*/
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
91
|
+
static rgbToHex(r: number, g: number, b: number): string;
|
|
92
|
+
/**
|
|
93
|
+
* Convert rgb to hsl, as [hue 0-360, saturation 0-100, lightness 0-100].
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* Color.rgbToHsl(255, 0, 0); // [0, 100, 50]
|
|
97
|
+
*/
|
|
98
|
+
static rgbToHsl(r: number, g: number, b: number): [number, number, number];
|
|
99
|
+
/**
|
|
100
|
+
* Convert hsl to rgb. Hue wraps, saturation and lightness are 0-100.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* Color.hslToRgb(0, 100, 50); // [255, 0, 0]
|
|
104
|
+
*/
|
|
105
|
+
static hslToRgb(h: number, s: number, l: number): [number, number, number];
|
|
90
106
|
private static calculateBrightness;
|
|
91
107
|
private static colorDistance;
|
|
92
108
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Color.d.ts","sourceRoot":"","sources":["../../src/Color.ts"],"names":[],"mappings":"AAqBA,qBAAa,KAAK;IAKhB;;;;;;;;;OASG;WACW,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM;
|
|
1
|
+
{"version":3,"file":"Color.d.ts","sourceRoot":"","sources":["../../src/Color.ts"],"names":[],"mappings":"AAqBA,qBAAa,KAAK;IAKhB;;;;;;;;;OASG;WACW,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM;IAiBrE;;OAEG;WACW,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,KAAK,UAAQ,GAAG,MAAM;WAoF3E,gBAAgB,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM;IAiBtG;;;;;OAKG;IAWH;;;;;OAKG;IAWH;;;;;;OAMG;WACW,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,GAAE,MAAY,GAAG,MAAM;IAa/D;;;;;;OAMG;WACW,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,GAAE,MAAY,GAAG,MAAM;WAalD,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM;IAW9D;;;;;;OAMG;WACW,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,SAAK,GAAG,OAAO;IAMvF;;;;OAIG;WACW,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAY9C;;;;;OAKG;WACW,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM;IAO5D;;;;OAIG;WACW,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE;IAmBvD;;;;OAIG;WACW,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;IA2B7D;;;;;;;;;;OAUG;WACW,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM;IAM/D;;;;;OAKG;WACW,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;IAyBjF;;;;;OAKG;WACW,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;IA+BjF,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAKlC,OAAO,CAAC,MAAM,CAAC,aAAa;CAU7B"}
|
package/dist/types/Dates.d.ts
CHANGED
|
@@ -45,7 +45,46 @@ export declare class Dates {
|
|
|
45
45
|
static getTodayEST(): string;
|
|
46
46
|
static getStartOfDay(date: Date | string): Date;
|
|
47
47
|
static getStartOfMonth(date: Date | string): Date;
|
|
48
|
+
/**
|
|
49
|
+
* The last representable instant of the day, 23:59:59.999 local.
|
|
50
|
+
*/
|
|
51
|
+
static getEndOfDay(date: Date | string): Date;
|
|
52
|
+
/**
|
|
53
|
+
* The last representable instant of the month.
|
|
54
|
+
*/
|
|
55
|
+
static getEndOfMonth(date: Date | string): Date;
|
|
56
|
+
/**
|
|
57
|
+
* How many days the date's month contains.
|
|
58
|
+
*/
|
|
59
|
+
static getDaysInMonth(date: Date | string): number;
|
|
48
60
|
static getStartOfGrid(date: Date | string): Date;
|
|
61
|
+
/**
|
|
62
|
+
* The Saturday closing the week that contains the end of the month.
|
|
63
|
+
*
|
|
64
|
+
* Pairs with `getStartOfGrid` to bound a full month view; feed both into
|
|
65
|
+
* `eachDayOfInterval` to get the cells.
|
|
66
|
+
*/
|
|
67
|
+
static getEndOfGrid(date: Date | string): Date;
|
|
68
|
+
/**
|
|
69
|
+
* Every day from `start` to `end` inclusive, as local midnights.
|
|
70
|
+
*
|
|
71
|
+
* Steps with setDate so it stays correct across DST boundaries. Returns an
|
|
72
|
+
* empty array when `end` falls before `start`.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* Dates.eachDayOfInterval(Dates.getStartOfGrid(d), Dates.getEndOfGrid(d));
|
|
76
|
+
*/
|
|
77
|
+
static eachDayOfInterval(start: Date | string, end: Date | string): Date[];
|
|
78
|
+
/**
|
|
79
|
+
* Whether a date falls between two others.
|
|
80
|
+
*
|
|
81
|
+
* Compares exact instants, not calendar days; pair with `getStartOfDay` and
|
|
82
|
+
* `getEndOfDay` for a whole-day range. The bounds may be given in either
|
|
83
|
+
* order.
|
|
84
|
+
*
|
|
85
|
+
* @param inclusive Whether a date landing exactly on a bound counts.
|
|
86
|
+
*/
|
|
87
|
+
static isBetween(date: Date | string, start: Date | string, end: Date | string, inclusive?: boolean): boolean;
|
|
49
88
|
static isSameDay(date1: Date | string, date2: Date | string): boolean;
|
|
50
89
|
static isBeforeDay(date1: Date | string, date2: Date | string): boolean;
|
|
51
90
|
static isAfterDay(date1: Date | string, date2: Date | string): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dates.d.ts","sourceRoot":"","sources":["../../src/Dates.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+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I,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,CAAC;KACjB;IAsCD;;;;;;OAMG;WACW,IAAI,CAChB,KAAK,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,EAC7B,KAAK,GAAE,IAAI,GAAG,MAAM,GAAG,MAAmB,EAC1C,GAAG,UAAQ,GACV;QACD,YAAY,EAAE,MAAM,CAAC;QACrB,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;QACd,GAAG,EAAE;YACH,YAAY,EAAE,MAAM,CAAC;YACrB,OAAO,EAAE,MAAM,CAAC;YAChB,OAAO,EAAE,MAAM,CAAC;YAChB,KAAK,EAAE,MAAM,CAAC;YACd,IAAI,EAAE,MAAM,CAAC;YACb,KAAK,EAAE,MAAM,CAAC;YACd,MAAM,EAAE,MAAM,CAAC;YACf,KAAK,EAAE,MAAM,CAAC;SACf,CAAA;KACF;CA2CF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Socket.d.ts","sourceRoot":"","sources":["../../../src/Kontororu/Socket.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"Socket.d.ts","sourceRoot":"","sources":["../../../src/Kontororu/Socket.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,UAAU,YAAY;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;CACd;AAID,KAAK,aAAa,GAAG;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,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"Store.d.ts","sourceRoot":"","sources":["../../../src/Kontororu/Store.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AA+DhE,qBAAa,KAAK,CAAC,MAAM,SAAS,SAAS,GAAG,SAAS,CAAE,SAAQ,SAAS;IACxE,OAAO,CAAC,KAAK,CAAwB;IAErC;;OAEG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM;IAIjB;;OAEG;IACH,GAAG,CAAC,CAAC,SAAS,MAAM,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,IAAI;IAMnG;;OAEG;IACH,IAAI,CAAC,CAAC,SAAS,MAAM,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;CA0C9G"}
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
type
|
|
1
|
+
type Listener = (...args: unknown[]) => void;
|
|
2
2
|
export declare class Kontororu extends EventTarget {
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Set membership is what keeps registration, removal and teardown O(1) per
|
|
5
|
+
* listener instead of a scan of everything registered for that type.
|
|
6
|
+
*
|
|
7
|
+
* A Map rather than an object literal because an event type is a
|
|
8
|
+
* caller-supplied string: '__proto__' on an object literal resolves to the
|
|
9
|
+
* prototype rather than to an entry of its own.
|
|
10
|
+
*/
|
|
4
11
|
private listeners;
|
|
5
|
-
addEventListener(type: string, listener:
|
|
6
|
-
removeEventListener(type: string, listener:
|
|
12
|
+
addEventListener(type: string, listener: Listener): this;
|
|
13
|
+
removeEventListener(type: string, listener: Listener): this;
|
|
7
14
|
removeAllEventListeners(): void;
|
|
8
|
-
getListeners(type: string):
|
|
15
|
+
getListeners(type: string): Listener[];
|
|
9
16
|
}
|
|
10
17
|
export {};
|
|
11
18
|
//# sourceMappingURL=Kontororu.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Kontororu.d.ts","sourceRoot":"","sources":["../../src/Kontororu.ts"],"names":[],"mappings":"AAgBA,KAAK,
|
|
1
|
+
{"version":3,"file":"Kontororu.d.ts","sourceRoot":"","sources":["../../src/Kontororu.ts"],"names":[],"mappings":"AAgBA,KAAK,QAAQ,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;AAE7C,qBAAa,SAAU,SAAQ,WAAW;IACxC;;;;;;;OAOG;IACH,OAAO,CAAC,SAAS,CAAoC;IAErD,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAkBxD,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAQ3D,uBAAuB;IAWvB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,EAAE;CAOvC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Human-readable number formatting: ranks, compact counts, percentages,
|
|
3
|
+
* durations, and file sizes.
|
|
4
|
+
*/
|
|
5
|
+
export declare class Numbers {
|
|
6
|
+
/**
|
|
7
|
+
* The English ordinal suffix for a number: 'st', 'nd', 'rd', or 'th'.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* Numbers.ordinalSuffix(1); // 'st'
|
|
11
|
+
* Numbers.ordinalSuffix(12); // 'th'
|
|
12
|
+
*/
|
|
13
|
+
static ordinalSuffix(value: number): string;
|
|
14
|
+
/**
|
|
15
|
+
* A number with its ordinal suffix attached.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* Numbers.formatOrdinal(3); // '3rd'
|
|
19
|
+
*/
|
|
20
|
+
static formatOrdinal(value: number): string;
|
|
21
|
+
/**
|
|
22
|
+
* A number with locale grouping separators.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* Numbers.format(1234567.891, 2); // '1,234,567.89'
|
|
26
|
+
*/
|
|
27
|
+
static format(value: number, decimals?: number, locale?: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* A signed number, always carrying an explicit '+' or '-'.
|
|
30
|
+
*
|
|
31
|
+
* Useful for deltas such as a change in rank or rating.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* Numbers.formatSigned(3); // '+3'
|
|
35
|
+
* Numbers.formatSigned(0); // '0'
|
|
36
|
+
*/
|
|
37
|
+
static formatSigned(value: number, decimals?: number): string;
|
|
38
|
+
/**
|
|
39
|
+
* A large number shortened with a magnitude suffix.
|
|
40
|
+
*
|
|
41
|
+
* Implemented directly rather than through Intl's compact notation, whose
|
|
42
|
+
* exact output varies with the runtime's ICU data.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* Numbers.formatCompact(1234); // '1.2K'
|
|
46
|
+
* Numbers.formatCompact(1500000); // '1.5M'
|
|
47
|
+
*/
|
|
48
|
+
static formatCompact(value: number, decimals?: number): string;
|
|
49
|
+
/**
|
|
50
|
+
* A ratio rendered as a percentage.
|
|
51
|
+
*
|
|
52
|
+
* @param fromRatio When true (the default) the input is a 0..1 ratio;
|
|
53
|
+
* when false it is already a percentage.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* Numbers.formatPercent(0.1234); // '12.3%'
|
|
57
|
+
* Numbers.formatPercent(12.34, 1, false); // '12.3%'
|
|
58
|
+
*/
|
|
59
|
+
static formatPercent(value: number, decimals?: number, fromRatio?: boolean): string;
|
|
60
|
+
/**
|
|
61
|
+
* A duration in milliseconds as a compact human string.
|
|
62
|
+
*
|
|
63
|
+
* @param parts How many magnitude units to show, largest first.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* Numbers.formatDuration(3_725_000); // '1h 2m'
|
|
67
|
+
* Numbers.formatDuration(3_725_000, 3); // '1h 2m 5s'
|
|
68
|
+
*/
|
|
69
|
+
static formatDuration(ms: number, parts?: number): string;
|
|
70
|
+
/**
|
|
71
|
+
* A byte count as a human-readable file size, using binary (1024) steps.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* Numbers.formatBytes(1536); // '1.5 KB'
|
|
75
|
+
*/
|
|
76
|
+
static formatBytes(bytes: number, decimals?: number): string;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=Numbers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Numbers.d.ts","sourceRoot":"","sources":["../../src/Numbers.ts"],"names":[],"mappings":"AAqCA;;;GAGG;AACH,qBAAa,OAAO;IAClB;;;;;;OAMG;WACW,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAwBlD;;;;;OAKG;WACW,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAMlD;;;;;OAKG;WACW,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,MAAM,GAAE,MAAgB,GAAG,MAAM;IAqBxF;;;;;;;;OAQG;WACW,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM;IAQpE;;;;;;;;;OASG;WACW,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAU,GAAG,MAAM;IAqBxE;;;;;;;;;OASG;WACW,aAAa,CACzB,KAAK,EAAE,MAAM,EACb,QAAQ,GAAE,MAAU,EACpB,SAAS,GAAE,OAAc,GACxB,MAAM;IAUT;;;;;;;;OAQG;WACW,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,GAAE,MAAU,GAAG,MAAM;IAyCnE;;;;;OAKG;WACW,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAU,GAAG,MAAM;CAsBvE"}
|
package/dist/types/Objector.d.ts
CHANGED
|
@@ -5,6 +5,20 @@ type MergeAll<T extends object[]> = T extends [infer First extends object, ...in
|
|
|
5
5
|
*/
|
|
6
6
|
export declare class Objector {
|
|
7
7
|
static deepClone<T>(obj: T, memo?: WeakMap<any, any>): T;
|
|
8
|
+
/**
|
|
9
|
+
* Structurally compares two values.
|
|
10
|
+
*
|
|
11
|
+
* Handles the same shapes `deepClone` does — Date, RegExp, Map, Set, arrays,
|
|
12
|
+
* plain objects and symbol keys — and tolerates circular references by
|
|
13
|
+
* remembering which pairs are already being compared.
|
|
14
|
+
*
|
|
15
|
+
* NaN equals NaN, and +0 does not equal -0, matching `Object.is` rather than
|
|
16
|
+
* `===`. Objects must share a prototype to be considered equal.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* Objector.deepEqual({ a: [1, { b: 2 }] }, { a: [1, { b: 2 }] }); // true
|
|
20
|
+
*/
|
|
21
|
+
static deepEqual(a: unknown, b: unknown, seen?: WeakMap<any, Set<any>>): boolean;
|
|
8
22
|
/**
|
|
9
23
|
* Deeply merges one or more source objects into a target object.
|
|
10
24
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Objector.d.ts","sourceRoot":"","sources":["../../src/Objector.ts"],"names":[],"mappings":"AAgBA,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC;AAExC,KAAK,QAAQ,CAAC,CAAC,SAAS,MAAM,EAAE,IAC9B,CA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MAAM,EAAE,CAAC,EACT,GAAG,OAAO,EAAE,CAAC,GACZ,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;CA+BvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sorter.d.ts","sourceRoot":"","sources":["../../src/Sorter.ts"],"names":[],"mappings":"AAcA;;GAEG;AACH,qBAAa,MAAM;WACH,oBAAoB,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM;
|
|
1
|
+
{"version":3,"file":"Sorter.d.ts","sourceRoot":"","sources":["../../src/Sorter.ts"],"names":[],"mappings":"AAcA;;GAEG;AACH,qBAAa,MAAM;WACH,oBAAoB,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM;WAgC1I,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,KAAK,MAAM;CAKpK"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Style.d.ts","sourceRoot":"","sources":["../../src/Style.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Style.d.ts","sourceRoot":"","sources":["../../src/Style.ts"],"names":[],"mappings":"AAsBA,KAAK,MA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+1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A debounced or throttled wrapper, plus the controls to abandon or force a
|
|
3
|
+
* pending call.
|
|
4
|
+
*/
|
|
5
|
+
export interface Scheduled<T extends (...args: any[]) => any> {
|
|
6
|
+
(...args: Parameters<T>): void;
|
|
7
|
+
/** Drop any pending call. */
|
|
8
|
+
cancel: () => void;
|
|
9
|
+
/** Run any pending call immediately. */
|
|
10
|
+
flush: () => void;
|
|
11
|
+
/** Whether a call is currently waiting to run. */
|
|
12
|
+
pending: () => boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A memoized wrapper, plus access to its cache.
|
|
16
|
+
*/
|
|
17
|
+
export interface Memoized<T extends (...args: any[]) => any> {
|
|
18
|
+
(...args: Parameters<T>): ReturnType<T>;
|
|
19
|
+
/** Forget every cached result. */
|
|
20
|
+
clear: () => void;
|
|
21
|
+
/** How many results are cached. */
|
|
22
|
+
size: () => number;
|
|
23
|
+
}
|
|
24
|
+
export interface BackoffOptions {
|
|
25
|
+
/** Delay before the first retry, in milliseconds. */
|
|
26
|
+
delay?: number;
|
|
27
|
+
/** Multiplier applied per attempt. */
|
|
28
|
+
factor?: number;
|
|
29
|
+
/** Ceiling for any single delay, in milliseconds. */
|
|
30
|
+
maxDelay?: number;
|
|
31
|
+
/** Randomize each delay across 0..computed, to avoid a thundering herd. */
|
|
32
|
+
jitter?: boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface RetryOptions extends BackoffOptions {
|
|
35
|
+
/** Total number of attempts, including the first. */
|
|
36
|
+
attempts?: number;
|
|
37
|
+
/** Called before each retry with the error and the upcoming attempt number. */
|
|
38
|
+
onRetry?: (error: unknown, attempt: number) => void;
|
|
39
|
+
/** Return false to stop retrying a particular error. */
|
|
40
|
+
shouldRetry?: (error: unknown) => boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Wrappers for controlling how and when other functions run.
|
|
44
|
+
*/
|
|
45
|
+
export declare class Tasker {
|
|
46
|
+
/**
|
|
47
|
+
* Resolve after a delay.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* await Tasker.sleep(250);
|
|
51
|
+
*/
|
|
52
|
+
static sleep(ms: number): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* The delay to wait before a given retry attempt, growing exponentially.
|
|
55
|
+
*
|
|
56
|
+
* Attempt 0 is the delay before the first retry.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* Tasker.backoff(0); // 1000
|
|
60
|
+
* Tasker.backoff(3); // 8000
|
|
61
|
+
*/
|
|
62
|
+
static backoff(attempt: number, options?: BackoffOptions): number;
|
|
63
|
+
/**
|
|
64
|
+
* Call an async function until it succeeds, backing off between attempts.
|
|
65
|
+
*
|
|
66
|
+
* Rethrows the final error once the attempts are exhausted.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* const data = await Tasker.retry(() => fetchRatings(), { attempts: 5 });
|
|
70
|
+
*/
|
|
71
|
+
static retry<T>(fn: (attempt: number) => T | Promise<T>, options?: RetryOptions): Promise<T>;
|
|
72
|
+
/**
|
|
73
|
+
* Delay a function until it has stopped being called for `wait` ms.
|
|
74
|
+
*
|
|
75
|
+
* @param leading Run on the first call instead of after the pause.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* const search = Tasker.debounce((term: string) => query(term), 300);
|
|
79
|
+
*/
|
|
80
|
+
static debounce<T extends (...args: any[]) => any>(fn: T, wait?: number, leading?: boolean): Scheduled<T>;
|
|
81
|
+
/**
|
|
82
|
+
* Allow a function to run at most once per `wait` ms.
|
|
83
|
+
*
|
|
84
|
+
* The first call runs immediately; a call made during the cooling-off period
|
|
85
|
+
* runs once the period ends, carrying the most recent arguments.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* const onScroll = Tasker.throttle(() => measure(), 100);
|
|
89
|
+
*/
|
|
90
|
+
static throttle<T extends (...args: any[]) => any>(fn: T, wait?: number): Scheduled<T>;
|
|
91
|
+
/**
|
|
92
|
+
* Cache a function's results, keyed by its arguments.
|
|
93
|
+
*
|
|
94
|
+
* The default key is a JSON serialization of the arguments, which suits
|
|
95
|
+
* primitives; pass `keyFn` for anything else.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* const ratingFor = Tasker.memoize((teamId: number) => compute(teamId));
|
|
99
|
+
*/
|
|
100
|
+
static memoize<T extends (...args: any[]) => any>(fn: T, keyFn?: (...args: Parameters<T>) => string): Memoized<T>;
|
|
101
|
+
/**
|
|
102
|
+
* Allow a function to run only once, returning the first result thereafter.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* const init = Tasker.once(() => connect());
|
|
106
|
+
*/
|
|
107
|
+
static once<T extends (...args: any[]) => any>(fn: T): (...args: Parameters<T>) => ReturnType<T>;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=Tasker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tasker.d.ts","sourceRoot":"","sources":["../../src/Tasker.ts"],"names":[],"mappings":"AAoBA;;;GAGG;AACH,MAAM,WAAW,SAAS,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG;IAC1D,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAC/B,6BAA6B;IAC7B,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,wCAAwC;IACxC,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,kDAAkD;IAClD,OAAO,EAAE,MAAM,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG;IACzD,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;IACxC,kCAAkC;IA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