@oscarpalmer/atoms 0.186.2 → 0.187.1
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/dist/array/filter.d.mts +4 -4
- package/dist/array/find.d.mts +4 -4
- package/dist/array/first.d.mts +4 -4
- package/dist/array/get.d.mts +27 -1
- package/dist/array/get.mjs +5 -3
- package/dist/array/group-by.d.mts +6 -6
- package/dist/array/last.d.mts +4 -4
- package/dist/array/match.d.mts +7 -6
- package/dist/array/move.d.mts +7 -7
- package/dist/array/move.mjs +1 -1
- package/dist/array/select.d.mts +1 -0
- package/dist/array/slice.d.mts +3 -3
- package/dist/array/sort.d.mts +10 -7
- package/dist/array/sort.mjs +4 -3
- package/dist/array/swap.d.mts +1 -1
- package/dist/array/swap.mjs +1 -1
- package/dist/array/to-map.d.mts +32 -32
- package/dist/array/to-record.d.mts +6 -6
- package/dist/array/to-set.d.mts +6 -6
- package/dist/beacon.d.mts +6 -0
- package/dist/beacon.mjs +3 -0
- package/dist/color/index.d.mts +6 -2
- package/dist/color/index.mjs +6 -2
- package/dist/color/instance.d.mts +78 -14
- package/dist/color/instance.mjs +78 -14
- package/dist/color/misc/get.d.mts +39 -11
- package/dist/color/misc/get.mjs +39 -11
- package/dist/color/misc/is.d.mts +26 -11
- package/dist/color/misc/is.mjs +26 -11
- package/dist/color/misc/state.mjs +1 -1
- package/dist/color/models.d.mts +7 -4
- package/dist/color/space/hex.d.mts +15 -6
- package/dist/color/space/hex.mjs +15 -6
- package/dist/color/space/hsl.d.mts +10 -4
- package/dist/color/space/hsl.mjs +10 -4
- package/dist/color/space/rgb.d.mts +21 -12
- package/dist/color/space/rgb.mjs +21 -12
- package/dist/function/assert.d.mts +20 -14
- package/dist/function/assert.mjs +19 -13
- package/dist/function/limit.d.mts +8 -6
- package/dist/function/limit.mjs +8 -6
- package/dist/function/memoize.d.mts +15 -4
- package/dist/function/memoize.mjs +18 -4
- package/dist/function/once.d.mts +5 -3
- package/dist/function/once.mjs +5 -3
- package/dist/function/retry.d.mts +5 -2
- package/dist/function/retry.mjs +3 -1
- package/dist/function/work.d.mts +146 -98
- package/dist/{kalas.d.mts → herald.d.mts} +17 -8
- package/dist/{kalas.mjs → herald.mjs} +22 -13
- package/dist/index.d.mts +1464 -708
- package/dist/index.mjs +703 -342
- package/dist/internal/array/index-of.d.mts +4 -4
- package/dist/internal/array/insert.mjs +1 -1
- package/dist/internal/array/shuffle.d.mts +1 -0
- package/dist/internal/array/shuffle.mjs +2 -1
- package/dist/internal/is.d.mts +26 -8
- package/dist/internal/is.mjs +26 -8
- package/dist/internal/math/aggregate.d.mts +9 -9
- package/dist/internal/number.d.mts +13 -2
- package/dist/internal/number.mjs +13 -2
- package/dist/internal/random.d.mts +4 -2
- package/dist/internal/random.mjs +7 -5
- package/dist/internal/result.d.mts +17 -11
- package/dist/internal/result.mjs +10 -14
- package/dist/internal/string.d.mts +16 -1
- package/dist/internal/string.mjs +24 -1
- package/dist/internal/value/compare.d.mts +5 -2
- package/dist/internal/value/compare.mjs +5 -2
- package/dist/internal/value/equal.d.mts +12 -3
- package/dist/internal/value/equal.mjs +7 -4
- package/dist/internal/value/get.d.mts +17 -17
- package/dist/internal/value/has.d.mts +55 -11
- package/dist/internal/value/set.d.mts +24 -0
- package/dist/internal/value/set.mjs +1 -1
- package/dist/is.d.mts +12 -0
- package/dist/is.mjs +16 -1
- package/dist/logger.d.mts +7 -6
- package/dist/logger.mjs +6 -5
- package/dist/math.d.mts +36 -18
- package/dist/math.mjs +6 -3
- package/dist/models.d.mts +3 -3
- package/dist/promise/delay.d.mts +2 -0
- package/dist/promise/helpers.d.mts +6 -4
- package/dist/promise/helpers.mjs +6 -4
- package/dist/promise/index.d.mts +49 -38
- package/dist/promise/misc.d.mts +10 -7
- package/dist/promise/misc.mjs +4 -3
- package/dist/promise/models.d.mts +18 -19
- package/dist/promise/models.mjs +4 -3
- package/dist/promise/timed.d.mts +8 -6
- package/dist/query.d.mts +2 -0
- package/dist/query.mjs +27 -17
- package/dist/queue.d.mts +15 -4
- package/dist/queue.mjs +10 -3
- package/dist/random.d.mts +9 -2
- package/dist/random.mjs +7 -2
- package/dist/result/index.d.mts +14 -8
- package/dist/result/match.d.mts +18 -10
- package/dist/result/misc.d.mts +14 -7
- package/dist/result/misc.mjs +4 -2
- package/dist/result/models.d.mts +2 -0
- package/dist/result/work/flow.d.mts +86 -62
- package/dist/result/work/pipe.d.mts +55 -33
- package/dist/sized/map.d.mts +19 -16
- package/dist/sized/map.mjs +4 -4
- package/dist/sized/set.d.mts +20 -16
- package/dist/sized/set.mjs +8 -7
- package/dist/string/case.d.mts +8 -0
- package/dist/string/case.mjs +8 -0
- package/dist/string/fuzzy.d.mts +19 -5
- package/dist/string/fuzzy.mjs +7 -0
- package/dist/string/index.d.mts +17 -2
- package/dist/string/index.mjs +7 -9
- package/dist/string/match.d.mts +3 -0
- package/dist/string/match.mjs +3 -0
- package/dist/string/normalize.d.mts +6 -2
- package/dist/string/normalize.mjs +5 -2
- package/dist/string/template.d.mts +38 -9
- package/dist/string/template.mjs +19 -19
- package/dist/value/clone.d.mts +25 -4
- package/dist/value/clone.mjs +36 -22
- package/dist/value/collection.d.mts +9 -6
- package/dist/value/collection.mjs +3 -2
- package/dist/value/diff.d.mts +3 -1
- package/dist/value/diff.mjs +1 -0
- package/dist/value/freeze.d.mts +118 -9
- package/dist/value/freeze.mjs +56 -14
- package/dist/value/index.d.mts +1 -2
- package/dist/value/index.mjs +1 -2
- package/dist/value/merge.d.mts +11 -5
- package/dist/value/merge.mjs +2 -2
- package/dist/value/omit.d.mts +1 -0
- package/dist/value/omit.mjs +1 -0
- package/dist/value/pick.d.mts +1 -0
- package/dist/value/pick.mjs +1 -0
- package/dist/value/shake.d.mts +1 -0
- package/dist/value/shake.mjs +1 -0
- package/dist/value/smush.d.mts +1 -0
- package/dist/value/smush.mjs +1 -0
- package/dist/value/transform.d.mts +7 -3
- package/dist/value/unsmush.d.mts +1 -0
- package/dist/value/unsmush.mjs +1 -0
- package/package.json +12 -8
- package/src/array/filter.ts +4 -4
- package/src/array/find.ts +4 -4
- package/src/array/first.ts +4 -4
- package/src/array/get.ts +40 -5
- package/src/array/group-by.ts +6 -6
- package/src/array/last.ts +4 -4
- package/src/array/match.ts +7 -6
- package/src/array/move.ts +7 -7
- package/src/array/select.ts +1 -0
- package/src/array/slice.ts +3 -3
- package/src/array/sort.ts +15 -10
- package/src/array/swap.ts +1 -1
- package/src/array/to-map.ts +32 -32
- package/src/array/to-record.ts +6 -6
- package/src/array/to-set.ts +6 -6
- package/src/beacon.ts +6 -0
- package/src/color/index.ts +6 -2
- package/src/color/instance.ts +78 -14
- package/src/color/misc/get.ts +39 -11
- package/src/color/misc/is.ts +26 -11
- package/src/color/misc/state.ts +1 -1
- package/src/color/models.ts +7 -4
- package/src/color/space/hex.ts +15 -6
- package/src/color/space/hsl.ts +10 -4
- package/src/color/space/rgb.ts +21 -12
- package/src/function/assert.ts +20 -14
- package/src/function/limit.ts +8 -6
- package/src/function/memoize.ts +24 -5
- package/src/function/once.ts +5 -3
- package/src/function/retry.ts +7 -3
- package/src/function/work.ts +146 -98
- package/src/{kalas.ts → herald.ts} +23 -14
- package/src/index.ts +3 -2
- package/src/internal/array/index-of.ts +4 -4
- package/src/internal/array/insert.ts +1 -1
- package/src/internal/array/shuffle.ts +2 -1
- package/src/internal/is.ts +26 -8
- package/src/internal/math/aggregate.ts +9 -9
- package/src/internal/number.ts +13 -2
- package/src/internal/random.ts +10 -4
- package/src/internal/result.ts +30 -29
- package/src/internal/string.ts +28 -0
- package/src/internal/value/compare.ts +5 -2
- package/src/internal/value/equal.ts +13 -4
- package/src/internal/value/get.ts +17 -17
- package/src/internal/value/has.ts +54 -11
- package/src/internal/value/set.ts +25 -1
- package/src/is.ts +15 -1
- package/src/logger.ts +8 -7
- package/src/math.ts +36 -18
- package/src/models.ts +3 -3
- package/src/promise/delay.ts +2 -0
- package/src/promise/helpers.ts +6 -4
- package/src/promise/index.ts +49 -38
- package/src/promise/misc.ts +10 -7
- package/src/promise/models.ts +18 -19
- package/src/promise/timed.ts +8 -6
- package/src/query.ts +39 -28
- package/src/queue.ts +15 -4
- package/src/random.ts +8 -1
- package/src/result/index.ts +14 -8
- package/src/result/match.ts +18 -10
- package/src/result/misc.ts +17 -9
- package/src/result/models.ts +2 -0
- package/src/result/work/flow.ts +86 -62
- package/src/result/work/pipe.ts +55 -33
- package/src/sized/map.ts +20 -17
- package/src/sized/set.ts +21 -17
- package/src/string/case.ts +8 -0
- package/src/string/fuzzy.ts +19 -5
- package/src/string/index.ts +18 -15
- package/src/string/match.ts +3 -0
- package/src/string/normalize.ts +6 -2
- package/src/string/template.ts +69 -18
- package/src/value/clone.ts +51 -26
- package/src/value/collection.ts +9 -6
- package/src/value/diff.ts +3 -1
- package/src/value/freeze.ts +239 -25
- package/src/value/index.ts +0 -1
- package/src/value/merge.ts +11 -5
- package/src/value/omit.ts +1 -0
- package/src/value/pick.ts +1 -0
- package/src/value/shake.ts +1 -0
- package/src/value/smush.ts +1 -0
- package/src/value/transform.ts +7 -3
- package/src/value/unsmush.ts +1 -0
package/dist/color/space/hsl.mjs
CHANGED
|
@@ -31,9 +31,12 @@ function hslToHex(hsl, alpha) {
|
|
|
31
31
|
return convertRgbToHex(convertHslToRgba(hsl), alpha ?? false);
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
|
-
* Convert an
|
|
34
|
+
* Convert an _HSL(A)_ color to an _RGB_ color
|
|
35
|
+
*
|
|
36
|
+
* _If the value is unable to be converted, a black RGB color will be returned_
|
|
37
|
+
*
|
|
38
|
+
* _Thanks, https://github.com/color-js/color.js/blob/main/src/spaces/hsl.js#L61_
|
|
35
39
|
*
|
|
36
|
-
* Thanks, https://github.com/color-js/color.js/blob/main/src/spaces/hsl.js#L61
|
|
37
40
|
* @param hsl HSL(A) color
|
|
38
41
|
* @returns RGB color
|
|
39
42
|
*/
|
|
@@ -46,9 +49,12 @@ function hslToRgb(hsl) {
|
|
|
46
49
|
};
|
|
47
50
|
}
|
|
48
51
|
/**
|
|
49
|
-
* Convert an
|
|
52
|
+
* Convert an _HSL(A)_ color to an _RGBA_ color
|
|
53
|
+
*
|
|
54
|
+
* _If the value is unable to be converted, a black RGBA color with an alpha channel (opactiy) of `0` will be returned_
|
|
55
|
+
*
|
|
56
|
+
* _Thanks, https://github.com/color-js/color.js/blob/main/src/spaces/hsl.js#L61_
|
|
50
57
|
*
|
|
51
|
-
* Thanks, https://github.com/color-js/color.js/blob/main/src/spaces/hsl.js#L61
|
|
52
58
|
* @param hsl HSL(A) color
|
|
53
59
|
* @returns RGBA color
|
|
54
60
|
*/
|
|
@@ -5,26 +5,35 @@ declare function convertRgbToHex(rgb: RGBAColor | RGBColor, alpha: boolean): str
|
|
|
5
5
|
declare function convertRgbToHsla(value: unknown): HSLAColor;
|
|
6
6
|
declare function getRgbValue(value: Record<keyof RGBColor, unknown>): RGBColor;
|
|
7
7
|
/**
|
|
8
|
-
* Convert an
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
8
|
+
* Convert an _RGB(A)_ color to a hex color _(with optional alpha channel, i.e., opacity)_
|
|
9
|
+
*
|
|
10
|
+
* _If the value is unable to be converted, a black hex color will be returned_
|
|
11
|
+
*
|
|
12
|
+
* @param rgb _RGB(A)_ color
|
|
13
|
+
* @param alpha Include alpha channel _(opacity)_? _(defaults to `false`)_
|
|
14
|
+
* @returns Hex color string
|
|
12
15
|
*/
|
|
13
16
|
declare function rgbToHex(rgb: RGBAColor | RGBColor, alpha?: boolean): string;
|
|
14
17
|
/**
|
|
15
|
-
* Convert an
|
|
18
|
+
* Convert an _RGB(A)_ color to an _HSL_ color
|
|
19
|
+
*
|
|
20
|
+
* _If the value is unable to be converted, a black HSL color will be returned_
|
|
16
21
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* @
|
|
22
|
+
* _Thanks, https://github.com/color-js/color.js/blob/main/src/spaces/hsl.js#L26_
|
|
23
|
+
*
|
|
24
|
+
* @param rgb _RGB(A)_ color
|
|
25
|
+
* @returns _HSL_ color
|
|
20
26
|
*/
|
|
21
27
|
declare function rgbToHsl(rgb: RGBAColor | RGBColor): HSLColor;
|
|
22
28
|
/**
|
|
23
|
-
* Convert an
|
|
29
|
+
* Convert an _RGB(A)_ color to an _HSLA_ color
|
|
30
|
+
*
|
|
31
|
+
* _If the value is unable to be converted, a black _HSLA_ color with an alpha channel (opacity) of `0` will be returned_
|
|
32
|
+
*
|
|
33
|
+
* _Thanks, https://github.com/color-js/color.js/blob/main/src/spaces/hsl.js#L26_
|
|
24
34
|
*
|
|
25
|
-
*
|
|
26
|
-
* @
|
|
27
|
-
* @returns HSLA color
|
|
35
|
+
* @param rgb _RGB(A)_ color
|
|
36
|
+
* @returns _HSLA_ color
|
|
28
37
|
*/
|
|
29
38
|
declare function rgbToHsla(rgb: RGBAColor | RGBColor): HSLAColor;
|
|
30
39
|
//#endregion
|
package/dist/color/space/rgb.mjs
CHANGED
|
@@ -58,20 +58,26 @@ function getRgbValue(value) {
|
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
60
|
/**
|
|
61
|
-
* Convert an
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
61
|
+
* Convert an _RGB(A)_ color to a hex color _(with optional alpha channel, i.e., opacity)_
|
|
62
|
+
*
|
|
63
|
+
* _If the value is unable to be converted, a black hex color will be returned_
|
|
64
|
+
*
|
|
65
|
+
* @param rgb _RGB(A)_ color
|
|
66
|
+
* @param alpha Include alpha channel _(opacity)_? _(defaults to `false`)_
|
|
67
|
+
* @returns Hex color string
|
|
65
68
|
*/
|
|
66
69
|
function rgbToHex(rgb, alpha) {
|
|
67
70
|
return convertRgbToHex(isRgbLike(rgb) ? getRgbValue(rgb) : { ...DEFAULT_RGB }, alpha ?? false);
|
|
68
71
|
}
|
|
69
72
|
/**
|
|
70
|
-
* Convert an
|
|
73
|
+
* Convert an _RGB(A)_ color to an _HSL_ color
|
|
74
|
+
*
|
|
75
|
+
* _If the value is unable to be converted, a black HSL color will be returned_
|
|
71
76
|
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
* @
|
|
77
|
+
* _Thanks, https://github.com/color-js/color.js/blob/main/src/spaces/hsl.js#L26_
|
|
78
|
+
*
|
|
79
|
+
* @param rgb _RGB(A)_ color
|
|
80
|
+
* @returns _HSL_ color
|
|
75
81
|
*/
|
|
76
82
|
function rgbToHsl(rgb) {
|
|
77
83
|
const { hue, lightness, saturation } = convertRgbToHsla(rgb);
|
|
@@ -82,11 +88,14 @@ function rgbToHsl(rgb) {
|
|
|
82
88
|
};
|
|
83
89
|
}
|
|
84
90
|
/**
|
|
85
|
-
* Convert an
|
|
91
|
+
* Convert an _RGB(A)_ color to an _HSLA_ color
|
|
92
|
+
*
|
|
93
|
+
* _If the value is unable to be converted, a black _HSLA_ color with an alpha channel (opacity) of `0` will be returned_
|
|
94
|
+
*
|
|
95
|
+
* _Thanks, https://github.com/color-js/color.js/blob/main/src/spaces/hsl.js#L26_
|
|
86
96
|
*
|
|
87
|
-
*
|
|
88
|
-
* @
|
|
89
|
-
* @returns HSLA color
|
|
97
|
+
* @param rgb _RGB(A)_ color
|
|
98
|
+
* @returns _HSLA_ color
|
|
90
99
|
*/
|
|
91
100
|
function rgbToHsla(rgb) {
|
|
92
101
|
return convertRgbToHsla(rgb);
|
|
@@ -2,7 +2,7 @@ import { Constructor, NestedKeys, NestedValue, PlainObject } from "../models.mjs
|
|
|
2
2
|
|
|
3
3
|
//#region src/function/assert.d.ts
|
|
4
4
|
/**
|
|
5
|
-
* Asserter for a
|
|
5
|
+
* Asserter for a property of a value
|
|
6
6
|
*/
|
|
7
7
|
type AssertProperty<Value extends PlainObject, Path extends NestedKeys<Value>, Asserted extends NestedPick<Value, Path> = NestedPick<Value, Path>> = Asserter<Asserted>;
|
|
8
8
|
/**
|
|
@@ -12,6 +12,7 @@ type Asserter<Value> = (value: unknown) => asserts value is Value;
|
|
|
12
12
|
type NestedPick<Value, Path extends string> = Value extends PlainObject ? Path extends `${infer Head}.${infer Rest}` ? Head extends keyof Value ? { [Key in Head]: NestedPick<Value[Key], Rest> } : never : Path extends keyof Value ? { [Key in Path]: Value[Key] } : never : never;
|
|
13
13
|
/**
|
|
14
14
|
* Asserts that a condition is true, throwing an error if it is not
|
|
15
|
+
*
|
|
15
16
|
* @param condition Condition to assert
|
|
16
17
|
* @param message Error message
|
|
17
18
|
* @param error Error constructor _(defaults to `Error`)_
|
|
@@ -25,53 +26,58 @@ declare namespace assert {
|
|
|
25
26
|
var property: typeof assertProperty;
|
|
26
27
|
}
|
|
27
28
|
/**
|
|
28
|
-
* Creates an
|
|
29
|
+
* Creates an _Asserter_ that asserts a condition is true, throwing an error if it is not
|
|
30
|
+
*
|
|
31
|
+
* _Available as `assertCondition` and `assert.condition`_
|
|
29
32
|
*
|
|
30
|
-
* Available as `assertCondition` and `assert.condition`
|
|
31
33
|
* @param condition Condition to assert
|
|
32
34
|
* @param message Error message
|
|
33
35
|
* @param error Error constructor _(defaults to `Error`)_
|
|
34
|
-
* @returns
|
|
36
|
+
* @returns _Asserter_
|
|
35
37
|
*/
|
|
36
38
|
declare function assertCondition<Value>(condition: (value: unknown) => boolean, message: string, error?: ErrorConstructor): Asserter<Value>;
|
|
37
39
|
/**
|
|
38
40
|
* Asserts that a value is defined, throwing an error if it is not
|
|
39
41
|
*
|
|
40
|
-
*
|
|
42
|
+
* _Available as `assertDefined` and `assert.defined`_
|
|
43
|
+
*
|
|
41
44
|
* @param value Value to assert
|
|
42
45
|
* @param message Error message
|
|
43
46
|
* @param error Error constructor _(defaults to `Error`)_
|
|
44
47
|
*/
|
|
45
48
|
declare function assertDefined<Value>(value: unknown, message?: string, error?: ErrorConstructor): asserts value is Exclude<Value, null | undefined>;
|
|
46
49
|
/**
|
|
47
|
-
* Creates an
|
|
50
|
+
* Creates an _Asserter_ that asserts a value is an instance of a constructor, throwing an error if it is not
|
|
51
|
+
*
|
|
52
|
+
* _Available as `assertInstanceOf` and `assert.instanceOf`_
|
|
48
53
|
*
|
|
49
|
-
* Available as `assertInstanceOf` and `assert.instanceOf`
|
|
50
54
|
* @param constructor Constructor to check against
|
|
51
55
|
* @param message Error message
|
|
52
56
|
* @param error Error constructor _(defaults to `Error`)_
|
|
53
|
-
* @returns
|
|
57
|
+
* @returns _Asserter_
|
|
54
58
|
*/
|
|
55
59
|
declare function assertInstanceOf<Value>(constructor: Constructor<Value>, message: string, error?: ErrorConstructor): Asserter<Value>;
|
|
56
60
|
/**
|
|
57
|
-
* Creates an
|
|
61
|
+
* Creates an _Asserter_ that asserts a value is of a specific type, throwing an error if it is not
|
|
62
|
+
*
|
|
63
|
+
* _Available as `assertIs` and `assert.is`_
|
|
58
64
|
*
|
|
59
|
-
* Available as `assertIs` and `assert.is`
|
|
60
65
|
* @param condition Type guard function to check the value
|
|
61
66
|
* @param message Error message
|
|
62
67
|
* @param error Error constructor _(defaults to `Error`)_
|
|
63
|
-
* @returns
|
|
68
|
+
* @returns _Asserter_
|
|
64
69
|
*/
|
|
65
70
|
declare function assertIs<Value>(condition: (value: unknown) => value is Value, message: string, error?: ErrorConstructor): Asserter<Value>;
|
|
66
71
|
/**
|
|
67
|
-
* Creates an
|
|
72
|
+
* Creates an _Asserter_ that asserts a property of a value exists and satisfies a condition, throwing an error if it does not
|
|
73
|
+
*
|
|
74
|
+
* _Available as `assertProperty` and `assert.property`_
|
|
68
75
|
*
|
|
69
|
-
* Available as `assertProperty` and `assert.property`
|
|
70
76
|
* @param path Path to the property to check, e.g., `foo.bar.baz` for a nested property
|
|
71
77
|
* @param condition Condition to assert for the property
|
|
72
78
|
* @param message Error message
|
|
73
79
|
* @param error Error constructor _(defaults to `Error`)_
|
|
74
|
-
* @returns
|
|
80
|
+
* @returns _Asserter_
|
|
75
81
|
*/
|
|
76
82
|
declare function assertProperty<Value extends PlainObject, Path extends NestedKeys<Value>, Asserted = NestedPick<Value, Path>>(path: Path, condition: (value: NestedValue<Value, Path>) => boolean, message: string, error?: ErrorConstructor): Asserter<Asserted>;
|
|
77
83
|
//#endregion
|
package/dist/function/assert.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import { hasValueResult } from "../internal/value/has.mjs";
|
|
|
2
2
|
//#region src/function/assert.ts
|
|
3
3
|
/**
|
|
4
4
|
* Asserts that a condition is true, throwing an error if it is not
|
|
5
|
+
*
|
|
5
6
|
* @param condition Condition to assert
|
|
6
7
|
* @param message Error message
|
|
7
8
|
* @param error Error constructor _(defaults to `Error`)_
|
|
@@ -15,13 +16,14 @@ assert.instanceOf = assertInstanceOf;
|
|
|
15
16
|
assert.is = assertIs;
|
|
16
17
|
assert.property = assertProperty;
|
|
17
18
|
/**
|
|
18
|
-
* Creates an
|
|
19
|
+
* Creates an _Asserter_ that asserts a condition is true, throwing an error if it is not
|
|
20
|
+
*
|
|
21
|
+
* _Available as `assertCondition` and `assert.condition`_
|
|
19
22
|
*
|
|
20
|
-
* Available as `assertCondition` and `assert.condition`
|
|
21
23
|
* @param condition Condition to assert
|
|
22
24
|
* @param message Error message
|
|
23
25
|
* @param error Error constructor _(defaults to `Error`)_
|
|
24
|
-
* @returns
|
|
26
|
+
* @returns _Asserter_
|
|
25
27
|
*/
|
|
26
28
|
function assertCondition(condition, message, error) {
|
|
27
29
|
return (value) => {
|
|
@@ -31,7 +33,8 @@ function assertCondition(condition, message, error) {
|
|
|
31
33
|
/**
|
|
32
34
|
* Asserts that a value is defined, throwing an error if it is not
|
|
33
35
|
*
|
|
34
|
-
*
|
|
36
|
+
* _Available as `assertDefined` and `assert.defined`_
|
|
37
|
+
*
|
|
35
38
|
* @param value Value to assert
|
|
36
39
|
* @param message Error message
|
|
37
40
|
* @param error Error constructor _(defaults to `Error`)_
|
|
@@ -40,13 +43,14 @@ function assertDefined(value, message, error) {
|
|
|
40
43
|
assert(() => value != null, message ?? MESSAGE_VALUE_DEFINED, error);
|
|
41
44
|
}
|
|
42
45
|
/**
|
|
43
|
-
* Creates an
|
|
46
|
+
* Creates an _Asserter_ that asserts a value is an instance of a constructor, throwing an error if it is not
|
|
47
|
+
*
|
|
48
|
+
* _Available as `assertInstanceOf` and `assert.instanceOf`_
|
|
44
49
|
*
|
|
45
|
-
* Available as `assertInstanceOf` and `assert.instanceOf`
|
|
46
50
|
* @param constructor Constructor to check against
|
|
47
51
|
* @param message Error message
|
|
48
52
|
* @param error Error constructor _(defaults to `Error`)_
|
|
49
|
-
* @returns
|
|
53
|
+
* @returns _Asserter_
|
|
50
54
|
*/
|
|
51
55
|
function assertInstanceOf(constructor, message, error) {
|
|
52
56
|
return (value) => {
|
|
@@ -54,13 +58,14 @@ function assertInstanceOf(constructor, message, error) {
|
|
|
54
58
|
};
|
|
55
59
|
}
|
|
56
60
|
/**
|
|
57
|
-
* Creates an
|
|
61
|
+
* Creates an _Asserter_ that asserts a value is of a specific type, throwing an error if it is not
|
|
62
|
+
*
|
|
63
|
+
* _Available as `assertIs` and `assert.is`_
|
|
58
64
|
*
|
|
59
|
-
* Available as `assertIs` and `assert.is`
|
|
60
65
|
* @param condition Type guard function to check the value
|
|
61
66
|
* @param message Error message
|
|
62
67
|
* @param error Error constructor _(defaults to `Error`)_
|
|
63
|
-
* @returns
|
|
68
|
+
* @returns _Asserter_
|
|
64
69
|
*/
|
|
65
70
|
function assertIs(condition, message, error) {
|
|
66
71
|
return (value) => {
|
|
@@ -68,14 +73,15 @@ function assertIs(condition, message, error) {
|
|
|
68
73
|
};
|
|
69
74
|
}
|
|
70
75
|
/**
|
|
71
|
-
* Creates an
|
|
76
|
+
* Creates an _Asserter_ that asserts a property of a value exists and satisfies a condition, throwing an error if it does not
|
|
77
|
+
*
|
|
78
|
+
* _Available as `assertProperty` and `assert.property`_
|
|
72
79
|
*
|
|
73
|
-
* Available as `assertProperty` and `assert.property`
|
|
74
80
|
* @param path Path to the property to check, e.g., `foo.bar.baz` for a nested property
|
|
75
81
|
* @param condition Condition to assert for the property
|
|
76
82
|
* @param message Error message
|
|
77
83
|
* @param error Error constructor _(defaults to `Error`)_
|
|
78
|
-
* @returns
|
|
84
|
+
* @returns _Asserter_
|
|
79
85
|
*/
|
|
80
86
|
function assertProperty(path, condition, message, error) {
|
|
81
87
|
return (value) => {
|
|
@@ -4,11 +4,11 @@ import { AsyncCancelableCallback, CancelableCallback, GenericAsyncCallback, Gene
|
|
|
4
4
|
/**
|
|
5
5
|
* Debounce a function, ensuring it is only called after `time` milliseconds have passed
|
|
6
6
|
*
|
|
7
|
-
* When called, successful _(finished)_ results will resolve and errors will reject
|
|
7
|
+
* - When called, successful _(finished)_ results will resolve and errors will reject
|
|
8
|
+
* - On subsequent calls, existing calls will be canceled _(rejected)_, the timer reset, and will wait another `time` milliseconds before the new call is made _(and so on...)_
|
|
8
9
|
*
|
|
9
|
-
*
|
|
10
|
+
* _Available as `asyncDebounce` and `debounce.async`_
|
|
10
11
|
*
|
|
11
|
-
* Available as `asyncDebounce` and `debounce.async`
|
|
12
12
|
* @param callback Callback to debounce
|
|
13
13
|
* @param time Time in milliseconds to wait before calling the callback _(defaults to `0`; e.g., as soon as possible)_
|
|
14
14
|
* @returns Debounced callback handler with a `cancel` method
|
|
@@ -17,11 +17,11 @@ declare function asyncDebounce<Callback extends GenericAsyncCallback | GenericCa
|
|
|
17
17
|
/**
|
|
18
18
|
* Throttle a function, ensuring it is only called once every `time` milliseconds
|
|
19
19
|
*
|
|
20
|
-
* When called, successful _(finished)_ results will resolve and errors will reject
|
|
20
|
+
* - When called, successful _(finished)_ results will resolve and errors will reject
|
|
21
|
+
* - On subsequent calls, existing calls will be canceled _(rejected)_ and will wait until the next valid time to call the callback again _(and so on...)_
|
|
21
22
|
*
|
|
22
|
-
*
|
|
23
|
+
* _Available as `asyncThrottle` and `throttle.async`_
|
|
23
24
|
*
|
|
24
|
-
* Available as `asyncThrottle` and `throttle.async`
|
|
25
25
|
* @param callback Callback to throttle
|
|
26
26
|
* @param time Time in milliseconds to wait before calling the callback again _(defaults to `0`; e.g., as soon as possible)_
|
|
27
27
|
* @returns Throttled callback handler with a `cancel` method
|
|
@@ -31,6 +31,7 @@ declare function asyncThrottle<Callback extends GenericAsyncCallback | GenericCa
|
|
|
31
31
|
* Debounce a function, ensuring it is only called after `time` milliseconds have passed
|
|
32
32
|
*
|
|
33
33
|
* On subsequent calls, the timer is reset and will wait another `time` milliseconds _(and so on...)_
|
|
34
|
+
*
|
|
34
35
|
* @param callback Callback to debounce
|
|
35
36
|
* @param time Time in milliseconds to wait before calling the callback _(defaults to `0`; e.g., as soon as possible)_
|
|
36
37
|
* @returns Debounced callback handler with a `cancel` method
|
|
@@ -41,6 +42,7 @@ declare namespace debounce {
|
|
|
41
42
|
}
|
|
42
43
|
/**
|
|
43
44
|
* Throttle a function, ensuring it is only called once every `time` milliseconds
|
|
45
|
+
*
|
|
44
46
|
* @param callback Callback to throttle
|
|
45
47
|
* @param time Time in milliseconds to wait before calling the callback again _(defaults to `0`; e.g., as soon as possible)_
|
|
46
48
|
* @returns Throttled callback handler with a `cancel` method
|
package/dist/function/limit.mjs
CHANGED
|
@@ -3,11 +3,11 @@ import { TIMER_DEBOUNCE, TIMER_THROTTLE, getAsyncTimer, getTimer } from "../inte
|
|
|
3
3
|
/**
|
|
4
4
|
* Debounce a function, ensuring it is only called after `time` milliseconds have passed
|
|
5
5
|
*
|
|
6
|
-
* When called, successful _(finished)_ results will resolve and errors will reject
|
|
6
|
+
* - When called, successful _(finished)_ results will resolve and errors will reject
|
|
7
|
+
* - On subsequent calls, existing calls will be canceled _(rejected)_, the timer reset, and will wait another `time` milliseconds before the new call is made _(and so on...)_
|
|
7
8
|
*
|
|
8
|
-
*
|
|
9
|
+
* _Available as `asyncDebounce` and `debounce.async`_
|
|
9
10
|
*
|
|
10
|
-
* Available as `asyncDebounce` and `debounce.async`
|
|
11
11
|
* @param callback Callback to debounce
|
|
12
12
|
* @param time Time in milliseconds to wait before calling the callback _(defaults to `0`; e.g., as soon as possible)_
|
|
13
13
|
* @returns Debounced callback handler with a `cancel` method
|
|
@@ -18,11 +18,11 @@ function asyncDebounce(callback, time) {
|
|
|
18
18
|
/**
|
|
19
19
|
* Throttle a function, ensuring it is only called once every `time` milliseconds
|
|
20
20
|
*
|
|
21
|
-
* When called, successful _(finished)_ results will resolve and errors will reject
|
|
21
|
+
* - When called, successful _(finished)_ results will resolve and errors will reject
|
|
22
|
+
* - On subsequent calls, existing calls will be canceled _(rejected)_ and will wait until the next valid time to call the callback again _(and so on...)_
|
|
22
23
|
*
|
|
23
|
-
*
|
|
24
|
+
* _Available as `asyncThrottle` and `throttle.async`_
|
|
24
25
|
*
|
|
25
|
-
* Available as `asyncThrottle` and `throttle.async`
|
|
26
26
|
* @param callback Callback to throttle
|
|
27
27
|
* @param time Time in milliseconds to wait before calling the callback again _(defaults to `0`; e.g., as soon as possible)_
|
|
28
28
|
* @returns Throttled callback handler with a `cancel` method
|
|
@@ -34,6 +34,7 @@ function asyncThrottle(callback, time) {
|
|
|
34
34
|
* Debounce a function, ensuring it is only called after `time` milliseconds have passed
|
|
35
35
|
*
|
|
36
36
|
* On subsequent calls, the timer is reset and will wait another `time` milliseconds _(and so on...)_
|
|
37
|
+
*
|
|
37
38
|
* @param callback Callback to debounce
|
|
38
39
|
* @param time Time in milliseconds to wait before calling the callback _(defaults to `0`; e.g., as soon as possible)_
|
|
39
40
|
* @returns Debounced callback handler with a `cancel` method
|
|
@@ -44,6 +45,7 @@ function debounce(callback, time) {
|
|
|
44
45
|
debounce.async = asyncDebounce;
|
|
45
46
|
/**
|
|
46
47
|
* Throttle a function, ensuring it is only called once every `time` milliseconds
|
|
48
|
+
*
|
|
47
49
|
* @param callback Callback to throttle
|
|
48
50
|
* @param time Time in milliseconds to wait before calling the callback again _(defaults to `0`; e.g., as soon as possible)_
|
|
49
51
|
* @returns Throttled callback handler with a `cancel` method
|
|
@@ -2,16 +2,20 @@ import { GenericCallback } from "../models.mjs";
|
|
|
2
2
|
|
|
3
3
|
//#region src/function/memoize.d.ts
|
|
4
4
|
/**
|
|
5
|
-
* A
|
|
5
|
+
* A _Memoized_ function instance, caching and retrieving results based on the its parameters _(or a custom cache key)_
|
|
6
6
|
*/
|
|
7
7
|
declare class Memoized<Callback extends GenericCallback> {
|
|
8
8
|
#private;
|
|
9
9
|
/**
|
|
10
10
|
* Maximum cache size
|
|
11
|
+
*
|
|
12
|
+
* @returns Maximum cache size _(or `Number.NaN` if the instance has been destroyed)_
|
|
11
13
|
*/
|
|
12
14
|
get maximum(): number;
|
|
13
15
|
/**
|
|
14
16
|
* Current cache size
|
|
17
|
+
*
|
|
18
|
+
* @returns Current cache size _(or `Number.NaN` if the instance has been destroyed)_
|
|
15
19
|
*/
|
|
16
20
|
get size(): number;
|
|
17
21
|
constructor(callback: Callback, options: Options);
|
|
@@ -21,35 +25,41 @@ declare class Memoized<Callback extends GenericCallback> {
|
|
|
21
25
|
clear(): void;
|
|
22
26
|
/**
|
|
23
27
|
* Delete a result from the cache
|
|
28
|
+
*
|
|
24
29
|
* @param key Key to delete
|
|
25
30
|
* @returns `true` if the key existed and was removed, otherwise `false`
|
|
26
31
|
*/
|
|
27
32
|
delete(key: unknown): boolean;
|
|
28
33
|
/**
|
|
29
|
-
* Destroy the instance
|
|
34
|
+
* Destroy the instance
|
|
35
|
+
*
|
|
36
|
+
* _(When a Memoized instance is destroyed, its cache and callback are removed, and calls to `run` will throw an error)_
|
|
30
37
|
*/
|
|
31
38
|
destroy(): void;
|
|
32
39
|
/**
|
|
33
40
|
* Get a result from the cache
|
|
41
|
+
*
|
|
34
42
|
* @param key Key to get
|
|
35
43
|
* @returns Cached result or `undefined` if it does not exist
|
|
36
44
|
*/
|
|
37
45
|
get(key: unknown): ReturnType<Callback> | undefined;
|
|
38
46
|
/**
|
|
39
47
|
* Does the result exist?
|
|
48
|
+
*
|
|
40
49
|
* @param key Key to check
|
|
41
50
|
* @returns `true` if the result exists, otherwise `false`
|
|
42
51
|
*/
|
|
43
52
|
has(key: unknown): boolean;
|
|
44
53
|
/**
|
|
45
54
|
* Run the callback with the provided parameters
|
|
55
|
+
*
|
|
46
56
|
* @param parameters Parameters to pass to the callback
|
|
47
57
|
* @returns Cached or computed _(then cached)_ result
|
|
48
58
|
*/
|
|
49
59
|
run(...parameters: Parameters<Callback>): ReturnType<Callback>;
|
|
50
60
|
}
|
|
51
61
|
/**
|
|
52
|
-
* Options for
|
|
62
|
+
* Options for a _Memoized_ function
|
|
53
63
|
*/
|
|
54
64
|
type MemoizedOptions<Callback extends GenericCallback> = {
|
|
55
65
|
/**
|
|
@@ -67,9 +77,10 @@ type Options = {
|
|
|
67
77
|
};
|
|
68
78
|
/**
|
|
69
79
|
* Memoize a function, caching and retrieving results based on the first parameter
|
|
80
|
+
*
|
|
70
81
|
* @param callback Callback to memoize
|
|
71
82
|
* @param options Memoization options
|
|
72
|
-
* @returns
|
|
83
|
+
* @returns _Memoized_ instance
|
|
73
84
|
*/
|
|
74
85
|
declare function memoize<Callback extends GenericCallback>(callback: Callback, options?: MemoizedOptions<Callback>): Memoized<Callback>;
|
|
75
86
|
//#endregion
|
|
@@ -3,18 +3,22 @@ import { getString, join } from "../internal/string.mjs";
|
|
|
3
3
|
import { SizedMap } from "../sized/map.mjs";
|
|
4
4
|
//#region src/function/memoize.ts
|
|
5
5
|
/**
|
|
6
|
-
* A
|
|
6
|
+
* A _Memoized_ function instance, caching and retrieving results based on the its parameters _(or a custom cache key)_
|
|
7
7
|
*/
|
|
8
8
|
var Memoized = class {
|
|
9
9
|
#state;
|
|
10
10
|
/**
|
|
11
11
|
* Maximum cache size
|
|
12
|
+
*
|
|
13
|
+
* @returns Maximum cache size _(or `Number.NaN` if the instance has been destroyed)_
|
|
12
14
|
*/
|
|
13
15
|
get maximum() {
|
|
14
16
|
return this.#state.cache?.maximum ?? NaN;
|
|
15
17
|
}
|
|
16
18
|
/**
|
|
17
19
|
* Current cache size
|
|
20
|
+
*
|
|
21
|
+
* @returns Current cache size _(or `Number.NaN` if the instance has been destroyed)_
|
|
18
22
|
*/
|
|
19
23
|
get size() {
|
|
20
24
|
return this.#state.cache?.size ?? NaN;
|
|
@@ -41,6 +45,7 @@ var Memoized = class {
|
|
|
41
45
|
}
|
|
42
46
|
/**
|
|
43
47
|
* Delete a result from the cache
|
|
48
|
+
*
|
|
44
49
|
* @param key Key to delete
|
|
45
50
|
* @returns `true` if the key existed and was removed, otherwise `false`
|
|
46
51
|
*/
|
|
@@ -48,7 +53,9 @@ var Memoized = class {
|
|
|
48
53
|
return this.#state.cache?.delete(key) ?? false;
|
|
49
54
|
}
|
|
50
55
|
/**
|
|
51
|
-
* Destroy the instance
|
|
56
|
+
* Destroy the instance
|
|
57
|
+
*
|
|
58
|
+
* _(When a Memoized instance is destroyed, its cache and callback are removed, and calls to `run` will throw an error)_
|
|
52
59
|
*/
|
|
53
60
|
destroy() {
|
|
54
61
|
this.#state.cache?.clear();
|
|
@@ -57,6 +64,7 @@ var Memoized = class {
|
|
|
57
64
|
}
|
|
58
65
|
/**
|
|
59
66
|
* Get a result from the cache
|
|
67
|
+
*
|
|
60
68
|
* @param key Key to get
|
|
61
69
|
* @returns Cached result or `undefined` if it does not exist
|
|
62
70
|
*/
|
|
@@ -65,6 +73,7 @@ var Memoized = class {
|
|
|
65
73
|
}
|
|
66
74
|
/**
|
|
67
75
|
* Does the result exist?
|
|
76
|
+
*
|
|
68
77
|
* @param key Key to check
|
|
69
78
|
* @returns `true` if the result exists, otherwise `false`
|
|
70
79
|
*/
|
|
@@ -73,11 +82,12 @@ var Memoized = class {
|
|
|
73
82
|
}
|
|
74
83
|
/**
|
|
75
84
|
* Run the callback with the provided parameters
|
|
85
|
+
*
|
|
76
86
|
* @param parameters Parameters to pass to the callback
|
|
77
87
|
* @returns Cached or computed _(then cached)_ result
|
|
78
88
|
*/
|
|
79
89
|
run(...parameters) {
|
|
80
|
-
if (this.#state.cache == null || this.#state.getter == null) throw new Error(
|
|
90
|
+
if (this.#state.cache == null || this.#state.getter == null) throw new Error(MEMOIZED_ERROR_DESTROYED);
|
|
81
91
|
return this.#state.getter(...parameters);
|
|
82
92
|
}
|
|
83
93
|
};
|
|
@@ -90,14 +100,18 @@ function getMemoizationOptions(input) {
|
|
|
90
100
|
}
|
|
91
101
|
/**
|
|
92
102
|
* Memoize a function, caching and retrieving results based on the first parameter
|
|
103
|
+
*
|
|
93
104
|
* @param callback Callback to memoize
|
|
94
105
|
* @param options Memoization options
|
|
95
|
-
* @returns
|
|
106
|
+
* @returns _Memoized_ instance
|
|
96
107
|
*/
|
|
97
108
|
function memoize(callback, options) {
|
|
109
|
+
if (typeof callback !== "function") throw new TypeError(MEMOIZED_ERROR_CALLBACK);
|
|
98
110
|
return new Memoized(callback, getMemoizationOptions(options));
|
|
99
111
|
}
|
|
100
112
|
const DEFAULT_CACHE_SIZE = 1024;
|
|
113
|
+
const MEMOIZED_ERROR_CALLBACK = "Memoized requires a callback function";
|
|
114
|
+
const MEMOIZED_ERROR_DESTROYED = "The Memoized instance has been destroyed";
|
|
101
115
|
const SEPARATOR = "_";
|
|
102
116
|
//#endregion
|
|
103
117
|
export { memoize };
|
package/dist/function/once.d.mts
CHANGED
|
@@ -4,15 +4,17 @@ import { GenericAsyncCallback, GenericCallback, OnceAsyncCallback, OnceCallback
|
|
|
4
4
|
/**
|
|
5
5
|
* Create an asynchronous function that can only be called once, rejecting or resolving the same result on subsequent calls
|
|
6
6
|
*
|
|
7
|
-
*
|
|
7
|
+
* _Available as `asyncOnce` and `once.async`_
|
|
8
|
+
*
|
|
8
9
|
* @param callback Callback to use once
|
|
9
|
-
* @returns
|
|
10
|
+
* @returns _Once_ callback
|
|
10
11
|
*/
|
|
11
12
|
declare function asyncOnce<Callback extends GenericAsyncCallback>(callback: Callback): OnceAsyncCallback<Callback>;
|
|
12
13
|
/**
|
|
13
14
|
* Create a function that can only be called once, returning the same value on subsequent calls
|
|
15
|
+
*
|
|
14
16
|
* @param callback Callback to use once
|
|
15
|
-
* @returns
|
|
17
|
+
* @returns _Once_ callback
|
|
16
18
|
*/
|
|
17
19
|
declare function once<Callback extends GenericCallback>(callback: Callback): OnceCallback<Callback>;
|
|
18
20
|
declare namespace once {
|
package/dist/function/once.mjs
CHANGED
|
@@ -3,9 +3,10 @@ import { assert } from "./assert.mjs";
|
|
|
3
3
|
/**
|
|
4
4
|
* Create an asynchronous function that can only be called once, rejecting or resolving the same result on subsequent calls
|
|
5
5
|
*
|
|
6
|
-
*
|
|
6
|
+
* _Available as `asyncOnce` and `once.async`_
|
|
7
|
+
*
|
|
7
8
|
* @param callback Callback to use once
|
|
8
|
-
* @returns
|
|
9
|
+
* @returns _Once_ callback
|
|
9
10
|
*/
|
|
10
11
|
function asyncOnce(callback) {
|
|
11
12
|
assert(() => typeof callback === "function", ONCE_MESSAGE_EXPECTATION);
|
|
@@ -66,8 +67,9 @@ function handleOnceResult(state, value, error) {
|
|
|
66
67
|
}
|
|
67
68
|
/**
|
|
68
69
|
* Create a function that can only be called once, returning the same value on subsequent calls
|
|
70
|
+
*
|
|
69
71
|
* @param callback Callback to use once
|
|
70
|
-
* @returns
|
|
72
|
+
* @returns _Once_ callback
|
|
71
73
|
*/
|
|
72
74
|
function once(callback) {
|
|
73
75
|
assert(() => typeof callback === "function", ONCE_MESSAGE_EXPECTATION);
|
|
@@ -16,7 +16,8 @@ type RetryOptions = {
|
|
|
16
16
|
/**
|
|
17
17
|
* Retry a callback a specified number of times, with a delay between attempts
|
|
18
18
|
*
|
|
19
|
-
*
|
|
19
|
+
* _Available as `asyncRetry` and `retry.async`_
|
|
20
|
+
*
|
|
20
21
|
* @param callback Callback to retry
|
|
21
22
|
* @param options Retry options
|
|
22
23
|
* @returns Callback result
|
|
@@ -25,7 +26,8 @@ declare function asyncRetry<Callback extends GenericAsyncCallback>(callback: Cal
|
|
|
25
26
|
/**
|
|
26
27
|
* Retry a callback a specified number of times, with a delay between attempts
|
|
27
28
|
*
|
|
28
|
-
*
|
|
29
|
+
* _Available as `asyncRetry` and `retry.async`_
|
|
30
|
+
*
|
|
29
31
|
* @param callback Callback to retry
|
|
30
32
|
* @param options Retry options
|
|
31
33
|
* @returns Callback result
|
|
@@ -33,6 +35,7 @@ declare function asyncRetry<Callback extends GenericAsyncCallback>(callback: Cal
|
|
|
33
35
|
declare function asyncRetry<Callback extends GenericCallback>(callback: Callback, options?: RetryOptions): Promise<ReturnType<Callback>>;
|
|
34
36
|
/**
|
|
35
37
|
* Retry a callback a specified number of times
|
|
38
|
+
*
|
|
36
39
|
* @param callback Callback to retry
|
|
37
40
|
* @param options Retry options
|
|
38
41
|
* @returns Callback result
|
package/dist/function/retry.mjs
CHANGED
|
@@ -14,7 +14,8 @@ var RetryError = class extends Error {
|
|
|
14
14
|
/**
|
|
15
15
|
* Retry a callback a specified number of times, with a delay between attempts
|
|
16
16
|
*
|
|
17
|
-
*
|
|
17
|
+
* _Available as `asyncRetry` and `retry.async`_
|
|
18
|
+
*
|
|
18
19
|
* @param callback Callback to retry
|
|
19
20
|
* @param options Retry options
|
|
20
21
|
* @returns Callback result
|
|
@@ -57,6 +58,7 @@ function getRetryOptions(input) {
|
|
|
57
58
|
}
|
|
58
59
|
/**
|
|
59
60
|
* Retry a callback a specified number of times
|
|
61
|
+
*
|
|
60
62
|
* @param callback Callback to retry
|
|
61
63
|
* @param options Retry options
|
|
62
64
|
* @returns Callback result
|