@depthbomb/common 2.0.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.
@@ -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
@@ -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!Number.isNaN(e.getTime())}function t(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function n(e){return typeof e==`string`&&e.length>0}function r(e){return typeof e==`number`&&Number.isFinite(e)}function i(t){return t instanceof Date?e(t):typeof t==`number`?Number.isFinite(t)&&e(new Date(t)):typeof t==`string`?t.length>0&&e(new Date(t)):!1}exports.isDateLike=i,exports.isNonEmptyString=n,exports.isNumber=r,exports.isRecord=t;
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,7 +1,123 @@
1
+ import { Class } from "./typing.cjs";
2
+
1
3
  //#region src/guards.d.ts
2
- declare function isRecord(value: unknown): value is Record<string, unknown>;
4
+ /**
5
+ * Values that coerce to `false` in JavaScript conditionals.
6
+ */
7
+ type Falsy = false | 0 | 0n | '' | null | undefined;
8
+ /**
9
+ * Inputs that can be converted into a valid date.
10
+ */
11
+ type DateLike = Date | string | number;
12
+ /**
13
+ * Returns `true` when `value` is a string.
14
+ *
15
+ * @param value Value to check.
16
+ */
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
+ */
3
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
+ */
4
29
  declare function isNumber(value: unknown): value is number;
5
- declare function isDateLike(value: unknown): value is Date | number | string;
30
+ /**
31
+ * Returns `true` when `value` is a finite number greater than `0`.
32
+ *
33
+ * @param value Value to check.
34
+ */
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
+ */
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
+ */
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
+ */
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
+ */
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
+ */
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
+ */
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
+ */
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
+ */
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
+ */
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
+ */
101
+ declare function isDateLike(value: unknown): value is DateLike;
102
+ /**
103
+ * Namespaced aliases for all guard helpers.
104
+ */
105
+ declare const is: {
106
+ string: typeof isString;
107
+ nonEmptyString: typeof isNonEmptyString;
108
+ number: typeof isNumber;
109
+ positiveNumber: typeof isPositiveNumber;
110
+ record: typeof isRecord;
111
+ function: typeof isFunction;
112
+ promise: typeof isPromise;
113
+ class: typeof isClass;
114
+ null: typeof isNull;
115
+ undefined: typeof isUndefined;
116
+ nullOrUndefined: typeof isNullOrUndefined;
117
+ boolean: typeof isBoolean;
118
+ truthy: typeof isTruthy;
119
+ falsy: typeof isFalsy;
120
+ dateLike: typeof isDateLike;
121
+ };
6
122
  //#endregion
7
- export { isDateLike, isNonEmptyString, isNumber, isRecord };
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,7 +1,123 @@
1
+ import { Class } from "./typing.mjs";
2
+
1
3
  //#region src/guards.d.ts
2
- declare function isRecord(value: unknown): value is Record<string, unknown>;
4
+ /**
5
+ * Values that coerce to `false` in JavaScript conditionals.
6
+ */
7
+ type Falsy = false | 0 | 0n | '' | null | undefined;
8
+ /**
9
+ * Inputs that can be converted into a valid date.
10
+ */
11
+ type DateLike = Date | string | number;
12
+ /**
13
+ * Returns `true` when `value` is a string.
14
+ *
15
+ * @param value Value to check.
16
+ */
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
+ */
3
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
+ */
4
29
  declare function isNumber(value: unknown): value is number;
5
- declare function isDateLike(value: unknown): value is Date | number | string;
30
+ /**
31
+ * Returns `true` when `value` is a finite number greater than `0`.
32
+ *
33
+ * @param value Value to check.
34
+ */
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
+ */
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
+ */
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
+ */
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
+ */
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
+ */
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
+ */
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
+ */
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
+ */
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
+ */
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
+ */
101
+ declare function isDateLike(value: unknown): value is DateLike;
102
+ /**
103
+ * Namespaced aliases for all guard helpers.
104
+ */
105
+ declare const is: {
106
+ string: typeof isString;
107
+ nonEmptyString: typeof isNonEmptyString;
108
+ number: typeof isNumber;
109
+ positiveNumber: typeof isPositiveNumber;
110
+ record: typeof isRecord;
111
+ function: typeof isFunction;
112
+ promise: typeof isPromise;
113
+ class: typeof isClass;
114
+ null: typeof isNull;
115
+ undefined: typeof isUndefined;
116
+ nullOrUndefined: typeof isNullOrUndefined;
117
+ boolean: typeof isBoolean;
118
+ truthy: typeof isTruthy;
119
+ falsy: typeof isFalsy;
120
+ dateLike: typeof isDateLike;
121
+ };
6
122
  //#endregion
7
- export { isDateLike, isNonEmptyString, isNumber, isRecord };
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!Number.isNaN(e.getTime())}function t(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function n(e){return typeof e==`string`&&e.length>0}function r(e){return typeof e==`number`&&Number.isFinite(e)}function i(t){return t instanceof Date?e(t):typeof t==`number`?Number.isFinite(t)&&e(new Date(t)):typeof t==`string`?t.length>0&&e(new Date(t)):!1}export{i as isDateLike,n as isNonEmptyString,r as isNumber,t as isRecord};
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.isDateLike=r.isDateLike,exports.isNonEmptyString=r.isNonEmptyString,exports.isNumber=r.isNumber,exports.isOk=u.isOk,exports.isRecord=r.isRecord,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 { Awaitable, Maybe, Nullable, 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 { isDateLike, isNonEmptyString, isNumber, isRecord } 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 { Awaitable, BoundedQueue, BoundedQueueOverflow, Flag, IBoundedQueueOptions, IConcurrencyOptions, IRetryOptions, IWeightedItem, Maybe, Nullable, QueryObject, QueryValue, Queue, ResettableValue, Result, RetryJitter, SettledDetailed, URLLike, URLPath, abortAfter, allSettledDetailed, allSettledSuccessful, assume, average, cache, cast, clamp, err, inRange, isDateLike, isNonEmptyString, isNumber, isOk, isRecord, 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 { Awaitable, Maybe, Nullable, 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 { isDateLike, isNonEmptyString, isNumber, isRecord } 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 { Awaitable, BoundedQueue, BoundedQueueOverflow, Flag, IBoundedQueueOptions, IConcurrencyOptions, IRetryOptions, IWeightedItem, Maybe, Nullable, QueryObject, QueryValue, Queue, ResettableValue, Result, RetryJitter, SettledDetailed, URLLike, URLPath, abortAfter, allSettledDetailed, allSettledSuccessful, assume, average, cache, cast, clamp, err, inRange, isDateLike, isNonEmptyString, isNumber, isOk, isRecord, 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{isDateLike as a,isNonEmptyString as o,isNumber as s,isRecord as c}from"./guards.mjs";import{RetryJitter as l,abortAfter as u,pollUntil as d,raceSignals as f,rejectionTimeout as p,retry as m,timeout as h,withAbort as g,withTimeout as _}from"./timing.mjs";import{allSettledDetailed as v,allSettledSuccessful as y,pMap as b,pool as x,sequential as S}from"./promise.mjs";import{lazy as C,lazyAsync as w}from"./lazy.mjs";import{average as T,clamp as E,inRange as D,roundTo as O,sum as k}from"./number.mjs";import{pickRandom as A,pickWeighted as j,randomFloat as M,randomInt as N}from"./random.mjs";import{Flag as P,ResettableValue as F,resettableLazy as I,resettableLazyAsync as L}from"./state.mjs";import{assume as R,cast as z,err as B,isOk as V,mapErr as H,mapOk as U,ok as W,tryCatchAsync as G,typedEntries as K}from"./typing.mjs";import{URLPath as q,url as J}from"./url.mjs";export{e as BoundedQueue,t as BoundedQueueOverflow,P as Flag,n as Queue,F as ResettableValue,l as RetryJitter,q as URLPath,u as abortAfter,v as allSettledDetailed,y as allSettledSuccessful,R as assume,T as average,r as cache,z as cast,E as clamp,B as err,D as inRange,a as isDateLike,o as isNonEmptyString,s as isNumber,V as isOk,c as isRecord,C as lazy,w as lazyAsync,H as mapErr,U as mapOk,W as ok,i as once,b as pMap,A as pickRandom,j as pickWeighted,d as pollUntil,x as pool,f as raceSignals,M as randomFloat,N as randomInt,p as rejectionTimeout,I as resettableLazy,L as resettableLazyAsync,m as retry,O as roundTo,S as sequential,k as sum,h as timeout,G as tryCatchAsync,K as typedEntries,J as url,g as withAbort,_ as withTimeout};
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 };
@@ -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[];