@depthbomb/common 2.1.0 → 2.2.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/dist/collections.d.cts +58 -0
- package/dist/collections.d.mts +58 -0
- package/dist/guards.cjs +1 -1
- package/dist/guards.d.cts +87 -1
- package/dist/guards.d.mts +87 -1
- package/dist/guards.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +1 -1
- package/dist/lazy.d.cts +12 -0
- package/dist/lazy.d.mts +12 -0
- package/dist/number.d.cts +31 -0
- package/dist/number.d.mts +31 -0
- package/dist/promise.d.cts +6 -0
- package/dist/promise.d.mts +6 -0
- package/dist/random.d.cts +25 -0
- package/dist/random.d.mts +25 -0
- package/dist/state.d.cts +10 -0
- package/dist/state.d.mts +10 -0
- package/dist/timing.cjs +1 -1
- package/dist/timing.d.cts +8 -2
- package/dist/timing.d.mts +8 -2
- package/dist/timing.mjs +1 -1
- package/dist/typing.d.cts +83 -1
- package/dist/typing.d.mts +83 -1
- package/dist/url.cjs +1 -1
- package/dist/url.d.cts +151 -0
- package/dist/url.d.mts +151 -0
- package/dist/url.mjs +1 -1
- package/package.json +1 -1
package/dist/collections.d.cts
CHANGED
|
@@ -1,17 +1,31 @@
|
|
|
1
1
|
import { Maybe } from "./typing.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/collections.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Options for constructing a {@link BoundedQueue}.
|
|
6
|
+
*/
|
|
4
7
|
interface IBoundedQueueOptions {
|
|
5
8
|
maxSize: number;
|
|
6
9
|
overflow?: BoundedQueueOverflow;
|
|
7
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Overflow behavior for {@link BoundedQueue}.
|
|
13
|
+
*/
|
|
8
14
|
declare const enum BoundedQueueOverflow {
|
|
9
15
|
DropOldest = 0,
|
|
10
16
|
DropNewest = 1,
|
|
11
17
|
Throw = 2
|
|
12
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* FIFO queue implementation with O(1) amortized dequeue.
|
|
21
|
+
*/
|
|
13
22
|
declare class Queue<T> {
|
|
14
23
|
#private;
|
|
24
|
+
/**
|
|
25
|
+
* Creates a queue optionally seeded with initial values.
|
|
26
|
+
*
|
|
27
|
+
* @param initial Initial values in dequeue order.
|
|
28
|
+
*/
|
|
15
29
|
constructor(initial?: Iterable<T>);
|
|
16
30
|
/**
|
|
17
31
|
* Get the number of items in the queue.
|
|
@@ -56,19 +70,63 @@ declare class Queue<T> {
|
|
|
56
70
|
*/
|
|
57
71
|
toArray(): T[];
|
|
58
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Queue with a fixed maximum size and configurable overflow policy.
|
|
75
|
+
*/
|
|
59
76
|
declare class BoundedQueue<T> {
|
|
60
77
|
#private;
|
|
78
|
+
/**
|
|
79
|
+
* Creates a bounded queue.
|
|
80
|
+
*
|
|
81
|
+
* @param options Queue size and overflow behavior.
|
|
82
|
+
* @param initial Optional initial values.
|
|
83
|
+
*/
|
|
61
84
|
constructor(options: IBoundedQueueOptions, initial?: Iterable<T>);
|
|
85
|
+
/**
|
|
86
|
+
* Number of values currently stored in the queue.
|
|
87
|
+
*/
|
|
62
88
|
get size(): number;
|
|
89
|
+
/**
|
|
90
|
+
* Whether the queue currently has zero items.
|
|
91
|
+
*/
|
|
63
92
|
get isEmpty(): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Whether the queue has reached its maximum size.
|
|
95
|
+
*/
|
|
64
96
|
get isFull(): boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Maximum number of elements this queue can hold.
|
|
99
|
+
*/
|
|
65
100
|
get maxSize(): number;
|
|
101
|
+
/**
|
|
102
|
+
* Overflow strategy applied when enqueuing into a full queue.
|
|
103
|
+
*/
|
|
66
104
|
get overflow(): BoundedQueueOverflow;
|
|
105
|
+
/**
|
|
106
|
+
* Adds an item to the queue, applying overflow behavior when full.
|
|
107
|
+
*
|
|
108
|
+
* @param item Item to enqueue.
|
|
109
|
+
*/
|
|
67
110
|
enqueue(item: T): void;
|
|
111
|
+
/**
|
|
112
|
+
* Removes and returns the item at the front of the queue.
|
|
113
|
+
*/
|
|
68
114
|
dequeue(): Maybe<T>;
|
|
115
|
+
/**
|
|
116
|
+
* Returns the item at the front without removing it.
|
|
117
|
+
*/
|
|
69
118
|
peek(): Maybe<T>;
|
|
119
|
+
/**
|
|
120
|
+
* Removes all items from the queue.
|
|
121
|
+
*/
|
|
70
122
|
clear(): void;
|
|
123
|
+
/**
|
|
124
|
+
* Iterates queue items from oldest to newest.
|
|
125
|
+
*/
|
|
71
126
|
[Symbol.iterator](): Iterator<T>;
|
|
127
|
+
/**
|
|
128
|
+
* Returns queue contents as an array in dequeue order.
|
|
129
|
+
*/
|
|
72
130
|
toArray(): T[];
|
|
73
131
|
}
|
|
74
132
|
//#endregion
|
package/dist/collections.d.mts
CHANGED
|
@@ -1,17 +1,31 @@
|
|
|
1
1
|
import { Maybe } from "./typing.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/collections.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Options for constructing a {@link BoundedQueue}.
|
|
6
|
+
*/
|
|
4
7
|
interface IBoundedQueueOptions {
|
|
5
8
|
maxSize: number;
|
|
6
9
|
overflow?: BoundedQueueOverflow;
|
|
7
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Overflow behavior for {@link BoundedQueue}.
|
|
13
|
+
*/
|
|
8
14
|
declare const enum BoundedQueueOverflow {
|
|
9
15
|
DropOldest = 0,
|
|
10
16
|
DropNewest = 1,
|
|
11
17
|
Throw = 2
|
|
12
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* FIFO queue implementation with O(1) amortized dequeue.
|
|
21
|
+
*/
|
|
13
22
|
declare class Queue<T> {
|
|
14
23
|
#private;
|
|
24
|
+
/**
|
|
25
|
+
* Creates a queue optionally seeded with initial values.
|
|
26
|
+
*
|
|
27
|
+
* @param initial Initial values in dequeue order.
|
|
28
|
+
*/
|
|
15
29
|
constructor(initial?: Iterable<T>);
|
|
16
30
|
/**
|
|
17
31
|
* Get the number of items in the queue.
|
|
@@ -56,19 +70,63 @@ declare class Queue<T> {
|
|
|
56
70
|
*/
|
|
57
71
|
toArray(): T[];
|
|
58
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Queue with a fixed maximum size and configurable overflow policy.
|
|
75
|
+
*/
|
|
59
76
|
declare class BoundedQueue<T> {
|
|
60
77
|
#private;
|
|
78
|
+
/**
|
|
79
|
+
* Creates a bounded queue.
|
|
80
|
+
*
|
|
81
|
+
* @param options Queue size and overflow behavior.
|
|
82
|
+
* @param initial Optional initial values.
|
|
83
|
+
*/
|
|
61
84
|
constructor(options: IBoundedQueueOptions, initial?: Iterable<T>);
|
|
85
|
+
/**
|
|
86
|
+
* Number of values currently stored in the queue.
|
|
87
|
+
*/
|
|
62
88
|
get size(): number;
|
|
89
|
+
/**
|
|
90
|
+
* Whether the queue currently has zero items.
|
|
91
|
+
*/
|
|
63
92
|
get isEmpty(): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Whether the queue has reached its maximum size.
|
|
95
|
+
*/
|
|
64
96
|
get isFull(): boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Maximum number of elements this queue can hold.
|
|
99
|
+
*/
|
|
65
100
|
get maxSize(): number;
|
|
101
|
+
/**
|
|
102
|
+
* Overflow strategy applied when enqueuing into a full queue.
|
|
103
|
+
*/
|
|
66
104
|
get overflow(): BoundedQueueOverflow;
|
|
105
|
+
/**
|
|
106
|
+
* Adds an item to the queue, applying overflow behavior when full.
|
|
107
|
+
*
|
|
108
|
+
* @param item Item to enqueue.
|
|
109
|
+
*/
|
|
67
110
|
enqueue(item: T): void;
|
|
111
|
+
/**
|
|
112
|
+
* Removes and returns the item at the front of the queue.
|
|
113
|
+
*/
|
|
68
114
|
dequeue(): Maybe<T>;
|
|
115
|
+
/**
|
|
116
|
+
* Returns the item at the front without removing it.
|
|
117
|
+
*/
|
|
69
118
|
peek(): Maybe<T>;
|
|
119
|
+
/**
|
|
120
|
+
* Removes all items from the queue.
|
|
121
|
+
*/
|
|
70
122
|
clear(): void;
|
|
123
|
+
/**
|
|
124
|
+
* Iterates queue items from oldest to newest.
|
|
125
|
+
*/
|
|
71
126
|
[Symbol.iterator](): Iterator<T>;
|
|
127
|
+
/**
|
|
128
|
+
* Returns queue contents as an array in dequeue order.
|
|
129
|
+
*/
|
|
72
130
|
toArray(): T[];
|
|
73
131
|
}
|
|
74
132
|
//#endregion
|
package/dist/guards.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});function e(e){return typeof e==`string`}function t(t){return e(t)&&t.length>0}function n(e){return typeof e==`number`&&Number.isFinite(e)}function r(e){return n(e)&&e>0}function i(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function a(e){return typeof e==`function`}function o(e){return a(e)&&e.toString().startsWith(`class`)}function
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});function e(e){return typeof e==`string`}function t(t){return e(t)&&t.length>0}function n(e){return typeof e==`number`&&Number.isFinite(e)}function r(e){return n(e)&&e>0}function i(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function a(e){return typeof e==`function`}function o(e){return typeof e==`object`&&!!e&&`then`in e&&typeof e.then==`function`}function s(e){return a(e)&&e.toString().startsWith(`class`)}function c(e){return e===null}function l(e){return e===void 0}function u(e){return c(e)||l(e)}function d(e){return typeof e==`boolean`}function f(e){return!!e}function p(e){return!e}function m(t){return t instanceof Date?g(t):n(t)||e(t)?g(new Date(t)):!1}const h={string:e,nonEmptyString:t,number:n,positiveNumber:r,record:i,function:a,promise:o,class:s,null:c,undefined:l,nullOrUndefined:u,boolean:d,truthy:f,falsy:p,dateLike:m};function g(e){return!Number.isNaN(e.getTime())}exports.is=h,exports.isBoolean=d,exports.isClass=s,exports.isDateLike=m,exports.isFalsy=p,exports.isFunction=a,exports.isNonEmptyString=t,exports.isNull=c,exports.isNullOrUndefined=u,exports.isNumber=n,exports.isPositiveNumber=r,exports.isPromise=o,exports.isRecord=i,exports.isString=e,exports.isTruthy=f,exports.isUndefined=l;
|
package/dist/guards.d.cts
CHANGED
|
@@ -1,22 +1,107 @@
|
|
|
1
1
|
import { Class } from "./typing.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/guards.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Values that coerce to `false` in JavaScript conditionals.
|
|
6
|
+
*/
|
|
4
7
|
type Falsy = false | 0 | 0n | '' | null | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Inputs that can be converted into a valid date.
|
|
10
|
+
*/
|
|
5
11
|
type DateLike = Date | string | number;
|
|
12
|
+
/**
|
|
13
|
+
* Returns `true` when `value` is a string.
|
|
14
|
+
*
|
|
15
|
+
* @param value Value to check.
|
|
16
|
+
*/
|
|
6
17
|
declare function isString(value: unknown): value is string;
|
|
18
|
+
/**
|
|
19
|
+
* Returns `true` when `value` is a string with at least one character.
|
|
20
|
+
*
|
|
21
|
+
* @param value Value to check.
|
|
22
|
+
*/
|
|
7
23
|
declare function isNonEmptyString(value: unknown): value is string;
|
|
24
|
+
/**
|
|
25
|
+
* Returns `true` when `value` is a finite number.
|
|
26
|
+
*
|
|
27
|
+
* @param value Value to check.
|
|
28
|
+
*/
|
|
8
29
|
declare function isNumber(value: unknown): value is number;
|
|
30
|
+
/**
|
|
31
|
+
* Returns `true` when `value` is a finite number greater than `0`.
|
|
32
|
+
*
|
|
33
|
+
* @param value Value to check.
|
|
34
|
+
*/
|
|
9
35
|
declare function isPositiveNumber(value: unknown): value is number;
|
|
36
|
+
/**
|
|
37
|
+
* Returns `true` when `value` is a non-null object and not an array.
|
|
38
|
+
*
|
|
39
|
+
* @param value Value to check.
|
|
40
|
+
*/
|
|
10
41
|
declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
42
|
+
/**
|
|
43
|
+
* Returns `true` when `value` is callable.
|
|
44
|
+
*
|
|
45
|
+
* @param value Value to check.
|
|
46
|
+
*/
|
|
11
47
|
declare function isFunction(value: unknown): value is Function;
|
|
48
|
+
/**
|
|
49
|
+
* Returns `true` when `value` is a {@link PromiseConstructor|Promise}.
|
|
50
|
+
*
|
|
51
|
+
* @param value Value to check.
|
|
52
|
+
*/
|
|
53
|
+
declare function isPromise<T = unknown>(value: unknown): value is Promise<T>;
|
|
54
|
+
/**
|
|
55
|
+
* Returns `true` when `value` is an ES class constructor.
|
|
56
|
+
*
|
|
57
|
+
* @param value Value to check.
|
|
58
|
+
*/
|
|
12
59
|
declare function isClass<T = unknown>(value: unknown): value is Class<T>;
|
|
60
|
+
/**
|
|
61
|
+
* Returns `true` when `value` is `null`.
|
|
62
|
+
*
|
|
63
|
+
* @param value Value to check.
|
|
64
|
+
*/
|
|
13
65
|
declare function isNull(value: unknown): value is null;
|
|
66
|
+
/**
|
|
67
|
+
* Returns `true` when `value` is `undefined`.
|
|
68
|
+
*
|
|
69
|
+
* @param value Value to check.
|
|
70
|
+
*/
|
|
14
71
|
declare function isUndefined(value: unknown): value is undefined;
|
|
72
|
+
/**
|
|
73
|
+
* Returns `true` when `value` is either `null` or `undefined`.
|
|
74
|
+
*
|
|
75
|
+
* @param value Value to check.
|
|
76
|
+
*/
|
|
15
77
|
declare function isNullOrUndefined(value: unknown): value is null | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* Returns `true` when `value` is a boolean.
|
|
80
|
+
*
|
|
81
|
+
* @param value Value to check.
|
|
82
|
+
*/
|
|
16
83
|
declare function isBoolean(value: unknown): value is boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Returns `true` when `value` is truthy.
|
|
86
|
+
*
|
|
87
|
+
* @param value Value to check.
|
|
88
|
+
*/
|
|
17
89
|
declare function isTruthy<T>(value: T | Falsy): value is T;
|
|
90
|
+
/**
|
|
91
|
+
* Returns `true` when `value` is falsy.
|
|
92
|
+
*
|
|
93
|
+
* @param value Value to check.
|
|
94
|
+
*/
|
|
18
95
|
declare function isFalsy(value: unknown): value is Falsy;
|
|
96
|
+
/**
|
|
97
|
+
* Returns `true` when `value` can be converted to a valid `Date`.
|
|
98
|
+
*
|
|
99
|
+
* @param value Value to check.
|
|
100
|
+
*/
|
|
19
101
|
declare function isDateLike(value: unknown): value is DateLike;
|
|
102
|
+
/**
|
|
103
|
+
* Namespaced aliases for all guard helpers.
|
|
104
|
+
*/
|
|
20
105
|
declare const is: {
|
|
21
106
|
string: typeof isString;
|
|
22
107
|
nonEmptyString: typeof isNonEmptyString;
|
|
@@ -24,6 +109,7 @@ declare const is: {
|
|
|
24
109
|
positiveNumber: typeof isPositiveNumber;
|
|
25
110
|
record: typeof isRecord;
|
|
26
111
|
function: typeof isFunction;
|
|
112
|
+
promise: typeof isPromise;
|
|
27
113
|
class: typeof isClass;
|
|
28
114
|
null: typeof isNull;
|
|
29
115
|
undefined: typeof isUndefined;
|
|
@@ -34,4 +120,4 @@ declare const is: {
|
|
|
34
120
|
dateLike: typeof isDateLike;
|
|
35
121
|
};
|
|
36
122
|
//#endregion
|
|
37
|
-
export { DateLike, Falsy, is, isBoolean, isClass, isDateLike, isFalsy, isFunction, isNonEmptyString, isNull, isNullOrUndefined, isNumber, isPositiveNumber, isRecord, isString, isTruthy, isUndefined };
|
|
123
|
+
export { DateLike, Falsy, is, isBoolean, isClass, isDateLike, isFalsy, isFunction, isNonEmptyString, isNull, isNullOrUndefined, isNumber, isPositiveNumber, isPromise, isRecord, isString, isTruthy, isUndefined };
|
package/dist/guards.d.mts
CHANGED
|
@@ -1,22 +1,107 @@
|
|
|
1
1
|
import { Class } from "./typing.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/guards.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Values that coerce to `false` in JavaScript conditionals.
|
|
6
|
+
*/
|
|
4
7
|
type Falsy = false | 0 | 0n | '' | null | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Inputs that can be converted into a valid date.
|
|
10
|
+
*/
|
|
5
11
|
type DateLike = Date | string | number;
|
|
12
|
+
/**
|
|
13
|
+
* Returns `true` when `value` is a string.
|
|
14
|
+
*
|
|
15
|
+
* @param value Value to check.
|
|
16
|
+
*/
|
|
6
17
|
declare function isString(value: unknown): value is string;
|
|
18
|
+
/**
|
|
19
|
+
* Returns `true` when `value` is a string with at least one character.
|
|
20
|
+
*
|
|
21
|
+
* @param value Value to check.
|
|
22
|
+
*/
|
|
7
23
|
declare function isNonEmptyString(value: unknown): value is string;
|
|
24
|
+
/**
|
|
25
|
+
* Returns `true` when `value` is a finite number.
|
|
26
|
+
*
|
|
27
|
+
* @param value Value to check.
|
|
28
|
+
*/
|
|
8
29
|
declare function isNumber(value: unknown): value is number;
|
|
30
|
+
/**
|
|
31
|
+
* Returns `true` when `value` is a finite number greater than `0`.
|
|
32
|
+
*
|
|
33
|
+
* @param value Value to check.
|
|
34
|
+
*/
|
|
9
35
|
declare function isPositiveNumber(value: unknown): value is number;
|
|
36
|
+
/**
|
|
37
|
+
* Returns `true` when `value` is a non-null object and not an array.
|
|
38
|
+
*
|
|
39
|
+
* @param value Value to check.
|
|
40
|
+
*/
|
|
10
41
|
declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
42
|
+
/**
|
|
43
|
+
* Returns `true` when `value` is callable.
|
|
44
|
+
*
|
|
45
|
+
* @param value Value to check.
|
|
46
|
+
*/
|
|
11
47
|
declare function isFunction(value: unknown): value is Function;
|
|
48
|
+
/**
|
|
49
|
+
* Returns `true` when `value` is a {@link PromiseConstructor|Promise}.
|
|
50
|
+
*
|
|
51
|
+
* @param value Value to check.
|
|
52
|
+
*/
|
|
53
|
+
declare function isPromise<T = unknown>(value: unknown): value is Promise<T>;
|
|
54
|
+
/**
|
|
55
|
+
* Returns `true` when `value` is an ES class constructor.
|
|
56
|
+
*
|
|
57
|
+
* @param value Value to check.
|
|
58
|
+
*/
|
|
12
59
|
declare function isClass<T = unknown>(value: unknown): value is Class<T>;
|
|
60
|
+
/**
|
|
61
|
+
* Returns `true` when `value` is `null`.
|
|
62
|
+
*
|
|
63
|
+
* @param value Value to check.
|
|
64
|
+
*/
|
|
13
65
|
declare function isNull(value: unknown): value is null;
|
|
66
|
+
/**
|
|
67
|
+
* Returns `true` when `value` is `undefined`.
|
|
68
|
+
*
|
|
69
|
+
* @param value Value to check.
|
|
70
|
+
*/
|
|
14
71
|
declare function isUndefined(value: unknown): value is undefined;
|
|
72
|
+
/**
|
|
73
|
+
* Returns `true` when `value` is either `null` or `undefined`.
|
|
74
|
+
*
|
|
75
|
+
* @param value Value to check.
|
|
76
|
+
*/
|
|
15
77
|
declare function isNullOrUndefined(value: unknown): value is null | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* Returns `true` when `value` is a boolean.
|
|
80
|
+
*
|
|
81
|
+
* @param value Value to check.
|
|
82
|
+
*/
|
|
16
83
|
declare function isBoolean(value: unknown): value is boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Returns `true` when `value` is truthy.
|
|
86
|
+
*
|
|
87
|
+
* @param value Value to check.
|
|
88
|
+
*/
|
|
17
89
|
declare function isTruthy<T>(value: T | Falsy): value is T;
|
|
90
|
+
/**
|
|
91
|
+
* Returns `true` when `value` is falsy.
|
|
92
|
+
*
|
|
93
|
+
* @param value Value to check.
|
|
94
|
+
*/
|
|
18
95
|
declare function isFalsy(value: unknown): value is Falsy;
|
|
96
|
+
/**
|
|
97
|
+
* Returns `true` when `value` can be converted to a valid `Date`.
|
|
98
|
+
*
|
|
99
|
+
* @param value Value to check.
|
|
100
|
+
*/
|
|
19
101
|
declare function isDateLike(value: unknown): value is DateLike;
|
|
102
|
+
/**
|
|
103
|
+
* Namespaced aliases for all guard helpers.
|
|
104
|
+
*/
|
|
20
105
|
declare const is: {
|
|
21
106
|
string: typeof isString;
|
|
22
107
|
nonEmptyString: typeof isNonEmptyString;
|
|
@@ -24,6 +109,7 @@ declare const is: {
|
|
|
24
109
|
positiveNumber: typeof isPositiveNumber;
|
|
25
110
|
record: typeof isRecord;
|
|
26
111
|
function: typeof isFunction;
|
|
112
|
+
promise: typeof isPromise;
|
|
27
113
|
class: typeof isClass;
|
|
28
114
|
null: typeof isNull;
|
|
29
115
|
undefined: typeof isUndefined;
|
|
@@ -34,4 +120,4 @@ declare const is: {
|
|
|
34
120
|
dateLike: typeof isDateLike;
|
|
35
121
|
};
|
|
36
122
|
//#endregion
|
|
37
|
-
export { DateLike, Falsy, is, isBoolean, isClass, isDateLike, isFalsy, isFunction, isNonEmptyString, isNull, isNullOrUndefined, isNumber, isPositiveNumber, isRecord, isString, isTruthy, isUndefined };
|
|
123
|
+
export { DateLike, Falsy, is, isBoolean, isClass, isDateLike, isFalsy, isFunction, isNonEmptyString, isNull, isNullOrUndefined, isNumber, isPositiveNumber, isPromise, isRecord, isString, isTruthy, isUndefined };
|
package/dist/guards.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(e){return typeof e==`string`}function t(t){return e(t)&&t.length>0}function n(e){return typeof e==`number`&&Number.isFinite(e)}function r(e){return n(e)&&e>0}function i(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function a(e){return typeof e==`function`}function o(e){return a(e)&&e.toString().startsWith(`class`)}function
|
|
1
|
+
function e(e){return typeof e==`string`}function t(t){return e(t)&&t.length>0}function n(e){return typeof e==`number`&&Number.isFinite(e)}function r(e){return n(e)&&e>0}function i(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function a(e){return typeof e==`function`}function o(e){return typeof e==`object`&&!!e&&`then`in e&&typeof e.then==`function`}function s(e){return a(e)&&e.toString().startsWith(`class`)}function c(e){return e===null}function l(e){return e===void 0}function u(e){return c(e)||l(e)}function d(e){return typeof e==`boolean`}function f(e){return!!e}function p(e){return!e}function m(t){return t instanceof Date?g(t):n(t)||e(t)?g(new Date(t)):!1}const h={string:e,nonEmptyString:t,number:n,positiveNumber:r,record:i,function:a,promise:o,class:s,null:c,undefined:l,nullOrUndefined:u,boolean:d,truthy:f,falsy:p,dateLike:m};function g(e){return!Number.isNaN(e.getTime())}export{h as is,d as isBoolean,s as isClass,m as isDateLike,p as isFalsy,a as isFunction,t as isNonEmptyString,c as isNull,u as isNullOrUndefined,n as isNumber,r as isPositiveNumber,o as isPromise,i as isRecord,e as isString,f as isTruthy,l as isUndefined};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./collections.cjs`),t=require(`./decorators.cjs`),n=require(`./functional.cjs`),r=require(`./guards.cjs`),i=require(`./timing.cjs`),a=require(`./promise.cjs`),o=require(`./lazy.cjs`),s=require(`./number.cjs`),c=require(`./random.cjs`),l=require(`./state.cjs`),u=require(`./typing.cjs`),d=require(`./url.cjs`);exports.BoundedQueue=e.BoundedQueue,exports.BoundedQueueOverflow=e.BoundedQueueOverflow,exports.Flag=l.Flag,exports.Queue=e.Queue,exports.ResettableValue=l.ResettableValue,exports.RetryJitter=i.RetryJitter,exports.URLPath=d.URLPath,exports.abortAfter=i.abortAfter,exports.allSettledDetailed=a.allSettledDetailed,exports.allSettledSuccessful=a.allSettledSuccessful,exports.assume=u.assume,exports.average=s.average,exports.cache=t.cache,exports.cast=u.cast,exports.clamp=s.clamp,exports.err=u.err,exports.inRange=s.inRange,exports.is=r.is,exports.isBoolean=r.isBoolean,exports.isClass=r.isClass,exports.isDateLike=r.isDateLike,exports.isFalsy=r.isFalsy,exports.isFunction=r.isFunction,exports.isNonEmptyString=r.isNonEmptyString,exports.isNull=r.isNull,exports.isNullOrUndefined=r.isNullOrUndefined,exports.isNumber=r.isNumber,exports.isOk=u.isOk,exports.isPositiveNumber=r.isPositiveNumber,exports.isRecord=r.isRecord,exports.isString=r.isString,exports.isTruthy=r.isTruthy,exports.isUndefined=r.isUndefined,exports.lazy=o.lazy,exports.lazyAsync=o.lazyAsync,exports.mapErr=u.mapErr,exports.mapOk=u.mapOk,exports.ok=u.ok,exports.once=n.once,exports.pMap=a.pMap,exports.pickRandom=c.pickRandom,exports.pickWeighted=c.pickWeighted,exports.pollUntil=i.pollUntil,exports.pool=a.pool,exports.raceSignals=i.raceSignals,exports.randomFloat=c.randomFloat,exports.randomInt=c.randomInt,exports.rejectionTimeout=i.rejectionTimeout,exports.resettableLazy=l.resettableLazy,exports.resettableLazyAsync=l.resettableLazyAsync,exports.retry=i.retry,exports.roundTo=s.roundTo,exports.sequential=a.sequential,exports.sum=s.sum,exports.timeout=i.timeout,exports.tryCatchAsync=u.tryCatchAsync,exports.typedEntries=u.typedEntries,exports.url=d.url,exports.withAbort=i.withAbort,exports.withTimeout=i.withTimeout;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./collections.cjs`),t=require(`./decorators.cjs`),n=require(`./functional.cjs`),r=require(`./guards.cjs`),i=require(`./timing.cjs`),a=require(`./promise.cjs`),o=require(`./lazy.cjs`),s=require(`./number.cjs`),c=require(`./random.cjs`),l=require(`./state.cjs`),u=require(`./typing.cjs`),d=require(`./url.cjs`);exports.BoundedQueue=e.BoundedQueue,exports.BoundedQueueOverflow=e.BoundedQueueOverflow,exports.Flag=l.Flag,exports.Queue=e.Queue,exports.ResettableValue=l.ResettableValue,exports.RetryJitter=i.RetryJitter,exports.URLPath=d.URLPath,exports.abortAfter=i.abortAfter,exports.allSettledDetailed=a.allSettledDetailed,exports.allSettledSuccessful=a.allSettledSuccessful,exports.assume=u.assume,exports.average=s.average,exports.cache=t.cache,exports.cast=u.cast,exports.clamp=s.clamp,exports.err=u.err,exports.inRange=s.inRange,exports.is=r.is,exports.isBoolean=r.isBoolean,exports.isClass=r.isClass,exports.isDateLike=r.isDateLike,exports.isFalsy=r.isFalsy,exports.isFunction=r.isFunction,exports.isNonEmptyString=r.isNonEmptyString,exports.isNull=r.isNull,exports.isNullOrUndefined=r.isNullOrUndefined,exports.isNumber=r.isNumber,exports.isOk=u.isOk,exports.isPositiveNumber=r.isPositiveNumber,exports.isPromise=r.isPromise,exports.isRecord=r.isRecord,exports.isString=r.isString,exports.isTruthy=r.isTruthy,exports.isUndefined=r.isUndefined,exports.lazy=o.lazy,exports.lazyAsync=o.lazyAsync,exports.mapErr=u.mapErr,exports.mapOk=u.mapOk,exports.ok=u.ok,exports.once=n.once,exports.pMap=a.pMap,exports.pickRandom=c.pickRandom,exports.pickWeighted=c.pickWeighted,exports.pollUntil=i.pollUntil,exports.pool=a.pool,exports.raceSignals=i.raceSignals,exports.randomFloat=c.randomFloat,exports.randomInt=c.randomInt,exports.rejectionTimeout=i.rejectionTimeout,exports.resettableLazy=l.resettableLazy,exports.resettableLazyAsync=l.resettableLazyAsync,exports.retry=i.retry,exports.roundTo=s.roundTo,exports.sequential=a.sequential,exports.sum=s.sum,exports.timeout=i.timeout,exports.tryCatchAsync=u.tryCatchAsync,exports.typedEntries=u.typedEntries,exports.url=d.url,exports.withAbort=i.withAbort,exports.withTimeout=i.withTimeout;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Arrayable, Awaitable, Class, Maybe, Nullable, Prettify, Result, assume, cast, err, isOk, mapErr, mapOk, ok, tryCatchAsync, typedEntries } from "./typing.cjs";
|
|
1
|
+
import { Arrayable, Awaitable, AwaitableFn, Class, Fn, Maybe, Nullable, Prettify, Result, assume, cast, err, isOk, mapErr, mapOk, ok, tryCatchAsync, typedEntries } from "./typing.cjs";
|
|
2
2
|
import { BoundedQueue, BoundedQueueOverflow, IBoundedQueueOptions, Queue } from "./collections.cjs";
|
|
3
3
|
import { cache } from "./decorators.cjs";
|
|
4
4
|
import { once } from "./functional.cjs";
|
|
5
|
-
import { DateLike, Falsy, is, isBoolean, isClass, isDateLike, isFalsy, isFunction, isNonEmptyString, isNull, isNullOrUndefined, isNumber, isPositiveNumber, isRecord, isString, isTruthy, isUndefined } from "./guards.cjs";
|
|
5
|
+
import { DateLike, Falsy, is, isBoolean, isClass, isDateLike, isFalsy, isFunction, isNonEmptyString, isNull, isNullOrUndefined, isNumber, isPositiveNumber, isPromise, isRecord, isString, isTruthy, isUndefined } from "./guards.cjs";
|
|
6
6
|
import { IRetryOptions, RetryJitter, abortAfter, pollUntil, raceSignals, rejectionTimeout, retry, timeout, withAbort, withTimeout } from "./timing.cjs";
|
|
7
7
|
import { IConcurrencyOptions, SettledDetailed, allSettledDetailed, allSettledSuccessful, pMap, pool, sequential } from "./promise.cjs";
|
|
8
8
|
import { lazy, lazyAsync } from "./lazy.cjs";
|
|
@@ -10,4 +10,4 @@ import { average, clamp, inRange, roundTo, sum } from "./number.cjs";
|
|
|
10
10
|
import { IWeightedItem, pickRandom, pickWeighted, randomFloat, randomInt } from "./random.cjs";
|
|
11
11
|
import { Flag, ResettableValue, resettableLazy, resettableLazyAsync } from "./state.cjs";
|
|
12
12
|
import { QueryObject, QueryValue, URLLike, URLPath, url } from "./url.cjs";
|
|
13
|
-
export { Arrayable, Awaitable, BoundedQueue, BoundedQueueOverflow, Class, DateLike, Falsy, Flag, IBoundedQueueOptions, IConcurrencyOptions, IRetryOptions, IWeightedItem, Maybe, Nullable, Prettify, QueryObject, QueryValue, Queue, ResettableValue, Result, RetryJitter, SettledDetailed, URLLike, URLPath, abortAfter, allSettledDetailed, allSettledSuccessful, assume, average, cache, cast, clamp, err, inRange, is, isBoolean, isClass, isDateLike, isFalsy, isFunction, isNonEmptyString, isNull, isNullOrUndefined, isNumber, isOk, isPositiveNumber, isRecord, isString, isTruthy, isUndefined, lazy, lazyAsync, mapErr, mapOk, ok, once, pMap, pickRandom, pickWeighted, pollUntil, pool, raceSignals, randomFloat, randomInt, rejectionTimeout, resettableLazy, resettableLazyAsync, retry, roundTo, sequential, sum, timeout, tryCatchAsync, typedEntries, url, withAbort, withTimeout };
|
|
13
|
+
export { Arrayable, Awaitable, AwaitableFn, BoundedQueue, BoundedQueueOverflow, Class, DateLike, Falsy, Flag, Fn, IBoundedQueueOptions, IConcurrencyOptions, IRetryOptions, IWeightedItem, Maybe, Nullable, Prettify, QueryObject, QueryValue, Queue, ResettableValue, Result, RetryJitter, SettledDetailed, URLLike, URLPath, abortAfter, allSettledDetailed, allSettledSuccessful, assume, average, cache, cast, clamp, err, inRange, is, isBoolean, isClass, isDateLike, isFalsy, isFunction, isNonEmptyString, isNull, isNullOrUndefined, isNumber, isOk, isPositiveNumber, isPromise, isRecord, isString, isTruthy, isUndefined, lazy, lazyAsync, mapErr, mapOk, ok, once, pMap, pickRandom, pickWeighted, pollUntil, pool, raceSignals, randomFloat, randomInt, rejectionTimeout, resettableLazy, resettableLazyAsync, retry, roundTo, sequential, sum, timeout, tryCatchAsync, typedEntries, url, withAbort, withTimeout };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Arrayable, Awaitable, Class, Maybe, Nullable, Prettify, Result, assume, cast, err, isOk, mapErr, mapOk, ok, tryCatchAsync, typedEntries } from "./typing.mjs";
|
|
1
|
+
import { Arrayable, Awaitable, AwaitableFn, Class, Fn, Maybe, Nullable, Prettify, Result, assume, cast, err, isOk, mapErr, mapOk, ok, tryCatchAsync, typedEntries } from "./typing.mjs";
|
|
2
2
|
import { BoundedQueue, BoundedQueueOverflow, IBoundedQueueOptions, Queue } from "./collections.mjs";
|
|
3
3
|
import { cache } from "./decorators.mjs";
|
|
4
4
|
import { once } from "./functional.mjs";
|
|
5
|
-
import { DateLike, Falsy, is, isBoolean, isClass, isDateLike, isFalsy, isFunction, isNonEmptyString, isNull, isNullOrUndefined, isNumber, isPositiveNumber, isRecord, isString, isTruthy, isUndefined } from "./guards.mjs";
|
|
5
|
+
import { DateLike, Falsy, is, isBoolean, isClass, isDateLike, isFalsy, isFunction, isNonEmptyString, isNull, isNullOrUndefined, isNumber, isPositiveNumber, isPromise, isRecord, isString, isTruthy, isUndefined } from "./guards.mjs";
|
|
6
6
|
import { IRetryOptions, RetryJitter, abortAfter, pollUntil, raceSignals, rejectionTimeout, retry, timeout, withAbort, withTimeout } from "./timing.mjs";
|
|
7
7
|
import { IConcurrencyOptions, SettledDetailed, allSettledDetailed, allSettledSuccessful, pMap, pool, sequential } from "./promise.mjs";
|
|
8
8
|
import { lazy, lazyAsync } from "./lazy.mjs";
|
|
@@ -10,4 +10,4 @@ import { average, clamp, inRange, roundTo, sum } from "./number.mjs";
|
|
|
10
10
|
import { IWeightedItem, pickRandom, pickWeighted, randomFloat, randomInt } from "./random.mjs";
|
|
11
11
|
import { Flag, ResettableValue, resettableLazy, resettableLazyAsync } from "./state.mjs";
|
|
12
12
|
import { QueryObject, QueryValue, URLLike, URLPath, url } from "./url.mjs";
|
|
13
|
-
export { Arrayable, Awaitable, BoundedQueue, BoundedQueueOverflow, Class, DateLike, Falsy, Flag, IBoundedQueueOptions, IConcurrencyOptions, IRetryOptions, IWeightedItem, Maybe, Nullable, Prettify, QueryObject, QueryValue, Queue, ResettableValue, Result, RetryJitter, SettledDetailed, URLLike, URLPath, abortAfter, allSettledDetailed, allSettledSuccessful, assume, average, cache, cast, clamp, err, inRange, is, isBoolean, isClass, isDateLike, isFalsy, isFunction, isNonEmptyString, isNull, isNullOrUndefined, isNumber, isOk, isPositiveNumber, isRecord, isString, isTruthy, isUndefined, lazy, lazyAsync, mapErr, mapOk, ok, once, pMap, pickRandom, pickWeighted, pollUntil, pool, raceSignals, randomFloat, randomInt, rejectionTimeout, resettableLazy, resettableLazyAsync, retry, roundTo, sequential, sum, timeout, tryCatchAsync, typedEntries, url, withAbort, withTimeout };
|
|
13
|
+
export { Arrayable, Awaitable, AwaitableFn, BoundedQueue, BoundedQueueOverflow, Class, DateLike, Falsy, Flag, Fn, IBoundedQueueOptions, IConcurrencyOptions, IRetryOptions, IWeightedItem, Maybe, Nullable, Prettify, QueryObject, QueryValue, Queue, ResettableValue, Result, RetryJitter, SettledDetailed, URLLike, URLPath, abortAfter, allSettledDetailed, allSettledSuccessful, assume, average, cache, cast, clamp, err, inRange, is, isBoolean, isClass, isDateLike, isFalsy, isFunction, isNonEmptyString, isNull, isNullOrUndefined, isNumber, isOk, isPositiveNumber, isPromise, isRecord, isString, isTruthy, isUndefined, lazy, lazyAsync, mapErr, mapOk, ok, once, pMap, pickRandom, pickWeighted, pollUntil, pool, raceSignals, randomFloat, randomInt, rejectionTimeout, resettableLazy, resettableLazyAsync, retry, roundTo, sequential, sum, timeout, tryCatchAsync, typedEntries, url, withAbort, withTimeout };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{BoundedQueue as e,BoundedQueueOverflow as t,Queue as n}from"./collections.mjs";import{cache as r}from"./decorators.mjs";import{once as i}from"./functional.mjs";import{is as a,isBoolean as o,isClass as s,isDateLike as c,isFalsy as l,isFunction as u,isNonEmptyString as d,isNull as f,isNullOrUndefined as p,isNumber as m,isPositiveNumber as h,
|
|
1
|
+
import{BoundedQueue as e,BoundedQueueOverflow as t,Queue as n}from"./collections.mjs";import{cache as r}from"./decorators.mjs";import{once as i}from"./functional.mjs";import{is as a,isBoolean as o,isClass as s,isDateLike as c,isFalsy as l,isFunction as u,isNonEmptyString as d,isNull as f,isNullOrUndefined as p,isNumber as m,isPositiveNumber as h,isPromise as g,isRecord as _,isString as v,isTruthy as y,isUndefined as b}from"./guards.mjs";import{RetryJitter as x,abortAfter as S,pollUntil as C,raceSignals as w,rejectionTimeout as T,retry as E,timeout as D,withAbort as O,withTimeout as k}from"./timing.mjs";import{allSettledDetailed as A,allSettledSuccessful as j,pMap as M,pool as N,sequential as P}from"./promise.mjs";import{lazy as F,lazyAsync as I}from"./lazy.mjs";import{average as L,clamp as R,inRange as z,roundTo as B,sum as V}from"./number.mjs";import{pickRandom as H,pickWeighted as U,randomFloat as W,randomInt as G}from"./random.mjs";import{Flag as K,ResettableValue as q,resettableLazy as J,resettableLazyAsync as Y}from"./state.mjs";import{assume as X,cast as Z,err as Q,isOk as $,mapErr as ee,mapOk as te,ok as ne,tryCatchAsync as re,typedEntries as ie}from"./typing.mjs";import{URLPath as ae,url as oe}from"./url.mjs";export{e as BoundedQueue,t as BoundedQueueOverflow,K as Flag,n as Queue,q as ResettableValue,x as RetryJitter,ae as URLPath,S as abortAfter,A as allSettledDetailed,j as allSettledSuccessful,X as assume,L as average,r as cache,Z as cast,R as clamp,Q as err,z as inRange,a as is,o as isBoolean,s as isClass,c as isDateLike,l as isFalsy,u as isFunction,d as isNonEmptyString,f as isNull,p as isNullOrUndefined,m as isNumber,$ as isOk,h as isPositiveNumber,g as isPromise,_ as isRecord,v as isString,y as isTruthy,b as isUndefined,F as lazy,I as lazyAsync,ee as mapErr,te as mapOk,ne as ok,i as once,M as pMap,H as pickRandom,U as pickWeighted,C as pollUntil,N as pool,w as raceSignals,W as randomFloat,G as randomInt,T as rejectionTimeout,J as resettableLazy,Y as resettableLazyAsync,E as retry,B as roundTo,P as sequential,V as sum,D as timeout,re as tryCatchAsync,ie as typedEntries,oe as url,O as withAbort,k as withTimeout};
|
package/dist/lazy.d.cts
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
//#region src/lazy.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a getter that computes its value once and then returns the cached result.
|
|
4
|
+
*
|
|
5
|
+
* @param factory Function used to create the value.
|
|
6
|
+
* @returns A zero-argument getter for the lazily-created value.
|
|
7
|
+
*/
|
|
2
8
|
declare function lazy<T>(factory: () => T): () => T;
|
|
9
|
+
/**
|
|
10
|
+
* Creates a getter that runs an async factory once and reuses the same promise.
|
|
11
|
+
*
|
|
12
|
+
* @param factory Async function used to create the value.
|
|
13
|
+
* @returns A zero-argument getter returning the cached promise.
|
|
14
|
+
*/
|
|
3
15
|
declare function lazyAsync<T>(factory: () => Promise<T>): () => Promise<T>;
|
|
4
16
|
//#endregion
|
|
5
17
|
export { lazy, lazyAsync };
|
package/dist/lazy.d.mts
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
//#region src/lazy.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a getter that computes its value once and then returns the cached result.
|
|
4
|
+
*
|
|
5
|
+
* @param factory Function used to create the value.
|
|
6
|
+
* @returns A zero-argument getter for the lazily-created value.
|
|
7
|
+
*/
|
|
2
8
|
declare function lazy<T>(factory: () => T): () => T;
|
|
9
|
+
/**
|
|
10
|
+
* Creates a getter that runs an async factory once and reuses the same promise.
|
|
11
|
+
*
|
|
12
|
+
* @param factory Async function used to create the value.
|
|
13
|
+
* @returns A zero-argument getter returning the cached promise.
|
|
14
|
+
*/
|
|
3
15
|
declare function lazyAsync<T>(factory: () => Promise<T>): () => Promise<T>;
|
|
4
16
|
//#endregion
|
|
5
17
|
export { lazy, lazyAsync };
|
package/dist/number.d.cts
CHANGED
|
@@ -1,8 +1,39 @@
|
|
|
1
1
|
//#region src/number.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Restricts a number to the closed interval `[min, max]`.
|
|
4
|
+
*
|
|
5
|
+
* @param value Input value.
|
|
6
|
+
* @param min Lower bound.
|
|
7
|
+
* @param max Upper bound.
|
|
8
|
+
*/
|
|
2
9
|
declare function clamp(value: number, min: number, max: number): number;
|
|
10
|
+
/**
|
|
11
|
+
* Returns whether a number is within the provided range.
|
|
12
|
+
*
|
|
13
|
+
* @param value Input value.
|
|
14
|
+
* @param min Lower bound.
|
|
15
|
+
* @param max Upper bound.
|
|
16
|
+
* @param inclusive Whether range endpoints are included.
|
|
17
|
+
*/
|
|
3
18
|
declare function inRange(value: number, min: number, max: number, inclusive?: boolean): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Rounds a number to a fixed count of decimal places.
|
|
21
|
+
*
|
|
22
|
+
* @param value Number to round.
|
|
23
|
+
* @param decimals Decimal places to keep.
|
|
24
|
+
*/
|
|
4
25
|
declare function roundTo(value: number, decimals?: number): number;
|
|
26
|
+
/**
|
|
27
|
+
* Sums all numbers from an iterable.
|
|
28
|
+
*
|
|
29
|
+
* @param values Numbers to add.
|
|
30
|
+
*/
|
|
5
31
|
declare function sum(values: Iterable<number>): number;
|
|
32
|
+
/**
|
|
33
|
+
* Calculates the arithmetic mean of numbers from an iterable.
|
|
34
|
+
*
|
|
35
|
+
* @param values Numbers to average.
|
|
36
|
+
*/
|
|
6
37
|
declare function average(values: Iterable<number>): number;
|
|
7
38
|
//#endregion
|
|
8
39
|
export { average, clamp, inRange, roundTo, sum };
|
package/dist/number.d.mts
CHANGED
|
@@ -1,8 +1,39 @@
|
|
|
1
1
|
//#region src/number.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Restricts a number to the closed interval `[min, max]`.
|
|
4
|
+
*
|
|
5
|
+
* @param value Input value.
|
|
6
|
+
* @param min Lower bound.
|
|
7
|
+
* @param max Upper bound.
|
|
8
|
+
*/
|
|
2
9
|
declare function clamp(value: number, min: number, max: number): number;
|
|
10
|
+
/**
|
|
11
|
+
* Returns whether a number is within the provided range.
|
|
12
|
+
*
|
|
13
|
+
* @param value Input value.
|
|
14
|
+
* @param min Lower bound.
|
|
15
|
+
* @param max Upper bound.
|
|
16
|
+
* @param inclusive Whether range endpoints are included.
|
|
17
|
+
*/
|
|
3
18
|
declare function inRange(value: number, min: number, max: number, inclusive?: boolean): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Rounds a number to a fixed count of decimal places.
|
|
21
|
+
*
|
|
22
|
+
* @param value Number to round.
|
|
23
|
+
* @param decimals Decimal places to keep.
|
|
24
|
+
*/
|
|
4
25
|
declare function roundTo(value: number, decimals?: number): number;
|
|
26
|
+
/**
|
|
27
|
+
* Sums all numbers from an iterable.
|
|
28
|
+
*
|
|
29
|
+
* @param values Numbers to add.
|
|
30
|
+
*/
|
|
5
31
|
declare function sum(values: Iterable<number>): number;
|
|
32
|
+
/**
|
|
33
|
+
* Calculates the arithmetic mean of numbers from an iterable.
|
|
34
|
+
*
|
|
35
|
+
* @param values Numbers to average.
|
|
36
|
+
*/
|
|
6
37
|
declare function average(values: Iterable<number>): number;
|
|
7
38
|
//#endregion
|
|
8
39
|
export { average, clamp, inRange, roundTo, sum };
|
package/dist/promise.d.cts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { Awaitable } from "./typing.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/promise.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Configuration for promise concurrency helpers.
|
|
6
|
+
*/
|
|
4
7
|
interface IConcurrencyOptions {
|
|
5
8
|
concurrency?: number;
|
|
6
9
|
}
|
|
@@ -11,6 +14,9 @@ interface IConcurrencyOptions {
|
|
|
11
14
|
* @returns A promise that resolves to an array of successful results
|
|
12
15
|
*/
|
|
13
16
|
declare function allSettledSuccessful<T>(promises: Array<Awaitable<T>>): Promise<T[]>;
|
|
17
|
+
/**
|
|
18
|
+
* Detailed output from {@link allSettledDetailed}.
|
|
19
|
+
*/
|
|
14
20
|
interface SettledDetailed<T> {
|
|
15
21
|
results: Array<PromiseSettledResult<T>>;
|
|
16
22
|
fulfilled: T[];
|