@oscarpalmer/atoms 0.216.0 → 0.218.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/insert.mjs +1 -1
- package/dist/array/slice.mjs +27 -14
- package/dist/array/sort.mjs +2 -1
- package/dist/array/swap.d.mts +2 -1
- package/dist/color/constants.d.mts +2 -1
- package/dist/color/misc/get.mjs +3 -1
- package/dist/color/space/hex.mjs +1 -1
- package/dist/color/space/rgb.d.mts +1 -0
- package/dist/function/index.mjs +1 -2
- package/dist/function/retry.d.mts +1 -1
- package/dist/function/retry.mjs +5 -2
- package/dist/herald.mjs +1 -2
- package/dist/index.d.mts +335 -113
- package/dist/index.mjs +483 -241
- package/dist/internal/array/find.mjs +57 -34
- package/dist/internal/array/insert.mjs +1 -1
- package/dist/internal/array/match.mjs +21 -17
- package/dist/internal/array/sets.mjs +7 -1
- package/dist/internal/math/aggregate.mjs +4 -1
- package/dist/internal/number.d.mts +1 -1
- package/dist/internal/number.mjs +4 -2
- package/dist/internal/plan/index.d.mts +7 -0
- package/dist/internal/plan/index.mjs +18 -0
- package/dist/{plan/generate.d.mts → internal/plan/plan.generate.d.mts} +2 -2
- package/dist/{plan/generate.mjs → internal/plan/plan.generate.mjs} +7 -7
- package/dist/internal/random.d.mts +6 -0
- package/dist/internal/random.mjs +13 -2
- package/dist/internal/result/attempt.mjs +4 -4
- package/dist/internal/string/misc.mjs +2 -1
- package/dist/internal/subscription.mjs +1 -1
- package/dist/internal/value/equal.mjs +2 -1
- package/dist/internal/value/partial.mjs +3 -1
- package/dist/models/color.model.d.mts +2 -1
- package/dist/models/function/once.model.d.mts +2 -1
- package/dist/models/index.d.mts +2 -1
- package/dist/models/plan.model.d.mts +160 -29
- package/dist/models/plan.model.mjs +15 -5
- package/dist/models/queue.model.d.mts +2 -1
- package/dist/models/result.model.d.mts +2 -1
- package/dist/models/string/string.fuzzy.model.d.mts +1 -1
- package/dist/models/string/string.misc.model.mjs +1 -1
- package/dist/models/value/value.equal.model.d.mts +2 -1
- package/dist/models/value/value.merge.model.d.mts +3 -2
- package/dist/models/value/value.misc.model.d.mts +2 -1
- package/dist/number.mjs +1 -2
- package/dist/plan/index.d.mts +1 -4
- package/dist/plan/index.mjs +14 -15
- package/dist/plan/is.d.mts +59 -3
- package/dist/plan/is.mjs +82 -10
- package/dist/plan/misc.d.mts +51 -3
- package/dist/plan/misc.mjs +47 -30
- package/dist/plan/models.d.mts +2 -2
- package/dist/plan/result.d.mts +15 -3
- package/dist/plan/result.mjs +5 -11
- package/dist/plan/run.d.mts +1 -3
- package/dist/plan/run.mjs +5 -11
- package/dist/plan/use.d.mts +36 -0
- package/dist/plan/use.mjs +69 -0
- package/dist/promise/index.d.mts +6 -4
- package/dist/promise/index.mjs +4 -4
- package/dist/promise/misc.mjs +5 -2
- package/dist/promise/models.mjs +1 -2
- package/dist/promise/timed.mjs +2 -2
- package/dist/queue.mjs +4 -5
- package/dist/random.d.mts +2 -2
- package/dist/random.mjs +3 -3
- package/dist/result/index.mjs +1 -2
- package/dist/result/match.mjs +2 -2
- package/dist/result/misc.mjs +3 -10
- package/dist/result/work/pipe.d.mts +26 -23
- package/dist/result/work/pipe.mjs +7 -3
- package/dist/string/fuzzy.mjs +1 -1
- package/dist/string/index.mjs +1 -1
- package/dist/subscription.mjs +1 -2
- package/dist/value/clone.mjs +1 -1
- package/dist/value/merge.mjs +17 -4
- package/package.json +8 -10
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
import { Err, Ok, Result } from "./result.model.mjs";
|
|
2
2
|
//#region src/models/plan.model.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* An immediately failing asynchronous plan
|
|
5
|
+
*/
|
|
6
|
+
export type AsyncFailure<Value> = {
|
|
7
|
+
/**
|
|
8
|
+
* Get the generator for the failed plan
|
|
9
|
+
*
|
|
10
|
+
* @returns Generator
|
|
11
|
+
*/
|
|
12
|
+
[Symbol.asyncIterator]: () => AsyncGenerator<Err<Value>, never>;
|
|
13
|
+
};
|
|
3
14
|
/**
|
|
4
15
|
* An asynchronous plan of execution that can yield intermediate results and eventually return a result
|
|
5
16
|
*/
|
|
@@ -26,21 +37,106 @@ export type AsyncPlan<Yielded, Returned, Parameters extends unknown[]> = {
|
|
|
26
37
|
*/
|
|
27
38
|
run: Parameters extends [infer _, ...(infer _)[]] ? (parameters: Parameters, signal?: AbortSignal) => Promise<PlanReturned<Returned>> : (signal?: AbortSignal) => Promise<PlanReturned<Returned>>;
|
|
28
39
|
};
|
|
40
|
+
/**
|
|
41
|
+
* An immediately succeeding or failing asynchronous plan
|
|
42
|
+
*/
|
|
43
|
+
export type AsyncPlanned<Value, Error> = AsyncSuccess<Value> | AsyncFailure<Error>;
|
|
44
|
+
export type AsyncPlannedState = {
|
|
45
|
+
generator: () => AsyncGenerator;
|
|
46
|
+
type: typeof PLAN_FAILURE_ASYNC | typeof PLAN_SUCCESS_ASYNC;
|
|
47
|
+
};
|
|
29
48
|
export type AsyncPlanState = {
|
|
30
49
|
generator(...parameters: unknown[]): AsyncGenerator;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
50
|
+
type: typeof PLAN_TYPE_ASYNC;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* A single asynchronous step within a plan of execution
|
|
54
|
+
*/
|
|
55
|
+
export type AsyncStep<Input> = {
|
|
56
|
+
/**
|
|
57
|
+
* Get the asynchronous generator for the step
|
|
58
|
+
*
|
|
59
|
+
* @returns Asynchronous generator
|
|
60
|
+
*/
|
|
61
|
+
[Symbol.asyncIterator]: () => AsyncGenerator<AsyncStepYielded<Input>, AsyncStepReturned<Input>>;
|
|
62
|
+
};
|
|
63
|
+
type AsyncStepReturned<Input> = AsyncStepReturnedItem<Awaited<Input>>;
|
|
64
|
+
type AsyncStepReturnedItem<Input> = Input extends {
|
|
65
|
+
[Symbol.asyncIterator](): AsyncGenerator<infer _, infer Returned>;
|
|
66
|
+
} ? Returned : StepReturned<Input>;
|
|
67
|
+
export type AsyncStepState = {
|
|
68
|
+
generator: () => AsyncGenerator;
|
|
69
|
+
type: typeof PLAN_STEP_ASYNC;
|
|
70
|
+
};
|
|
71
|
+
export type AsyncStepValue<Input> = [Extract<Awaited<Input>, InvalidAsyncStepValue<Awaited<Input>>>] extends [never] ? unknown : never;
|
|
72
|
+
type AsyncStepYielded<Input> = AsyncStepYieldedItem<Awaited<Input>>;
|
|
73
|
+
type AsyncStepYieldedItem<Input> = Input extends {
|
|
74
|
+
[Symbol.asyncIterator](): AsyncGenerator<infer Yielded>;
|
|
75
|
+
} ? Yielded : StepYielded<Input>;
|
|
76
|
+
/**
|
|
77
|
+
* An immediately successful asynchronous plan
|
|
78
|
+
*/
|
|
79
|
+
export type AsyncSuccess<Value> = {
|
|
80
|
+
/**
|
|
81
|
+
* Get the generator for the successful plan
|
|
82
|
+
*
|
|
83
|
+
* @returns Generator
|
|
84
|
+
*/
|
|
85
|
+
[Symbol.asyncIterator]: () => AsyncGenerator<never, Value>;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* An immediately failing plan
|
|
89
|
+
*/
|
|
90
|
+
export type Failure<Value> = {
|
|
91
|
+
/**
|
|
92
|
+
* Get the generator for the failed plan
|
|
93
|
+
*
|
|
94
|
+
* @returns Generator
|
|
95
|
+
*/
|
|
96
|
+
[Symbol.iterator]: () => Generator<Err<Value>, never>;
|
|
97
|
+
};
|
|
98
|
+
export type GenericPlanItem = {
|
|
99
|
+
[PLAN_SYMBOL]: GenericPlanItemState;
|
|
100
|
+
[Symbol.asyncIterator]: () => AsyncGenerator;
|
|
101
|
+
[Symbol.iterator]: () => Generator;
|
|
102
|
+
};
|
|
103
|
+
export type GenericPlanItemState = {
|
|
104
|
+
generator: () => AsyncGenerator | Generator;
|
|
105
|
+
type: PlanType | PlannedType | StepType;
|
|
34
106
|
};
|
|
107
|
+
export type InternalAsyncFailure = {
|
|
108
|
+
[PLAN_SYMBOL]: AsyncPlannedState;
|
|
109
|
+
} & AsyncFailure<never>;
|
|
35
110
|
export type InternalAsyncPlan = {
|
|
36
111
|
[PLAN_SYMBOL]: AsyncPlanState;
|
|
37
112
|
} & AsyncPlan<never, never, unknown[]>;
|
|
113
|
+
export type InternalAsyncStep = {
|
|
114
|
+
[PLAN_SYMBOL]: AsyncStepState;
|
|
115
|
+
} & AsyncStep<never>;
|
|
116
|
+
export type InternalAsyncSuccess = {
|
|
117
|
+
[PLAN_SYMBOL]: AsyncPlannedState;
|
|
118
|
+
} & AsyncSuccess<never>;
|
|
119
|
+
export type InternalFailure = {
|
|
120
|
+
[PLAN_SYMBOL]: PlannedState;
|
|
121
|
+
} & Failure<never>;
|
|
38
122
|
export type InternalPlan = {
|
|
39
123
|
[PLAN_SYMBOL]: PlanState;
|
|
40
124
|
} & Plan<never, never, unknown[]>;
|
|
41
|
-
export type
|
|
42
|
-
[PLAN_SYMBOL]:
|
|
43
|
-
}
|
|
125
|
+
export type InternalSuccess = {
|
|
126
|
+
[PLAN_SYMBOL]: PlannedState;
|
|
127
|
+
} & Success<never>;
|
|
128
|
+
export type InternalStep = {
|
|
129
|
+
[PLAN_SYMBOL]: StepState;
|
|
130
|
+
} & Step<never>;
|
|
131
|
+
type InvalidAsyncStepValue<Input> = ((...args: any[]) => unknown) | ParameterizedPlan<Input>;
|
|
132
|
+
type InvalidStepValue<Input> = ((...args: any[]) => unknown) | {
|
|
133
|
+
[Symbol.asyncIterator]: unknown;
|
|
134
|
+
} | ParameterizedPlan<Input> | Promise<unknown>;
|
|
135
|
+
type ParameterizedPlan<Input> = Input extends {
|
|
136
|
+
[Symbol.iterator]: (...parameters: infer Parameters) => unknown;
|
|
137
|
+
} ? [] extends Parameters ? never : Input : Input extends {
|
|
138
|
+
[Symbol.asyncIterator]: (...parameters: infer Parameters) => unknown;
|
|
139
|
+
} ? [] extends Parameters ? never : Input : never;
|
|
44
140
|
/**
|
|
45
141
|
* A plan of execution that can yield intermediate results and eventually return a result
|
|
46
142
|
*/
|
|
@@ -68,35 +164,60 @@ export type Plan<Yielded, Returned, Parameters extends unknown[]> = {
|
|
|
68
164
|
run(...parameters: Parameters): PlanReturned<Returned>;
|
|
69
165
|
};
|
|
70
166
|
/**
|
|
71
|
-
* An
|
|
167
|
+
* An OK result of a plan execution
|
|
72
168
|
*/
|
|
73
|
-
export type PlanFailure<E> = {
|
|
74
|
-
/**
|
|
75
|
-
* Get the generator for the failed plan
|
|
76
|
-
*
|
|
77
|
-
* @returns Generator
|
|
78
|
-
*/
|
|
79
|
-
[Symbol.iterator]: () => Generator<Err<E>, never>;
|
|
80
|
-
};
|
|
81
169
|
export type PlanOk<Returned> = Returned extends Error ? never : Returned extends Err<infer _> ? never : Returned extends Ok<infer Value> ? Value : Returned;
|
|
82
170
|
type PlanErrors<Yielded, Returned> = PlanErrorValues<Yielded> | PlanErrorValues<Returned>;
|
|
171
|
+
/**
|
|
172
|
+
* An error result of a plan execution
|
|
173
|
+
*/
|
|
83
174
|
export type PlanError<Yielded, Returned> = [PlanErrors<Yielded, Returned>] extends [never] ? Error : PlanErrorValues<Yielded> | PlanErrorValues<Returned>;
|
|
84
|
-
type PlanErrorValues<Original> = Original extends Error ? Original : Original extends Err<infer E> ? E : Original extends
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
175
|
+
type PlanErrorValues<Original> = Original extends Error ? Original : Original extends Err<infer E> ? E : Original extends Failure<infer E> ? E : never;
|
|
176
|
+
/**
|
|
177
|
+
* The returned result of a plan execution _(excluding errors, which are thrown)_
|
|
178
|
+
*/
|
|
88
179
|
export type PlanReturned<Returned> = Returned extends Error ? never : Returned extends Err<infer _> ? never : Returned;
|
|
89
180
|
/**
|
|
90
|
-
* An immediately
|
|
181
|
+
* An immediately succeeding or failing plan
|
|
91
182
|
*/
|
|
92
|
-
export type
|
|
183
|
+
export type Planned<Value, Error> = Success<Value> | Failure<Error>;
|
|
184
|
+
export type PlannedState = {
|
|
185
|
+
generator: () => Generator;
|
|
186
|
+
type: typeof PLAN_FAILURE_SYNC | typeof PLAN_SUCCESS_SYNC;
|
|
187
|
+
};
|
|
188
|
+
export type PlannedType = "asyncFailure" | "asyncSuccess" | "failure" | "success";
|
|
93
189
|
export type PlanState = {
|
|
94
190
|
generator(...parameters: unknown[]): Generator;
|
|
95
|
-
|
|
191
|
+
type: typeof PLAN_TYPE_SYNC;
|
|
192
|
+
};
|
|
193
|
+
/**
|
|
194
|
+
* A single step within a plan of execution
|
|
195
|
+
*/
|
|
196
|
+
export type Step<Input> = {
|
|
197
|
+
/**
|
|
198
|
+
* Get the generator for the step
|
|
199
|
+
*
|
|
200
|
+
* @returns Generator
|
|
201
|
+
*/
|
|
202
|
+
[Symbol.iterator]: () => Generator<StepYielded<Input>, StepReturned<Input>>;
|
|
203
|
+
};
|
|
204
|
+
type StepReturned<Input> = Input extends Error ? never : Input extends Err<infer _> ? never : Input extends Ok<infer Value> ? Value : Input extends {
|
|
205
|
+
[Symbol.iterator](): Generator<infer _, infer Returned>;
|
|
206
|
+
} ? Returned : Input;
|
|
207
|
+
export type StepState = {
|
|
208
|
+
generator: () => Generator;
|
|
209
|
+
type: typeof PLAN_STEP_SYNC;
|
|
210
|
+
};
|
|
211
|
+
export type StepType = "asyncStep" | "step";
|
|
212
|
+
export type StepValue<Input> = [Extract<Input, InvalidStepValue<Input>>] extends [never] ? unknown : never;
|
|
213
|
+
type StepYielded<Input> = Input extends Error ? Err<Input> : Input extends Err<infer _> ? Input : Input extends {
|
|
214
|
+
[Symbol.iterator](): Generator<infer Yielded>;
|
|
215
|
+
} ? Yielded : never;
|
|
216
|
+
export type PlanType = "asyncPlan" | "plan";
|
|
96
217
|
/**
|
|
97
218
|
* An immediately successful plan
|
|
98
219
|
*/
|
|
99
|
-
export type
|
|
220
|
+
export type Success<Value> = {
|
|
100
221
|
/**
|
|
101
222
|
* Get the generator for the successful plan
|
|
102
223
|
*
|
|
@@ -104,12 +225,22 @@ export type PlanSuccess<Value> = {
|
|
|
104
225
|
*/
|
|
105
226
|
[Symbol.iterator]: () => Generator<never, Value>;
|
|
106
227
|
};
|
|
107
|
-
export
|
|
108
|
-
export declare const
|
|
109
|
-
export declare const
|
|
228
|
+
export declare const GENERATOR_FUNCTION_TYPE_ASYNC = "[object AsyncGeneratorFunction]";
|
|
229
|
+
export declare const GENERATOR_FUNCTION_TYPE_SYNC = "[object GeneratorFunction]";
|
|
230
|
+
export declare const GENERATOR_TYPE_ASYNC = "[object AsyncGenerator]";
|
|
231
|
+
export declare const GENERATOR_TYPE_SYNC = "[object Generator]";
|
|
232
|
+
export declare const PLAN_FAILURE_ASYNC: "asyncFailure";
|
|
233
|
+
export declare const PLAN_FAILURE_SYNC: "failure";
|
|
110
234
|
export declare const PLAN_MESSAGE_PLAN_INPUT = "plan requires a generator function";
|
|
111
235
|
export declare const PLAN_MESSAGE_RUN_INPUT = "run requires a plan or a generator function";
|
|
236
|
+
export declare const PLAN_MESSAGE_USE_NESTED_FN = "Cannot use nested functions with 'use'";
|
|
237
|
+
export declare const PLAN_MESSAGE_USE_SYNC_ASYNC = "Cannot use asynchronous values with 'use'";
|
|
238
|
+
export declare const PLAN_STEP_ASYNC: "asyncStep";
|
|
239
|
+
export declare const PLAN_STEP_SYNC: "step";
|
|
240
|
+
export declare const PLAN_SUCCESS_ASYNC: "asyncSuccess";
|
|
241
|
+
export declare const PLAN_SUCCESS_SYNC: "success";
|
|
112
242
|
export declare const PLAN_SYMBOL: unique symbol;
|
|
113
|
-
export declare const
|
|
114
|
-
export declare const
|
|
115
|
-
//#endregion
|
|
243
|
+
export declare const PLAN_TYPE_ASYNC: "asyncPlan";
|
|
244
|
+
export declare const PLAN_TYPE_SYNC: "plan";
|
|
245
|
+
//#endregion
|
|
246
|
+
export {};
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
//#region src/models/plan.model.ts
|
|
2
|
-
const
|
|
3
|
-
const
|
|
2
|
+
const GENERATOR_FUNCTION_TYPE_ASYNC = "[object AsyncGeneratorFunction]";
|
|
3
|
+
const GENERATOR_FUNCTION_TYPE_SYNC = "[object GeneratorFunction]";
|
|
4
|
+
const GENERATOR_TYPE_ASYNC = "[object AsyncGenerator]";
|
|
5
|
+
const GENERATOR_TYPE_SYNC = "[object Generator]";
|
|
6
|
+
const PLAN_FAILURE_ASYNC = "asyncFailure";
|
|
7
|
+
const PLAN_FAILURE_SYNC = "failure";
|
|
4
8
|
const PLAN_MESSAGE_PLAN_INPUT = "plan requires a generator function";
|
|
5
9
|
const PLAN_MESSAGE_RUN_INPUT = "run requires a plan or a generator function";
|
|
10
|
+
const PLAN_MESSAGE_USE_NESTED_FN = "Cannot use nested functions with 'use'";
|
|
11
|
+
const PLAN_MESSAGE_USE_SYNC_ASYNC = "Cannot use asynchronous values with 'use'";
|
|
12
|
+
const PLAN_STEP_ASYNC = "asyncStep";
|
|
13
|
+
const PLAN_STEP_SYNC = "step";
|
|
14
|
+
const PLAN_SUCCESS_ASYNC = "asyncSuccess";
|
|
15
|
+
const PLAN_SUCCESS_SYNC = "success";
|
|
6
16
|
const PLAN_SYMBOL = Symbol("plan");
|
|
7
|
-
const
|
|
8
|
-
const
|
|
17
|
+
const PLAN_TYPE_ASYNC = "asyncPlan";
|
|
18
|
+
const PLAN_TYPE_SYNC = "plan";
|
|
9
19
|
//#endregion
|
|
10
|
-
export {
|
|
20
|
+
export { GENERATOR_FUNCTION_TYPE_ASYNC, GENERATOR_FUNCTION_TYPE_SYNC, GENERATOR_TYPE_ASYNC, GENERATOR_TYPE_SYNC, PLAN_FAILURE_ASYNC, PLAN_FAILURE_SYNC, PLAN_MESSAGE_PLAN_INPUT, PLAN_MESSAGE_RUN_INPUT, PLAN_MESSAGE_USE_NESTED_FN, PLAN_MESSAGE_USE_SYNC_ASYNC, PLAN_STEP_ASYNC, PLAN_STEP_SYNC, PLAN_SUCCESS_ASYNC, PLAN_SUCCESS_SYNC, PLAN_SYMBOL, PLAN_TYPE_ASYNC, PLAN_TYPE_SYNC };
|
|
@@ -248,4 +248,5 @@ export declare const QUEUE_STATUS_EMPTY: QueueStatusKey;
|
|
|
248
248
|
export declare const QUEUE_STATUS_FULL: QueueStatusKey;
|
|
249
249
|
export declare const QUEUE_STATUS_PAUSED: QueueStatusKey;
|
|
250
250
|
export declare const QUEUE_SYMBOL: unique symbol;
|
|
251
|
-
//#endregion
|
|
251
|
+
//#endregion
|
|
252
|
+
export {};
|
|
@@ -68,4 +68,5 @@ type UnwrapResult<Original extends Result<unknown, unknown>> = Original extends
|
|
|
68
68
|
* Unwrap any value
|
|
69
69
|
*/
|
|
70
70
|
export type UnwrapValue<Original> = Original extends GenericCallback ? ReturnType<Original> extends Result<unknown, unknown> ? UnwrapResult<ReturnType<Original>> : ReturnType<Original> : Original extends Result<unknown, unknown> ? UnwrapResult<Original> : Original extends Promise<infer Value> ? Awaited<Value> : Original;
|
|
71
|
-
//#endregion
|
|
71
|
+
//#endregion
|
|
72
|
+
export {};
|
|
@@ -88,7 +88,7 @@ export type FuzzyResult<Item> = {
|
|
|
88
88
|
/**
|
|
89
89
|
* Options for fuzzy searching
|
|
90
90
|
*/
|
|
91
|
-
export type FuzzySearchOptions = FuzzyOptions;
|
|
91
|
+
export type FuzzySearchOptions = { [Key in keyof FuzzyOptions]: FuzzyOptions[Key]; };
|
|
92
92
|
export type FuzzyState<Item> = {
|
|
93
93
|
handler(item: Item): string;
|
|
94
94
|
items: Item[];
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
const STRING_DELIMITER_UUID_DEFAULT = "-";
|
|
3
3
|
const STRING_DELIMITER_UUID_HTML = "_";
|
|
4
4
|
const STRING_EXPRESSION_IGNORED = /(^|\.)(__proto__|constructor|prototype)(\.|$)/i;
|
|
5
|
-
const STRING_EXPRESSION_WORDS = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]
|
|
5
|
+
const STRING_EXPRESSION_WORDS = /([^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+)/g;
|
|
6
6
|
const STRING_EXPRESSION_WHITESPACE_PREFIX = /^(\s+)/;
|
|
7
7
|
const STRING_MATCH_ENDS_WITH = "endsWith";
|
|
8
8
|
const STRING_MATCH_INCLUDES = "includes";
|
|
@@ -73,4 +73,5 @@ export declare const EQUAL_ERROR_PROPERTIES: string[];
|
|
|
73
73
|
export declare const EQUAL_EXPRESSION_PROPERTIES: string[];
|
|
74
74
|
export declare const EQUAL_MINIMUM_LENGTH_FOR_SET = 16;
|
|
75
75
|
export declare const EQUAL_SYMBOL: unique symbol;
|
|
76
|
-
//#endregion
|
|
76
|
+
//#endregion
|
|
77
|
+
export {};
|
|
@@ -3,7 +3,7 @@ import { ArrayOrPlainObject, NestedPartial, PlainObject, UnionToIntersection } f
|
|
|
3
3
|
/**
|
|
4
4
|
* Options for assigning values
|
|
5
5
|
*/
|
|
6
|
-
export type AssignOptions = BaseOptions;
|
|
6
|
+
export type AssignOptions = { [Key in keyof BaseOptions]: BaseOptions[Key]; };
|
|
7
7
|
type BaseOptions = {
|
|
8
8
|
/**
|
|
9
9
|
* Key _(or key epxressions)_ for values that should be replaced
|
|
@@ -79,4 +79,5 @@ export type MergingOptions = {
|
|
|
79
79
|
};
|
|
80
80
|
export declare const MERGE_SYMBOL_ASSIGN: unique symbol;
|
|
81
81
|
export declare const MERGE_SYMBOL_MERGE: unique symbol;
|
|
82
|
-
//#endregion
|
|
82
|
+
//#endregion
|
|
83
|
+
export {};
|
|
@@ -30,4 +30,5 @@ export declare const VALUE_MISC_NESTED_MESSAGE_MISSING = "Expected property to e
|
|
|
30
30
|
export declare const VALUE_MISC_NESTED_MESSAGE_PATH = "Expected path to be a string";
|
|
31
31
|
export declare const VALUE_MISC_NESTED_MESSAGE_UNSAFE = "Access to this property is not allowed";
|
|
32
32
|
export declare const SMUSH_MAX_DEPTH = 100;
|
|
33
|
-
//#endregion
|
|
33
|
+
//#endregion
|
|
34
|
+
export {};
|
package/dist/number.mjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { between, clamp, getNumber };
|
|
1
|
+
export { between, clamp, getNumber } from "./internal/number.mjs";
|
package/dist/plan/index.d.mts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { AsyncPlan, Plan } from "../models/plan.model.mjs";
|
|
2
|
-
import { asyncAttemptRun, attemptRun } from "./result.mjs";
|
|
3
|
-
import { asyncRun, run } from "./run.mjs";
|
|
4
2
|
//#region src/plan/index.d.ts
|
|
5
3
|
/**
|
|
6
4
|
* Create a plan for an asynchronous generator function
|
|
@@ -16,5 +14,4 @@ export declare function plan<Yielded, Returned, Parameters extends unknown[]>(ge
|
|
|
16
14
|
* @returns Generator plan
|
|
17
15
|
*/
|
|
18
16
|
export declare function plan<Yielded, Returned, Parameters extends unknown[]>(generator: (...parameters: Parameters) => Generator<Yielded, Returned>): Plan<Yielded, Returned, Parameters>;
|
|
19
|
-
//#endregion
|
|
20
|
-
export { asyncAttemptRun, asyncRun, attemptRun, run };
|
|
17
|
+
//#endregion
|
package/dist/plan/index.mjs
CHANGED
|
@@ -1,34 +1,33 @@
|
|
|
1
|
-
import { PLAN_MESSAGE_PLAN_INPUT, PLAN_SYMBOL,
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { PLAN_MESSAGE_PLAN_INPUT, PLAN_SYMBOL, PLAN_TYPE_ASYNC, PLAN_TYPE_SYNC } from "../models/plan.model.mjs";
|
|
2
|
+
import { attemptRunPlan, getGenerator, runAsyncPlan, runPlan } from "../internal/plan/index.mjs";
|
|
3
|
+
import { isAsyncGeneratorFunction, isGeneratorFunction } from "./is.mjs";
|
|
4
|
+
import { asyncAttemptRun } from "./result.mjs";
|
|
5
5
|
//#region src/plan/index.ts
|
|
6
6
|
function AsyncPlan(generator) {
|
|
7
7
|
this[PLAN_SYMBOL] = {
|
|
8
8
|
generator,
|
|
9
|
-
type:
|
|
9
|
+
type: PLAN_TYPE_ASYNC
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
|
-
AsyncPlan.prototype[Symbol.asyncIterator] =
|
|
13
|
-
return this[PLAN_SYMBOL].generator();
|
|
14
|
-
};
|
|
12
|
+
AsyncPlan.prototype[Symbol.asyncIterator] = getGenerator;
|
|
15
13
|
AsyncPlan.prototype.attempt = attemptRunAsyncPlan;
|
|
16
14
|
AsyncPlan.prototype.run = runAsyncPlan;
|
|
17
15
|
function Plan(generator) {
|
|
18
16
|
this[PLAN_SYMBOL] = {
|
|
19
17
|
generator,
|
|
20
|
-
type:
|
|
18
|
+
type: PLAN_TYPE_SYNC
|
|
21
19
|
};
|
|
22
20
|
}
|
|
23
|
-
Plan.prototype[Symbol.iterator] =
|
|
24
|
-
return this[PLAN_SYMBOL].generator();
|
|
25
|
-
};
|
|
21
|
+
Plan.prototype[Symbol.iterator] = getGenerator;
|
|
26
22
|
Plan.prototype.attempt = attemptRunPlan;
|
|
27
23
|
Plan.prototype.run = runPlan;
|
|
24
|
+
function attemptRunAsyncPlan(first, second) {
|
|
25
|
+
return asyncAttemptRun(this, first, second);
|
|
26
|
+
}
|
|
28
27
|
function plan(generator) {
|
|
29
|
-
if (
|
|
30
|
-
if (
|
|
28
|
+
if (isAsyncGeneratorFunction(generator)) return new AsyncPlan(generator);
|
|
29
|
+
if (isGeneratorFunction(generator)) return new Plan(generator);
|
|
31
30
|
throw new Error(PLAN_MESSAGE_PLAN_INPUT);
|
|
32
31
|
}
|
|
33
32
|
//#endregion
|
|
34
|
-
export {
|
|
33
|
+
export { plan };
|
package/dist/plan/is.d.mts
CHANGED
|
@@ -1,12 +1,26 @@
|
|
|
1
|
-
import { AsyncPlan, Plan } from "../models/plan.model.mjs";
|
|
1
|
+
import { AsyncFailure, AsyncPlan, AsyncStep, AsyncSuccess, Failure, Plan, Step, Success } from "../models/plan.model.mjs";
|
|
2
2
|
//#region src/plan/is.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Is the value an asynchronous, immediately failing plan?
|
|
5
|
+
*
|
|
6
|
+
* @param value Value to check
|
|
7
|
+
* @returns `true` if the value is an asynchronous, immediately failing plan, otherwise `false`
|
|
8
|
+
*/
|
|
9
|
+
export declare function isAsyncFailure<Value = unknown>(value: unknown): value is AsyncFailure<Value>;
|
|
10
|
+
/**
|
|
11
|
+
* Is the value an asynchronous generator?
|
|
12
|
+
*
|
|
13
|
+
* @param value Value to check
|
|
14
|
+
* @returns `true` if the value is an asynchronous generator, otherwise `false`
|
|
15
|
+
*/
|
|
16
|
+
export declare function isAsyncGenerator<Y = unknown, R = unknown, N = unknown>(value: unknown): value is AsyncGenerator<Y, R, N>;
|
|
3
17
|
/**
|
|
4
18
|
* Is the value an asynchronous generator function?
|
|
5
19
|
*
|
|
6
20
|
* @param value Value to check
|
|
7
21
|
* @returns `true` if the value is an asynchronous generator function, otherwise `false`
|
|
8
22
|
*/
|
|
9
|
-
export declare function
|
|
23
|
+
export declare function isAsyncGeneratorFunction<Y = unknown, R = unknown, N = unknown>(value: unknown): value is () => AsyncGenerator<Y, R, N>;
|
|
10
24
|
/**
|
|
11
25
|
* Is the value an asynchronous plan?
|
|
12
26
|
*
|
|
@@ -14,13 +28,41 @@ export declare function isAsyncGenerator(value: unknown): value is () => AsyncGe
|
|
|
14
28
|
* @returns `true` if the value is an asynchronous plan, otherwise `false`
|
|
15
29
|
*/
|
|
16
30
|
export declare function isAsyncPlan<Yielded = unknown, Returned = unknown, Parameters extends unknown[] = unknown[]>(value: unknown): value is AsyncPlan<Yielded, Returned, Parameters>;
|
|
31
|
+
/**
|
|
32
|
+
* Is the value an asynchronous step?
|
|
33
|
+
*
|
|
34
|
+
* @param value Value to check
|
|
35
|
+
* @returns `true` if the value is an asynchronous step, otherwise `false`
|
|
36
|
+
*/
|
|
37
|
+
export declare function isAsyncStep<Value = unknown>(value: unknown): value is AsyncStep<Value>;
|
|
38
|
+
/**
|
|
39
|
+
* Is the value an asynchronous, immediately successful plan?
|
|
40
|
+
*
|
|
41
|
+
* @param value Value to check
|
|
42
|
+
* @returns `true` if the value is an asynchronous, immediately successful plan, otherwise `false`
|
|
43
|
+
*/
|
|
44
|
+
export declare function isAsyncSuccess<Value = unknown>(value: unknown): value is AsyncSuccess<Value>;
|
|
45
|
+
/**
|
|
46
|
+
* Is the value an immediately failing plan?
|
|
47
|
+
*
|
|
48
|
+
* @param value Value to check
|
|
49
|
+
* @returns `true` if the value is an immediately failing plan, otherwise `false`
|
|
50
|
+
*/
|
|
51
|
+
export declare function isFailure<Value = unknown>(value: unknown): value is Failure<Value>;
|
|
52
|
+
/**
|
|
53
|
+
* Is the value a generator?
|
|
54
|
+
*
|
|
55
|
+
* @param value Value to check
|
|
56
|
+
* @returns `true` if the value is a generator, otherwise `false`
|
|
57
|
+
*/
|
|
58
|
+
export declare function isGenerator<Y = unknown, R = unknown, N = unknown>(value: unknown): value is Generator<Y, R, N>;
|
|
17
59
|
/**
|
|
18
60
|
* Is the value a generator function?
|
|
19
61
|
*
|
|
20
62
|
* @param value Value to check
|
|
21
63
|
* @returns `true` if the value is a generator function, otherwise `false`
|
|
22
64
|
*/
|
|
23
|
-
export declare function
|
|
65
|
+
export declare function isGeneratorFunction<Y = unknown, R = unknown, N = unknown>(value: unknown): value is () => Generator<Y, R, N>;
|
|
24
66
|
/**
|
|
25
67
|
* Is the value a plan?
|
|
26
68
|
*
|
|
@@ -28,4 +70,18 @@ export declare function isGenerator(value: unknown): value is () => Generator;
|
|
|
28
70
|
* @returns `true` if the value is a plan, otherwise `false`
|
|
29
71
|
*/
|
|
30
72
|
export declare function isPlan<Yielded = unknown, Returned = unknown, Parameters extends unknown[] = unknown[]>(value: unknown): value is Plan<Yielded, Returned, Parameters>;
|
|
73
|
+
/**
|
|
74
|
+
* Is the value a step?
|
|
75
|
+
*
|
|
76
|
+
* @param value Value to check
|
|
77
|
+
* @returns `true` if the value is a step, otherwise `false`
|
|
78
|
+
*/
|
|
79
|
+
export declare function isStep<Value = unknown>(value: unknown): value is Step<Value>;
|
|
80
|
+
/**
|
|
81
|
+
* Is the value an immediately successful plan?
|
|
82
|
+
*
|
|
83
|
+
* @param value Value to check
|
|
84
|
+
* @returns `true` if the value is an immediately successful plan, otherwise `false`
|
|
85
|
+
*/
|
|
86
|
+
export declare function isSuccess<Value = unknown>(value: unknown): value is Success<Value>;
|
|
31
87
|
//#endregion
|
package/dist/plan/is.mjs
CHANGED
|
@@ -1,13 +1,31 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GENERATOR_FUNCTION_TYPE_ASYNC, GENERATOR_FUNCTION_TYPE_SYNC, GENERATOR_TYPE_ASYNC, GENERATOR_TYPE_SYNC, PLAN_FAILURE_ASYNC, PLAN_FAILURE_SYNC, PLAN_STEP_ASYNC, PLAN_STEP_SYNC, PLAN_SUCCESS_ASYNC, PLAN_SUCCESS_SYNC, PLAN_SYMBOL, PLAN_TYPE_ASYNC, PLAN_TYPE_SYNC } from "../models/plan.model.mjs";
|
|
2
2
|
//#region src/plan/is.ts
|
|
3
3
|
/**
|
|
4
|
+
* Is the value an asynchronous, immediately failing plan?
|
|
5
|
+
*
|
|
6
|
+
* @param value Value to check
|
|
7
|
+
* @returns `true` if the value is an asynchronous, immediately failing plan, otherwise `false`
|
|
8
|
+
*/
|
|
9
|
+
function isAsyncFailure(value) {
|
|
10
|
+
return isPlanInstance(PLAN_FAILURE_ASYNC, value);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Is the value an asynchronous generator?
|
|
14
|
+
*
|
|
15
|
+
* @param value Value to check
|
|
16
|
+
* @returns `true` if the value is an asynchronous generator, otherwise `false`
|
|
17
|
+
*/
|
|
18
|
+
function isAsyncGenerator(value) {
|
|
19
|
+
return isGeneratorInstance(GENERATOR_TYPE_ASYNC, value);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
4
22
|
* Is the value an asynchronous generator function?
|
|
5
23
|
*
|
|
6
24
|
* @param value Value to check
|
|
7
25
|
* @returns `true` if the value is an asynchronous generator function, otherwise `false`
|
|
8
26
|
*/
|
|
9
|
-
function
|
|
10
|
-
return isGeneratorInstance(
|
|
27
|
+
function isAsyncGeneratorFunction(value) {
|
|
28
|
+
return isGeneratorInstance(GENERATOR_FUNCTION_TYPE_ASYNC, value);
|
|
11
29
|
}
|
|
12
30
|
/**
|
|
13
31
|
* Is the value an asynchronous plan?
|
|
@@ -16,7 +34,43 @@ function isAsyncGenerator(value) {
|
|
|
16
34
|
* @returns `true` if the value is an asynchronous plan, otherwise `false`
|
|
17
35
|
*/
|
|
18
36
|
function isAsyncPlan(value) {
|
|
19
|
-
return isPlanInstance(
|
|
37
|
+
return isPlanInstance(PLAN_TYPE_ASYNC, value);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Is the value an asynchronous step?
|
|
41
|
+
*
|
|
42
|
+
* @param value Value to check
|
|
43
|
+
* @returns `true` if the value is an asynchronous step, otherwise `false`
|
|
44
|
+
*/
|
|
45
|
+
function isAsyncStep(value) {
|
|
46
|
+
return isPlanInstance(PLAN_STEP_ASYNC, value);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Is the value an asynchronous, immediately successful plan?
|
|
50
|
+
*
|
|
51
|
+
* @param value Value to check
|
|
52
|
+
* @returns `true` if the value is an asynchronous, immediately successful plan, otherwise `false`
|
|
53
|
+
*/
|
|
54
|
+
function isAsyncSuccess(value) {
|
|
55
|
+
return isPlanInstance(PLAN_SUCCESS_ASYNC, value);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Is the value an immediately failing plan?
|
|
59
|
+
*
|
|
60
|
+
* @param value Value to check
|
|
61
|
+
* @returns `true` if the value is an immediately failing plan, otherwise `false`
|
|
62
|
+
*/
|
|
63
|
+
function isFailure(value) {
|
|
64
|
+
return isPlanInstance(PLAN_FAILURE_SYNC, value);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Is the value a generator?
|
|
68
|
+
*
|
|
69
|
+
* @param value Value to check
|
|
70
|
+
* @returns `true` if the value is a generator, otherwise `false`
|
|
71
|
+
*/
|
|
72
|
+
function isGenerator(value) {
|
|
73
|
+
return isGeneratorInstance(GENERATOR_TYPE_SYNC, value);
|
|
20
74
|
}
|
|
21
75
|
/**
|
|
22
76
|
* Is the value a generator function?
|
|
@@ -24,11 +78,11 @@ function isAsyncPlan(value) {
|
|
|
24
78
|
* @param value Value to check
|
|
25
79
|
* @returns `true` if the value is a generator function, otherwise `false`
|
|
26
80
|
*/
|
|
27
|
-
function
|
|
28
|
-
return isGeneratorInstance(
|
|
81
|
+
function isGeneratorFunction(value) {
|
|
82
|
+
return isGeneratorInstance(GENERATOR_FUNCTION_TYPE_SYNC, value);
|
|
29
83
|
}
|
|
30
|
-
function isGeneratorInstance(
|
|
31
|
-
return
|
|
84
|
+
function isGeneratorInstance(type, value) {
|
|
85
|
+
return Object.prototype.toString.call(value) === type;
|
|
32
86
|
}
|
|
33
87
|
/**
|
|
34
88
|
* Is the value a plan?
|
|
@@ -37,10 +91,28 @@ function isGeneratorInstance(name, value) {
|
|
|
37
91
|
* @returns `true` if the value is a plan, otherwise `false`
|
|
38
92
|
*/
|
|
39
93
|
function isPlan(value) {
|
|
40
|
-
return isPlanInstance(
|
|
94
|
+
return isPlanInstance(PLAN_TYPE_SYNC, value);
|
|
41
95
|
}
|
|
42
96
|
function isPlanInstance(type, value) {
|
|
43
97
|
return typeof value === "object" && value !== null && PLAN_SYMBOL in value && value[PLAN_SYMBOL].type === type;
|
|
44
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Is the value a step?
|
|
101
|
+
*
|
|
102
|
+
* @param value Value to check
|
|
103
|
+
* @returns `true` if the value is a step, otherwise `false`
|
|
104
|
+
*/
|
|
105
|
+
function isStep(value) {
|
|
106
|
+
return isPlanInstance(PLAN_STEP_SYNC, value);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Is the value an immediately successful plan?
|
|
110
|
+
*
|
|
111
|
+
* @param value Value to check
|
|
112
|
+
* @returns `true` if the value is an immediately successful plan, otherwise `false`
|
|
113
|
+
*/
|
|
114
|
+
function isSuccess(value) {
|
|
115
|
+
return isPlanInstance(PLAN_SUCCESS_SYNC, value);
|
|
116
|
+
}
|
|
45
117
|
//#endregion
|
|
46
|
-
export { isAsyncGenerator, isAsyncPlan, isGenerator, isPlan };
|
|
118
|
+
export { isAsyncFailure, isAsyncGenerator, isAsyncGeneratorFunction, isAsyncPlan, isAsyncStep, isAsyncSuccess, isFailure, isGenerator, isGeneratorFunction, isPlan, isStep, isSuccess };
|