@oscarpalmer/atoms 0.212.0 → 0.214.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/array/difference.d.mts +1 -1
- package/dist/array/difference.mjs +3 -2
- package/dist/array/exists.d.mts +1 -1
- package/dist/array/exists.mjs +3 -2
- package/dist/array/filter.d.mts +1 -1
- package/dist/array/filter.mjs +1 -0
- package/dist/array/find.d.mts +1 -1
- package/dist/array/find.mjs +4 -3
- package/dist/array/first.d.mts +1 -1
- package/dist/array/flatten.d.mts +1 -1
- package/dist/array/group-by.d.mts +1 -1
- package/dist/array/index.d.mts +2 -2
- package/dist/array/insert.mjs +3 -2
- package/dist/array/intersection.mjs +3 -2
- package/dist/array/last.d.mts +1 -1
- package/dist/array/move.d.mts +1 -1
- package/dist/array/partition.d.mts +1 -1
- package/dist/array/partition.mjs +1 -0
- package/dist/array/push.mjs +3 -2
- package/dist/array/select.d.mts +10 -12
- package/dist/array/select.mjs +1 -0
- package/dist/array/single.d.mts +1 -1
- package/dist/array/single.mjs +1 -0
- package/dist/array/slice.d.mts +1 -1
- package/dist/array/slice.mjs +4 -5
- package/dist/array/sort.d.mts +4 -103
- package/dist/array/sort.mjs +6 -14
- package/dist/array/splice.mjs +3 -2
- package/dist/array/swap.d.mts +1 -1
- package/dist/array/to-map.d.mts +1 -1
- package/dist/array/to-record.d.mts +1 -1
- package/dist/array/to-set.d.mts +1 -1
- package/dist/array/toggle.d.mts +1 -1
- package/dist/array/union.mjs +3 -2
- package/dist/array/unique.d.mts +1 -1
- package/dist/array/unique.mjs +3 -2
- package/dist/array/update.d.mts +1 -1
- package/dist/beacon.d.mts +6 -92
- package/dist/beacon.mjs +6 -16
- package/dist/color/constants.d.mts +2 -2
- package/dist/color/constants.mjs +1 -1
- package/dist/color/index.d.mts +1 -1
- package/dist/color/instance.d.mts +1 -1
- package/dist/color/instance.mjs +0 -1
- package/dist/color/misc/alpha.d.mts +1 -1
- package/dist/color/misc/format.d.mts +1 -1
- package/dist/color/misc/get.d.mts +1 -1
- package/dist/color/misc/is.d.mts +2 -2
- package/dist/color/misc/is.mjs +1 -0
- package/dist/color/misc/state.d.mts +1 -1
- package/dist/color/space/hex.d.mts +1 -1
- package/dist/color/space/hsl.d.mts +1 -1
- package/dist/color/space/hwb.d.mts +1 -1
- package/dist/color/space/rgb.d.mts +1 -1
- package/dist/function/limit.d.mts +2 -2
- package/dist/function/limit.mjs +2 -1
- package/dist/function/once.d.mts +7 -3
- package/dist/function/once.mjs +5 -10
- package/dist/function/retry.d.mts +4 -14
- package/dist/function/retry.mjs +3 -15
- package/dist/herald.d.mts +2 -2
- package/dist/index.d.mts +466 -351
- package/dist/index.mjs +491 -439
- package/dist/internal/aborter.d.mts +1 -6
- package/dist/internal/aborter.mjs +3 -4
- package/dist/internal/array/callbacks.d.mts +3 -7
- package/dist/internal/array/chunk.mjs +2 -2
- package/dist/internal/array/find.d.mts +5 -23
- package/dist/internal/array/find.mjs +5 -9
- package/dist/internal/array/get.d.mts +1 -1
- package/dist/internal/array/group.d.mts +1 -1
- package/dist/internal/array/index-of.d.mts +1 -1
- package/dist/internal/array/index-of.mjs +4 -3
- package/dist/internal/array/insert.d.mts +2 -5
- package/dist/internal/array/insert.mjs +2 -4
- package/dist/internal/array/match.d.mts +2 -5
- package/dist/internal/array/match.mjs +10 -20
- package/dist/internal/array/overlap.d.mts +2 -10
- package/dist/internal/array/sets.d.mts +2 -5
- package/dist/internal/array/sets.mjs +5 -7
- package/dist/internal/function/assert.d.mts +5 -12
- package/dist/internal/function/assert.mjs +2 -2
- package/dist/internal/function/limit.d.mts +2 -37
- package/dist/internal/function/limit.mjs +4 -15
- package/dist/internal/function/memoize.d.mts +5 -70
- package/dist/internal/function/memoize.mjs +2 -5
- package/dist/internal/function/work.d.mts +16 -22
- package/dist/internal/function/work.mjs +1 -8
- package/dist/internal/herald.d.mts +3 -3
- package/dist/internal/herald.mjs +2 -1
- package/dist/internal/is.d.mts +1 -1
- package/dist/internal/math/aggregate.d.mts +2 -14
- package/dist/internal/math/aggregate.mjs +2 -5
- package/dist/internal/number.mjs +4 -7
- package/dist/internal/result/attempt.d.mts +1 -1
- package/dist/internal/result/misc.d.mts +1 -1
- package/dist/internal/string/case.mjs +6 -16
- package/dist/internal/string/misc.mjs +1 -3
- package/dist/internal/subscription.d.mts +1 -100
- package/dist/internal/subscription.mjs +3 -9
- package/dist/internal/value/compare.d.mts +4 -4
- package/dist/internal/value/compare.mjs +1 -1
- package/dist/internal/value/equal.d.mts +6 -57
- package/dist/internal/value/equal.mjs +5 -10
- package/dist/internal/value/get.d.mts +1 -1
- package/dist/internal/value/handlers.d.mts +2 -21
- package/dist/internal/value/has.d.mts +2 -2
- package/dist/internal/value/misc.d.mts +1 -1
- package/dist/internal/value/misc.mjs +8 -14
- package/dist/internal/value/set.d.mts +1 -1
- package/dist/internal/value/set.mjs +2 -2
- package/dist/is.mjs +3 -3
- package/dist/logger.d.mts +3 -70
- package/dist/logger.mjs +2 -5
- package/dist/math.d.mts +1 -1
- package/dist/math.mjs +2 -1
- package/dist/models/aborter.model.d.mts +12 -0
- package/dist/models/aborter.model.mjs +5 -0
- package/dist/models/array/array.find.model.d.mts +22 -0
- package/dist/models/array/array.find.model.mjs +8 -0
- package/dist/models/array/array.match.model.d.mts +14 -0
- package/dist/models/array/array.match.model.mjs +14 -0
- package/dist/models/array/array.misc.model.d.mts +36 -0
- package/dist/models/array/array.misc.model.mjs +12 -0
- package/dist/models/array/array.sort.model.d.mts +122 -0
- package/dist/models/array/array.sort.model.mjs +12 -0
- package/dist/models/beacon.model.d.mts +119 -0
- package/dist/models/beacon.model.mjs +16 -0
- package/dist/{color/models.d.mts → models/color.model.d.mts} +4 -4
- package/dist/models/function/assert.model.d.mts +13 -0
- package/dist/models/function/assert.model.mjs +4 -0
- package/dist/models/function/limiter.model.d.mts +71 -0
- package/dist/models/function/limiter.model.mjs +15 -0
- package/dist/models/function/memoize.model.d.mts +88 -0
- package/dist/models/function/memoize.model.mjs +7 -0
- package/dist/models/function/once.model.d.mts +76 -0
- package/dist/models/function/once.model.mjs +9 -0
- package/dist/models/function/retry.model.d.mts +17 -0
- package/dist/models/function/retry.model.mjs +17 -0
- package/dist/models/function/work.model.d.mts +20 -0
- package/dist/models/function/work.model.mjs +11 -0
- package/dist/{internal/models → models}/herald.model.d.mts +3 -3
- package/dist/{internal/models → models}/herald.model.mjs +2 -2
- package/dist/{models.d.mts → models/index.d.mts} +8 -50
- package/dist/models/logger.model.d.mts +83 -0
- package/dist/models/logger.model.mjs +7 -0
- package/dist/models/math.model.d.mts +16 -0
- package/dist/models/math.model.mjs +7 -0
- package/dist/models/misc.model.d.mts +10 -0
- package/dist/models/misc.model.mjs +11 -0
- package/dist/{internal/models → models}/plan.model.d.mts +17 -15
- package/dist/{internal/models → models}/plan.model.mjs +1 -1
- package/dist/models/promise.model.d.mts +119 -0
- package/dist/models/promise.model.mjs +47 -0
- package/dist/models/query.model.d.mts +9 -0
- package/dist/models/query.model.mjs +14 -0
- package/dist/models/queue.model.d.mts +251 -0
- package/dist/models/queue.model.mjs +29 -0
- package/dist/models/random.model.d.mts +6 -0
- package/dist/models/random.model.mjs +7 -0
- package/dist/{internal/models → models}/result.model.d.mts +10 -2
- package/dist/models/string/string.case.model.d.mts +19 -0
- package/dist/models/string/string.case.model.mjs +14 -0
- package/dist/models/string/string.fuzzy.model.d.mts +108 -0
- package/dist/models/string/string.fuzzy.model.mjs +9 -0
- package/dist/models/string/string.misc.model.d.mts +13 -0
- package/dist/models/string/string.misc.model.mjs +13 -0
- package/dist/models/string/string.normalize.model.d.mts +85 -0
- package/dist/models/string/string.normalize.model.mjs +43 -0
- package/dist/models/string/string.template.model.d.mts +50 -0
- package/dist/models/string/string.template.model.mjs +5 -0
- package/dist/models/subscription.model.d.mts +127 -0
- package/dist/models/subscription.model.mjs +10 -0
- package/dist/models/value/value.clone.model.d.mts +56 -0
- package/dist/models/value/value.clone.model.mjs +24 -0
- package/dist/models/value/value.diff.model.d.mts +61 -0
- package/dist/models/value/value.diff.model.mjs +6 -0
- package/dist/models/value/value.equal.model.d.mts +76 -0
- package/dist/models/value/value.equal.model.mjs +9 -0
- package/dist/models/value/value.handler.model.d.mts +27 -0
- package/dist/models/value/value.handler.model.mjs +1 -0
- package/dist/models/value/value.merge.model.d.mts +82 -0
- package/dist/models/value/value.merge.model.mjs +5 -0
- package/dist/models/value/value.misc.model.d.mts +33 -0
- package/dist/models/value/value.misc.model.mjs +12 -0
- package/dist/models/value/value.transform.model.d.mts +28 -0
- package/dist/models/value/value.transform.model.mjs +4 -0
- package/dist/plan/generate.d.mts +3 -2
- package/dist/plan/generate.mjs +14 -10
- package/dist/plan/index.d.mts +1 -1
- package/dist/plan/index.mjs +2 -2
- package/dist/plan/is.d.mts +31 -2
- package/dist/plan/is.mjs +45 -1
- package/dist/plan/misc.d.mts +21 -2
- package/dist/plan/misc.mjs +32 -2
- package/dist/plan/models.d.mts +1 -1
- package/dist/plan/result.d.mts +7 -7
- package/dist/plan/result.mjs +6 -6
- package/dist/plan/run.d.mts +5 -5
- package/dist/plan/run.mjs +6 -6
- package/dist/promise/delay.d.mts +1 -1
- package/dist/promise/delay.mjs +2 -1
- package/dist/promise/helpers.d.mts +2 -2
- package/dist/promise/helpers.mjs +6 -6
- package/dist/promise/index.d.mts +2 -2
- package/dist/promise/index.mjs +1 -1
- package/dist/promise/misc.d.mts +3 -3
- package/dist/promise/misc.mjs +7 -4
- package/dist/promise/models.d.mts +2 -106
- package/dist/promise/models.mjs +1 -35
- package/dist/promise/timed.d.mts +2 -2
- package/dist/promise/timed.mjs +3 -3
- package/dist/query.d.mts +1 -1
- package/dist/query.mjs +5 -15
- package/dist/queue.d.mts +6 -200
- package/dist/queue.mjs +9 -34
- package/dist/random.mjs +2 -5
- package/dist/result/match.d.mts +1 -1
- package/dist/result/match.mjs +27 -15
- package/dist/result/misc.d.mts +1 -1
- package/dist/result/work/flow.d.mts +13 -21
- package/dist/result/work/flow.mjs +0 -1
- package/dist/result/work/pipe.d.mts +2 -2
- package/dist/result/work/pipe.mjs +0 -1
- package/dist/string/fuzzy.d.mts +5 -87
- package/dist/string/fuzzy.mjs +6 -11
- package/dist/string/index.mjs +6 -8
- package/dist/string/match.mjs +4 -6
- package/dist/string/normalize.d.mts +4 -40
- package/dist/string/normalize.mjs +9 -48
- package/dist/string/template.d.mts +5 -43
- package/dist/string/template.mjs +1 -2
- package/dist/subscription.d.mts +2 -1
- package/dist/value/clone.d.mts +6 -42
- package/dist/value/clone.mjs +10 -30
- package/dist/value/collection.mjs +2 -0
- package/dist/value/diff.d.mts +3 -44
- package/dist/value/diff.mjs +1 -3
- package/dist/value/freeze.d.mts +1 -5
- package/dist/value/index.d.mts +4 -3
- package/dist/value/merge.d.mts +6 -64
- package/dist/value/merge.mjs +8 -8
- package/dist/value/omit.d.mts +1 -1
- package/dist/value/pick.d.mts +1 -1
- package/dist/value/shake.d.mts +4 -6
- package/dist/value/smush.d.mts +4 -6
- package/dist/value/smush.mjs +2 -2
- package/dist/value/transform.d.mts +6 -22
- package/dist/value/transform.mjs +1 -1
- package/dist/value/unsmush.d.mts +4 -10
- package/package.json +12 -3
- package/dist/internal/plan.d.mts +0 -45
- package/dist/internal/plan.mjs +0 -70
- package/dist/promise/constants.d.mts +0 -17
- package/dist/promise/constants.mjs +0 -15
- /package/dist/{color/models.mjs → models/color.model.mjs} +0 -0
- /package/dist/{internal/models/result.model.mjs → models/index.mjs} +0 -0
- /package/dist/{models.mjs → models/result.model.mjs} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Err, Ok, Result } from "./result.model.mjs";
|
|
2
|
-
//#region src/
|
|
2
|
+
//#region src/models/plan.model.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* An asynchronous plan of execution that can yield intermediate results and eventually return a result
|
|
5
5
|
*/
|
|
@@ -9,24 +9,24 @@ export type AsyncPlan<Yielded, Returned, Parameters extends unknown[]> = {
|
|
|
9
9
|
*
|
|
10
10
|
* @returns Asynchronous generator
|
|
11
11
|
*/
|
|
12
|
-
[Symbol.asyncIterator]: () => AsyncGenerator<Yielded, Returned
|
|
12
|
+
[Symbol.asyncIterator]: (...parameters: Parameters) => AsyncGenerator<Yielded, Returned>;
|
|
13
13
|
/**
|
|
14
14
|
* Attempt to run the plan to completion
|
|
15
15
|
*
|
|
16
16
|
* _Returns a promised {@link Result} instead of a raw value or throwing an error_
|
|
17
17
|
*
|
|
18
|
-
* @returns
|
|
18
|
+
* @returns Attempted result
|
|
19
19
|
*/
|
|
20
|
-
attempt(...parameters: Parameters): Promise<Result<
|
|
20
|
+
attempt(...parameters: Parameters): Promise<Result<PlanOk<Returned>, PlanError<Yielded, Returned>>>;
|
|
21
21
|
/**
|
|
22
22
|
* Run the plan to completion
|
|
23
23
|
*
|
|
24
24
|
* @throws {PlanError<Yielded, Returned>}
|
|
25
25
|
* @returns Result
|
|
26
26
|
*/
|
|
27
|
-
run(...parameters: Parameters): Promise<
|
|
27
|
+
run(...parameters: Parameters): Promise<PlanReturned<Returned>>;
|
|
28
28
|
};
|
|
29
|
-
type AsyncPlanState = {
|
|
29
|
+
export type AsyncPlanState = {
|
|
30
30
|
generator(...parameters: unknown[]): AsyncGenerator;
|
|
31
31
|
} & BaseState<typeof PLAN_TYPE_PLAN_ASYNC>;
|
|
32
32
|
type BaseState<Type extends PlanType> = {
|
|
@@ -47,30 +47,32 @@ export type Plan<Yielded, Returned, Parameters extends unknown[]> = {
|
|
|
47
47
|
*
|
|
48
48
|
* @returns Generator
|
|
49
49
|
*/
|
|
50
|
-
[Symbol.iterator]: () => Generator<Yielded, Returned
|
|
50
|
+
[Symbol.iterator]: (...parameters: Parameters) => Generator<Yielded, Returned>;
|
|
51
51
|
/**
|
|
52
52
|
* Attempt to run the plan to completion
|
|
53
53
|
*
|
|
54
54
|
* _Returns a {@link Result} instead of a raw value or throwing an error_
|
|
55
55
|
*
|
|
56
|
-
* @returns
|
|
56
|
+
* @returns Attempted result
|
|
57
57
|
*/
|
|
58
|
-
attempt(...parameters: Parameters): Result<
|
|
58
|
+
attempt(...parameters: Parameters): Result<PlanOk<Returned>, PlanError<Yielded, Returned>>;
|
|
59
59
|
/**
|
|
60
60
|
* Run the plan to completion
|
|
61
61
|
*
|
|
62
62
|
* @throws {PlanError<Yielded, Returned>}
|
|
63
63
|
* @returns Result
|
|
64
64
|
*/
|
|
65
|
-
run(...parameters: Parameters):
|
|
65
|
+
run(...parameters: Parameters): PlanReturned<Returned>;
|
|
66
66
|
};
|
|
67
|
-
type
|
|
68
|
-
|
|
69
|
-
export type
|
|
70
|
-
type
|
|
67
|
+
export type PlanOk<Returned> = Returned extends Error ? never : Returned extends Err<infer _> ? never : Returned extends Ok<infer Value> ? Value : Returned;
|
|
68
|
+
type PlanErrors<Yielded, Returned> = PlanErrorValues<Yielded> | PlanErrorValues<Returned>;
|
|
69
|
+
export type PlanError<Yielded, Returned> = [PlanErrors<Yielded, Returned>] extends [never] ? Error : PlanErrors<Yielded, Returned>;
|
|
70
|
+
type PlanErrorValues<Original> = Original extends Error ? Original : Original extends Err<infer Error> ? Error : never;
|
|
71
|
+
export type PlanReturned<Returned> = Returned extends Error ? never : Returned extends Err<infer _> ? never : Returned;
|
|
72
|
+
export type PlanState = {
|
|
71
73
|
generator(...parameters: unknown[]): Generator;
|
|
72
74
|
} & BaseState<typeof PLAN_TYPE_PLAN_SYNC>;
|
|
73
|
-
export type PlanType = "asyncPlan" | "plan"
|
|
75
|
+
export type PlanType = "asyncPlan" | "plan";
|
|
74
76
|
export declare const GENERATOR_NAME_ASYNC = "AsyncGeneratorFunction";
|
|
75
77
|
export declare const GENERATOR_NAME_SYNC = "GeneratorFunction";
|
|
76
78
|
export declare const PLAN_MESSAGE_PLAN_INPUT = "plan requires a generator function";
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { ArrayOrPlainObject, GenericCallback, Key } from "./index.mjs";
|
|
2
|
+
import { Aborter } from "./aborter.model.mjs";
|
|
3
|
+
import { Result } from "./result.model.mjs";
|
|
4
|
+
//#region src/models/promise.model.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* A _Promise_ that can be canceled
|
|
7
|
+
*/
|
|
8
|
+
export declare class CancelablePromise<Value = void> extends Promise<Value> {
|
|
9
|
+
#private;
|
|
10
|
+
constructor(executor: (resolve: (value: Value) => void, reject: (reason: unknown) => void) => void);
|
|
11
|
+
/**
|
|
12
|
+
* Cancel the _Promise_, rejecting it with an optional reason
|
|
13
|
+
*
|
|
14
|
+
* @param reason Optional reason for canceling the _Promise_
|
|
15
|
+
*/
|
|
16
|
+
cancel(reason?: unknown): void;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A _Promise_ that was fulfilled
|
|
20
|
+
*/
|
|
21
|
+
export type FulfilledPromise<Value> = {
|
|
22
|
+
/**
|
|
23
|
+
* Status of the _Promise_
|
|
24
|
+
*/
|
|
25
|
+
status: typeof PROMISE_TYPE_FULFILLED;
|
|
26
|
+
/**
|
|
27
|
+
* Value of the _Promise_
|
|
28
|
+
*/
|
|
29
|
+
value: Awaited<Value>;
|
|
30
|
+
};
|
|
31
|
+
export type PromiseData = {
|
|
32
|
+
last: number;
|
|
33
|
+
result: ArrayOrPlainObject;
|
|
34
|
+
};
|
|
35
|
+
export type PromiseHandlers = {
|
|
36
|
+
resolve(value: unknown[]): void;
|
|
37
|
+
reject(reason: unknown): void;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Options for a _Promise_-handling function
|
|
41
|
+
*/
|
|
42
|
+
export type PromiseOptions = {
|
|
43
|
+
/**
|
|
44
|
+
* AbortSignal for aborting the _Promise_; when aborted, the _Promise_ will reject with the reason of the signal
|
|
45
|
+
*/
|
|
46
|
+
signal?: AbortSignal;
|
|
47
|
+
/**
|
|
48
|
+
* How long to wait for _(in milliseconds; defaults to `0`)_
|
|
49
|
+
*/
|
|
50
|
+
time?: number;
|
|
51
|
+
};
|
|
52
|
+
export type PromiseParameters = {
|
|
53
|
+
aborter?: Aborter;
|
|
54
|
+
complete: boolean;
|
|
55
|
+
data: PromiseData;
|
|
56
|
+
handlers: PromiseHandlers;
|
|
57
|
+
index: number;
|
|
58
|
+
key: Key;
|
|
59
|
+
value?: unknown;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* _Promise_ handling strategy
|
|
63
|
+
*
|
|
64
|
+
* - `complete`: wait for all _Promises_ to settle, then return the results, as an array of fulfilled and/or rejected results
|
|
65
|
+
* - `first`: rejects on the first rejected _Promise_, and returns an array of values
|
|
66
|
+
*/
|
|
67
|
+
export type PromiseStrategy = "complete" | "first";
|
|
68
|
+
/**
|
|
69
|
+
* An error thrown when a promise times out
|
|
70
|
+
*/
|
|
71
|
+
export declare class PromiseTimeoutError extends Error {
|
|
72
|
+
constructor();
|
|
73
|
+
}
|
|
74
|
+
export type PromisesItems<Items extends ArrayOrPlainObject> = { [ItemsKey in keyof Items]: Items[ItemsKey] extends GenericCallback ? ReturnType<Items[ItemsKey]> extends Promise<infer Value> ? Promise<Value> : never : Items[ItemsKey] extends Promise<infer Value> ? Promise<Value> : Promise<Items[ItemsKey]>; };
|
|
75
|
+
/**
|
|
76
|
+
* Options for handling multiple _Promises_
|
|
77
|
+
*/
|
|
78
|
+
export type PromisesOptions = {
|
|
79
|
+
/**
|
|
80
|
+
* AbortSignal for aborting the _Promises_; when aborted, the _Promises_ will reject with the reason of the signal
|
|
81
|
+
*/
|
|
82
|
+
signal?: AbortSignal;
|
|
83
|
+
/**
|
|
84
|
+
* Strategy for handling the _Promises_; defaults to `complete`
|
|
85
|
+
*/
|
|
86
|
+
strategy?: PromiseStrategy;
|
|
87
|
+
};
|
|
88
|
+
export type PromisesResult<Items extends ArrayOrPlainObject> = { [ItemsKey in keyof Items]: Items[ItemsKey] extends Promise<infer Value> ? Result<Awaited<Value>> : never; };
|
|
89
|
+
export type PromisesUnwrapped<Items extends ArrayOrPlainObject> = { [ItemsKey in keyof Items]: Items[ItemsKey] extends GenericCallback ? ReturnType<Items[ItemsKey]> extends Promise<infer Value> ? Awaited<Value> : never : Items[ItemsKey] extends Promise<infer Value> ? Awaited<Value> : never; } extends (infer Result) ? Result : never;
|
|
90
|
+
export type PromisesValue<Value> = FulfilledPromise<Value> | RejectedPromise;
|
|
91
|
+
export type PromisesValues<Items extends ArrayOrPlainObject> = { [ItemsKey in keyof Items]: Items[ItemsKey] extends Promise<infer Value> ? PromisesValue<Awaited<Value>> : never; } extends (infer Result) ? Result : never;
|
|
92
|
+
/**
|
|
93
|
+
* A _Promise_ that was rejected
|
|
94
|
+
*/
|
|
95
|
+
export type RejectedPromise = {
|
|
96
|
+
/**
|
|
97
|
+
* Status of the _Promise_
|
|
98
|
+
*/
|
|
99
|
+
status: typeof PROMISE_TYPE_REJECTED;
|
|
100
|
+
/**
|
|
101
|
+
* Reason for the rejection
|
|
102
|
+
*/
|
|
103
|
+
reason: unknown;
|
|
104
|
+
};
|
|
105
|
+
export declare const PROMISE_ABORT_EVENT = "abort";
|
|
106
|
+
export declare const PROMISE_ABORT_OPTIONS: {
|
|
107
|
+
once: boolean;
|
|
108
|
+
};
|
|
109
|
+
export declare const PROMISE_ERROR_NAME = "PromiseTimeoutError";
|
|
110
|
+
export declare const PROMISE_MESSAGE_EXPECTATION_ATTEMPT = "Attempt expected a function or a promise";
|
|
111
|
+
export declare const PROMISE_MESSAGE_EXPECTATION_ITEMS_TYPE = "promises expected an array or object holding promise-functions or promises";
|
|
112
|
+
export declare const PROMISE_MESSAGE_EXPECTATION_RESULT = "toResult expected a Promise";
|
|
113
|
+
export declare const PROMISE_MESSAGE_EXPECTATION_TIMED = "Timed function expected a Promise";
|
|
114
|
+
export declare const PROMISE_MESSAGE_TIMEOUT = "Promise timed out";
|
|
115
|
+
export declare const PROMISE_STRATEGY_ALL: Set<PromiseStrategy>;
|
|
116
|
+
export declare const PROMISE_STRATEGY_DEFAULT: PromiseStrategy;
|
|
117
|
+
export declare const PROMISE_TYPE_FULFILLED = "fulfilled";
|
|
118
|
+
export declare const PROMISE_TYPE_REJECTED = "rejected";
|
|
119
|
+
//#endregion
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
//#region src/models/promise.model.ts
|
|
2
|
+
/**
|
|
3
|
+
* A _Promise_ that can be canceled
|
|
4
|
+
*/
|
|
5
|
+
var CancelablePromise = class extends Promise {
|
|
6
|
+
#rejector;
|
|
7
|
+
constructor(executor) {
|
|
8
|
+
let rejector;
|
|
9
|
+
super((resolve, reject) => {
|
|
10
|
+
rejector = reject;
|
|
11
|
+
executor(resolve, reject);
|
|
12
|
+
});
|
|
13
|
+
this.#rejector = rejector;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Cancel the _Promise_, rejecting it with an optional reason
|
|
17
|
+
*
|
|
18
|
+
* @param reason Optional reason for canceling the _Promise_
|
|
19
|
+
*/
|
|
20
|
+
cancel(reason) {
|
|
21
|
+
this.#rejector?.(reason);
|
|
22
|
+
this.#rejector = void 0;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* An error thrown when a promise times out
|
|
27
|
+
*/
|
|
28
|
+
var PromiseTimeoutError = class extends Error {
|
|
29
|
+
constructor() {
|
|
30
|
+
super(PROMISE_MESSAGE_TIMEOUT);
|
|
31
|
+
this.name = PROMISE_ERROR_NAME;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
const PROMISE_ABORT_EVENT = "abort";
|
|
35
|
+
const PROMISE_ABORT_OPTIONS = { once: true };
|
|
36
|
+
const PROMISE_ERROR_NAME = "PromiseTimeoutError";
|
|
37
|
+
const PROMISE_MESSAGE_EXPECTATION_ATTEMPT = "Attempt expected a function or a promise";
|
|
38
|
+
const PROMISE_MESSAGE_EXPECTATION_ITEMS_TYPE = "promises expected an array or object holding promise-functions or promises";
|
|
39
|
+
const PROMISE_MESSAGE_EXPECTATION_RESULT = "toResult expected a Promise";
|
|
40
|
+
const PROMISE_MESSAGE_EXPECTATION_TIMED = "Timed function expected a Promise";
|
|
41
|
+
const PROMISE_MESSAGE_TIMEOUT = "Promise timed out";
|
|
42
|
+
const PROMISE_STRATEGY_ALL = /* @__PURE__ */ new Set(["complete", "first"]);
|
|
43
|
+
const PROMISE_STRATEGY_DEFAULT = "complete";
|
|
44
|
+
const PROMISE_TYPE_FULFILLED = "fulfilled";
|
|
45
|
+
const PROMISE_TYPE_REJECTED = "rejected";
|
|
46
|
+
//#endregion
|
|
47
|
+
export { CancelablePromise, PROMISE_ABORT_EVENT, PROMISE_ABORT_OPTIONS, PROMISE_ERROR_NAME, PROMISE_MESSAGE_EXPECTATION_ATTEMPT, PROMISE_MESSAGE_EXPECTATION_ITEMS_TYPE, PROMISE_MESSAGE_EXPECTATION_RESULT, PROMISE_MESSAGE_EXPECTATION_TIMED, PROMISE_MESSAGE_TIMEOUT, PROMISE_STRATEGY_ALL, PROMISE_STRATEGY_DEFAULT, PROMISE_TYPE_FULFILLED, PROMISE_TYPE_REJECTED, PromiseTimeoutError };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/models/query.model.d.ts
|
|
2
|
+
export declare const QUERY_AMPERSAND = "&";
|
|
3
|
+
export declare const QUERY_DOT = ".";
|
|
4
|
+
export declare const QUERY_EQUAL = "=";
|
|
5
|
+
export declare const QUERY_EXPRESSION_ARRAY_SUFFIX: RegExp;
|
|
6
|
+
export declare const QUERY_EXPRESSION_BOOLEAN: RegExp;
|
|
7
|
+
export declare const QUERY_TRUE = "true";
|
|
8
|
+
export declare const QUERY_TYPES: Set<string>;
|
|
9
|
+
//#endregion
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/models/query.model.ts
|
|
2
|
+
const QUERY_AMPERSAND = "&";
|
|
3
|
+
const QUERY_DOT = ".";
|
|
4
|
+
const QUERY_EQUAL = "=";
|
|
5
|
+
const QUERY_EXPRESSION_ARRAY_SUFFIX = /\[\]$/;
|
|
6
|
+
const QUERY_EXPRESSION_BOOLEAN = /^(false|true)$/;
|
|
7
|
+
const QUERY_TRUE = "true";
|
|
8
|
+
const QUERY_TYPES = /* @__PURE__ */ new Set([
|
|
9
|
+
"boolean",
|
|
10
|
+
"number",
|
|
11
|
+
"string"
|
|
12
|
+
]);
|
|
13
|
+
//#endregion
|
|
14
|
+
export { QUERY_AMPERSAND, QUERY_DOT, QUERY_EQUAL, QUERY_EXPRESSION_ARRAY_SUFFIX, QUERY_EXPRESSION_BOOLEAN, QUERY_TRUE, QUERY_TYPES };
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { GenericAsyncCallback, GenericCallback } from "./index.mjs";
|
|
2
|
+
import { Aborter } from "./aborter.model.mjs";
|
|
3
|
+
//#region src/models/queue.model.d.ts
|
|
4
|
+
export type InternalKeyedQueue = {
|
|
5
|
+
[QUEUE_SYMBOL]: KeyedQueueState;
|
|
6
|
+
} & KeyedQueue<GenericAsyncCallback, unknown[]>;
|
|
7
|
+
export type InternalQueue = {
|
|
8
|
+
[QUEUE_SYMBOL]: QueueState;
|
|
9
|
+
} & Queue<GenericAsyncCallback, unknown[]>;
|
|
10
|
+
/**
|
|
11
|
+
* A queue that can be used to manage (a)synchronous tasks with a specific key
|
|
12
|
+
*/
|
|
13
|
+
export type KeyedQueue<Callback extends GenericCallback | GenericAsyncCallback, CallbackParameters extends unknown[] = Parameters<Callback>> = {
|
|
14
|
+
/**
|
|
15
|
+
* Get keys of all active queues
|
|
16
|
+
*/
|
|
17
|
+
get active(): string[];
|
|
18
|
+
/**
|
|
19
|
+
* Does the queue automatically start when the first item is added?
|
|
20
|
+
*/
|
|
21
|
+
get autostart(): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Maximum number of runners to process the queue concurrently
|
|
24
|
+
*/
|
|
25
|
+
get concurrency(): number;
|
|
26
|
+
/**
|
|
27
|
+
* Get keys of all empty queues
|
|
28
|
+
*/
|
|
29
|
+
get empty(): string[];
|
|
30
|
+
/**
|
|
31
|
+
* Get keys of all full queues
|
|
32
|
+
*/
|
|
33
|
+
get full(): string[];
|
|
34
|
+
/**
|
|
35
|
+
* Number of items in all queues
|
|
36
|
+
*/
|
|
37
|
+
get items(): Record<string, number>;
|
|
38
|
+
/**
|
|
39
|
+
* Keys of all queues
|
|
40
|
+
*/
|
|
41
|
+
get keys(): string[];
|
|
42
|
+
/**
|
|
43
|
+
* Maximum number of items allowed in the queue
|
|
44
|
+
*/
|
|
45
|
+
get maximum(): number;
|
|
46
|
+
/**
|
|
47
|
+
* Are all queues paused?
|
|
48
|
+
*/
|
|
49
|
+
get paused(): string[];
|
|
50
|
+
/**
|
|
51
|
+
* Number of queues
|
|
52
|
+
*/
|
|
53
|
+
get queues(): number;
|
|
54
|
+
/**
|
|
55
|
+
* Queue an item for a specific key
|
|
56
|
+
*
|
|
57
|
+
* @param key Key to queue the item for
|
|
58
|
+
* @param parameters Parameters to use when item runs
|
|
59
|
+
* @param signal Optional signal to abort the item
|
|
60
|
+
* @returns Queued item
|
|
61
|
+
*/
|
|
62
|
+
add(key: string, parameters: Tail<CallbackParameters>, signal?: AbortSignal): Queued<ReturnType<Callback>>;
|
|
63
|
+
/**
|
|
64
|
+
* Clear all items for a specific key _(or all items for all keys, if no key is provided)_
|
|
65
|
+
*
|
|
66
|
+
* @param key Optional key to clear the queue for
|
|
67
|
+
*/
|
|
68
|
+
clear(key?: string): void;
|
|
69
|
+
/**
|
|
70
|
+
* Get the queue for a specific key
|
|
71
|
+
*
|
|
72
|
+
* @param key Key to get the queue for
|
|
73
|
+
* @returns Queue for the key, or `undefined` if it doesn't exist
|
|
74
|
+
*/
|
|
75
|
+
get(key: string): Queue<Callback, Tail<CallbackParameters>> | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* Pause the queue for a specific key _(or all queues, if no key is provided)_
|
|
78
|
+
*
|
|
79
|
+
* @param key Optional key to pause the queue for
|
|
80
|
+
*/
|
|
81
|
+
pause(key?: string): void;
|
|
82
|
+
/**
|
|
83
|
+
* Remove a specific item for a specific key
|
|
84
|
+
*
|
|
85
|
+
* @param key Key to remove the item for
|
|
86
|
+
* @param id ID of the item to remove
|
|
87
|
+
*/
|
|
88
|
+
remove(key: string, id: number): void;
|
|
89
|
+
/**
|
|
90
|
+
* Remove a queue and its items for a specific key
|
|
91
|
+
*
|
|
92
|
+
* _(To remove all items for a specific key, use `clear()` instead)_
|
|
93
|
+
*
|
|
94
|
+
* @param key Key to remove the queue for
|
|
95
|
+
*/
|
|
96
|
+
remove(key: string): void;
|
|
97
|
+
/**
|
|
98
|
+
* Remove all queues and their items
|
|
99
|
+
*/
|
|
100
|
+
remove(): void;
|
|
101
|
+
/**
|
|
102
|
+
* Resume the queue for a specific key _(or all queues, if no key is provided)_
|
|
103
|
+
*
|
|
104
|
+
* @param key Optional key to resume the queue for
|
|
105
|
+
*/
|
|
106
|
+
resume(key?: string): void;
|
|
107
|
+
};
|
|
108
|
+
export type KeyedQueueState = {
|
|
109
|
+
callback: GenericCallback | GenericAsyncCallback;
|
|
110
|
+
options: Required<QueueOptions>;
|
|
111
|
+
queues: Map<string, Queue<GenericAsyncCallback, Tail<unknown[]>>>;
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* A queue that can be used to manage (a)synchronous tasks
|
|
115
|
+
*/
|
|
116
|
+
export type Queue<Callback extends GenericCallback | GenericAsyncCallback, CallbackParameters extends unknown[] = Parameters<Callback>> = {
|
|
117
|
+
/**
|
|
118
|
+
* Is the queue active?
|
|
119
|
+
*/
|
|
120
|
+
get active(): boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Does the queue automatically start when the first item is added?
|
|
123
|
+
*/
|
|
124
|
+
get autostart(): boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Maximum number of runners to process the queue concurrently
|
|
127
|
+
*/
|
|
128
|
+
get concurrency(): number;
|
|
129
|
+
/**
|
|
130
|
+
* Is the queue empty?
|
|
131
|
+
*/
|
|
132
|
+
get empty(): boolean;
|
|
133
|
+
/**
|
|
134
|
+
* Is the queue full?
|
|
135
|
+
*/
|
|
136
|
+
get full(): boolean;
|
|
137
|
+
/**
|
|
138
|
+
* Maximum number of items allowed in the queue
|
|
139
|
+
*/
|
|
140
|
+
get maximum(): number;
|
|
141
|
+
/**
|
|
142
|
+
* Is the queue paused?
|
|
143
|
+
*/
|
|
144
|
+
get paused(): boolean;
|
|
145
|
+
/**
|
|
146
|
+
* Number of items in the queue
|
|
147
|
+
*/
|
|
148
|
+
get size(): number;
|
|
149
|
+
/**
|
|
150
|
+
* Add an item to the queue
|
|
151
|
+
*
|
|
152
|
+
* @param parameters Parameters to use when item runs
|
|
153
|
+
* @param signal Optional signal to abort the item
|
|
154
|
+
* @returns Queued item
|
|
155
|
+
*/
|
|
156
|
+
add(parameters: CallbackParameters, signal?: AbortSignal): Queued<ReturnType<Callback>>;
|
|
157
|
+
/**
|
|
158
|
+
* Remove and reject all items in the queue
|
|
159
|
+
*/
|
|
160
|
+
clear(): void;
|
|
161
|
+
/**
|
|
162
|
+
* Pause the queue
|
|
163
|
+
*
|
|
164
|
+
* - Currently running items will not be stopped
|
|
165
|
+
* - New added items will not run until the queue is resumed
|
|
166
|
+
*/
|
|
167
|
+
pause(): void;
|
|
168
|
+
/**
|
|
169
|
+
* Remove and reject a specific item in the queue
|
|
170
|
+
*
|
|
171
|
+
* @param id ID of queued item
|
|
172
|
+
*/
|
|
173
|
+
remove(id: number): void;
|
|
174
|
+
/**
|
|
175
|
+
* Resume the queue
|
|
176
|
+
*/
|
|
177
|
+
resume(): void;
|
|
178
|
+
};
|
|
179
|
+
export type QueueHandleType = "clear" | "pause" | "resume";
|
|
180
|
+
export type QueueState = {
|
|
181
|
+
callback: GenericCallback | GenericAsyncCallback;
|
|
182
|
+
handled: GenericCallback[];
|
|
183
|
+
id: number;
|
|
184
|
+
items: Array<QueuedItem>;
|
|
185
|
+
key: string | undefined;
|
|
186
|
+
options: Required<QueueOptions>;
|
|
187
|
+
paused: boolean;
|
|
188
|
+
runners: number;
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* An error thrown by the Queue when an operation fails
|
|
192
|
+
*/
|
|
193
|
+
export declare class QueueError extends Error {
|
|
194
|
+
constructor(message: string);
|
|
195
|
+
}
|
|
196
|
+
export type QueueOptions = {
|
|
197
|
+
/**
|
|
198
|
+
* Automatically start processing the queue when the first item is added _(defaults to `true`)_
|
|
199
|
+
*/
|
|
200
|
+
autostart?: boolean;
|
|
201
|
+
/**
|
|
202
|
+
* Number of runners to process the queue concurrently _(defaults to `1`)_
|
|
203
|
+
*/
|
|
204
|
+
concurrency?: number;
|
|
205
|
+
/**
|
|
206
|
+
* Maximum number of items allowed in the queue _(defaults to `0`, which means no limit)_
|
|
207
|
+
*/
|
|
208
|
+
maximum?: number;
|
|
209
|
+
};
|
|
210
|
+
/**
|
|
211
|
+
* A queued item
|
|
212
|
+
*/
|
|
213
|
+
export type Queued<Value> = {
|
|
214
|
+
/**
|
|
215
|
+
* ID of the queued item _(can be used to remove it from the queue)_
|
|
216
|
+
*/
|
|
217
|
+
readonly id: number;
|
|
218
|
+
/**
|
|
219
|
+
* Queued promise
|
|
220
|
+
*/
|
|
221
|
+
readonly promise: Promise<Value extends Promise<infer Result> ? Result : Value>;
|
|
222
|
+
};
|
|
223
|
+
export type QueuedItem = {
|
|
224
|
+
aborter?: Aborter;
|
|
225
|
+
id: number;
|
|
226
|
+
key?: string;
|
|
227
|
+
parameters: unknown[];
|
|
228
|
+
promise: Promise<unknown>;
|
|
229
|
+
reject(reason?: unknown): void;
|
|
230
|
+
resolve(value: unknown): void;
|
|
231
|
+
};
|
|
232
|
+
export type QueueStatusKey = "active" | "empty" | "full" | "paused";
|
|
233
|
+
type Tail<Values extends any[]> = Values extends [infer _, ...infer Rest] ? Rest : never;
|
|
234
|
+
export declare const QUEUE_ERROR_NAME = "QueueError";
|
|
235
|
+
export declare const QUEUE_HANDLE_CLEAR: QueueHandleType;
|
|
236
|
+
export declare const QUEUE_HANDLE_PAUSE: QueueHandleType;
|
|
237
|
+
export declare const QUEUE_HANDLE_RESUME: QueueHandleType;
|
|
238
|
+
export declare const QUEUE_MESSAGE_CALLBACK = "A Queue requires a callback function";
|
|
239
|
+
export declare const QUEUE_MESSAGE_CLEAR = "Queue was cleared";
|
|
240
|
+
export declare const QUEUE_MESSAGE_KEY = "Key must be a non-empty string";
|
|
241
|
+
export declare const QUEUE_MESSAGE_MAXIMUM = "Queue has reached its maximum size";
|
|
242
|
+
export declare const QUEUE_MESSAGE_REMOVE = "Item removed from queue";
|
|
243
|
+
export declare const QUEUE_NAME_KEYED = "keyedQueue";
|
|
244
|
+
export declare const QUEUE_NAME_QUEUE = "queue";
|
|
245
|
+
export declare const QUEUE_PROPERTY = "$queue";
|
|
246
|
+
export declare const QUEUE_STATUS_ACTIVE: QueueStatusKey;
|
|
247
|
+
export declare const QUEUE_STATUS_EMPTY: QueueStatusKey;
|
|
248
|
+
export declare const QUEUE_STATUS_FULL: QueueStatusKey;
|
|
249
|
+
export declare const QUEUE_STATUS_PAUSED: QueueStatusKey;
|
|
250
|
+
export declare const QUEUE_SYMBOL: unique symbol;
|
|
251
|
+
//#endregion
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region src/models/queue.model.ts
|
|
2
|
+
/**
|
|
3
|
+
* An error thrown by the Queue when an operation fails
|
|
4
|
+
*/
|
|
5
|
+
var QueueError = class extends Error {
|
|
6
|
+
constructor(message) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.name = QUEUE_ERROR_NAME;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
const QUEUE_ERROR_NAME = "QueueError";
|
|
12
|
+
const QUEUE_HANDLE_CLEAR = "clear";
|
|
13
|
+
const QUEUE_HANDLE_PAUSE = "pause";
|
|
14
|
+
const QUEUE_HANDLE_RESUME = "resume";
|
|
15
|
+
const QUEUE_MESSAGE_CALLBACK = "A Queue requires a callback function";
|
|
16
|
+
const QUEUE_MESSAGE_CLEAR = "Queue was cleared";
|
|
17
|
+
const QUEUE_MESSAGE_KEY = "Key must be a non-empty string";
|
|
18
|
+
const QUEUE_MESSAGE_MAXIMUM = "Queue has reached its maximum size";
|
|
19
|
+
const QUEUE_MESSAGE_REMOVE = "Item removed from queue";
|
|
20
|
+
const QUEUE_NAME_KEYED = "keyedQueue";
|
|
21
|
+
const QUEUE_NAME_QUEUE = "queue";
|
|
22
|
+
const QUEUE_PROPERTY = "$queue";
|
|
23
|
+
const QUEUE_STATUS_ACTIVE = "active";
|
|
24
|
+
const QUEUE_STATUS_EMPTY = "empty";
|
|
25
|
+
const QUEUE_STATUS_FULL = "full";
|
|
26
|
+
const QUEUE_STATUS_PAUSED = "paused";
|
|
27
|
+
const QUEUE_SYMBOL = Symbol(QUEUE_PROPERTY);
|
|
28
|
+
//#endregion
|
|
29
|
+
export { QUEUE_ERROR_NAME, QUEUE_HANDLE_CLEAR, QUEUE_HANDLE_PAUSE, QUEUE_HANDLE_RESUME, QUEUE_MESSAGE_CALLBACK, QUEUE_MESSAGE_CLEAR, QUEUE_MESSAGE_KEY, QUEUE_MESSAGE_MAXIMUM, QUEUE_MESSAGE_REMOVE, QUEUE_NAME_KEYED, QUEUE_NAME_QUEUE, QUEUE_PROPERTY, QUEUE_STATUS_ACTIVE, QUEUE_STATUS_EMPTY, QUEUE_STATUS_FULL, QUEUE_STATUS_PAUSED, QUEUE_SYMBOL, QueueError };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
//#region src/models/random.model.d.ts
|
|
2
|
+
export declare const RANDOM_ALPHABET = "abcdefghijklmnopqrstuvwxyz";
|
|
3
|
+
export declare const RANDOM_BOOLEAN_MODIFIER = .5;
|
|
4
|
+
export declare const RANDOM_HEX_CHARACTERS = "0123456789ABCDEF";
|
|
5
|
+
export declare const RANDOM_HEX_MAXIMUM = 15;
|
|
6
|
+
//#endregion
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
//#region src/models/random.model.ts
|
|
2
|
+
const RANDOM_ALPHABET = "abcdefghijklmnopqrstuvwxyz";
|
|
3
|
+
const RANDOM_BOOLEAN_MODIFIER = .5;
|
|
4
|
+
const RANDOM_HEX_CHARACTERS = "0123456789ABCDEF";
|
|
5
|
+
const RANDOM_HEX_MAXIMUM = 15;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { RANDOM_ALPHABET, RANDOM_BOOLEAN_MODIFIER, RANDOM_HEX_CHARACTERS, RANDOM_HEX_MAXIMUM };
|
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
import { GenericCallback } from "
|
|
2
|
-
//#region src/
|
|
1
|
+
import { GenericCallback } from "./index.mjs";
|
|
2
|
+
//#region src/models/result.model.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* An unknown result
|
|
5
5
|
*/
|
|
6
6
|
export type AnyResult<Value, E> = Err<E> | ExtendedErr<E> | Ok<Value>;
|
|
7
|
+
/**
|
|
8
|
+
* A synchronous _Flow_, a function that attempts to pipe values through a series of functions
|
|
9
|
+
*/
|
|
10
|
+
export type AttemptFlow<Callback extends GenericCallback, Value> = (...args: Parameters<Callback>) => Result<UnwrapValue<Value>>;
|
|
11
|
+
/**
|
|
12
|
+
* An asynchronous _Flow_, a function that attempts to pipe values through a series of functions
|
|
13
|
+
*/
|
|
14
|
+
export type AttemptAsyncFlow<Callback extends GenericCallback, Value> = (...args: Parameters<Callback>) => Promise<Result<UnwrapValue<Value>>>;
|
|
7
15
|
/**
|
|
8
16
|
* An error result
|
|
9
17
|
*/
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/models/string/string.case.model.d.ts
|
|
2
|
+
export type StringCase = "camel" | "kebab" | "pascal" | "snake";
|
|
3
|
+
export type StringCaseOptions = {
|
|
4
|
+
capitalizeAny: boolean;
|
|
5
|
+
capitalizeFirst: boolean;
|
|
6
|
+
type: StringCase;
|
|
7
|
+
};
|
|
8
|
+
export declare const STRING_CASE_CAMEL: StringCase;
|
|
9
|
+
export declare const STRING_CASE_KEBAB: StringCase;
|
|
10
|
+
export declare const STRING_CASE_PASCAL: StringCase;
|
|
11
|
+
export declare const STRING_CASE_SNAKE: StringCase;
|
|
12
|
+
export declare const STRING_DELIMTER_EMPTY = "";
|
|
13
|
+
export declare const STRING_DELIMITER_HYPHEN = "-";
|
|
14
|
+
export declare const STRING_DELIMITER_UNDERSCORE = "_";
|
|
15
|
+
export declare const STRING_EXPRESSION_CAMEL_CASE: RegExp;
|
|
16
|
+
export declare const STRING_EXPRESSION_ACRONYM: RegExp;
|
|
17
|
+
export declare const STRING_REPLACEMENT_CAMEL_CASE = "$1-$2";
|
|
18
|
+
export declare const STRING_S = "s";
|
|
19
|
+
//#endregion
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/models/string/string.case.model.ts
|
|
2
|
+
const STRING_CASE_CAMEL = "camel";
|
|
3
|
+
const STRING_CASE_KEBAB = "kebab";
|
|
4
|
+
const STRING_CASE_PASCAL = "pascal";
|
|
5
|
+
const STRING_CASE_SNAKE = "snake";
|
|
6
|
+
const STRING_DELIMTER_EMPTY = "";
|
|
7
|
+
const STRING_DELIMITER_HYPHEN = "-";
|
|
8
|
+
const STRING_DELIMITER_UNDERSCORE = "_";
|
|
9
|
+
const STRING_EXPRESSION_CAMEL_CASE = /(\p{Ll})(\p{Lu})/gu;
|
|
10
|
+
const STRING_EXPRESSION_ACRONYM = /(\p{Lu}*)(\p{Lu})(\p{Ll}+)/gu;
|
|
11
|
+
const STRING_REPLACEMENT_CAMEL_CASE = "$1-$2";
|
|
12
|
+
const STRING_S = "s";
|
|
13
|
+
//#endregion
|
|
14
|
+
export { STRING_CASE_CAMEL, STRING_CASE_KEBAB, STRING_CASE_PASCAL, STRING_CASE_SNAKE, STRING_DELIMITER_HYPHEN, STRING_DELIMITER_UNDERSCORE, STRING_DELIMTER_EMPTY, STRING_EXPRESSION_ACRONYM, STRING_EXPRESSION_CAMEL_CASE, STRING_REPLACEMENT_CAMEL_CASE, STRING_S };
|