@oscarpalmer/atoms 0.213.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/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 +425 -318
- package/dist/index.mjs +454 -408
- 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 -2
- 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} +5 -47
- 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 +3 -3
- 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 +11 -7
- package/dist/plan/index.d.mts +1 -1
- package/dist/plan/index.mjs +1 -1
- package/dist/plan/is.d.mts +1 -1
- package/dist/plan/is.mjs +1 -1
- package/dist/plan/misc.d.mts +1 -1
- package/dist/plan/models.d.mts +1 -1
- package/dist/plan/result.d.mts +2 -2
- package/dist/plan/result.mjs +3 -3
- package/dist/plan/run.d.mts +1 -1
- package/dist/plan/run.mjs +3 -3
- 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/pipe.d.mts +2 -2
- 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 -4
- 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
package/dist/queue.d.mts
CHANGED
|
@@ -1,203 +1,8 @@
|
|
|
1
|
-
import { GenericAsyncCallback, GenericCallback } from "./models.mjs";
|
|
1
|
+
import { GenericAsyncCallback, GenericCallback } from "./models/index.mjs";
|
|
2
|
+
import { KeyedQueue, Queue, QueueOptions, Queued } from "./models/queue.model.mjs";
|
|
2
3
|
//#region src/queue.d.ts
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*/
|
|
6
|
-
export type KeyedQueue<Callback extends GenericCallback | GenericAsyncCallback, CallbackParameters extends unknown[] = Parameters<Callback>> = {
|
|
7
|
-
/**
|
|
8
|
-
* Get keys of all active queues
|
|
9
|
-
*/
|
|
10
|
-
get active(): string[];
|
|
11
|
-
/**
|
|
12
|
-
* Does the queue automatically start when the first item is added?
|
|
13
|
-
*/
|
|
14
|
-
get autostart(): boolean;
|
|
15
|
-
/**
|
|
16
|
-
* Maximum number of runners to process the queue concurrently
|
|
17
|
-
*/
|
|
18
|
-
get concurrency(): number;
|
|
19
|
-
/**
|
|
20
|
-
* Get keys of all empty queues
|
|
21
|
-
*/
|
|
22
|
-
get empty(): string[];
|
|
23
|
-
/**
|
|
24
|
-
* Get keys of all full queues
|
|
25
|
-
*/
|
|
26
|
-
get full(): string[];
|
|
27
|
-
/**
|
|
28
|
-
* Number of items in all queues
|
|
29
|
-
*/
|
|
30
|
-
get items(): Record<string, number>;
|
|
31
|
-
/**
|
|
32
|
-
* Keys of all queues
|
|
33
|
-
*/
|
|
34
|
-
get keys(): string[];
|
|
35
|
-
/**
|
|
36
|
-
* Maximum number of items allowed in the queue
|
|
37
|
-
*/
|
|
38
|
-
get maximum(): number;
|
|
39
|
-
/**
|
|
40
|
-
* Are all queues paused?
|
|
41
|
-
*/
|
|
42
|
-
get paused(): string[];
|
|
43
|
-
/**
|
|
44
|
-
* Number of queues
|
|
45
|
-
*/
|
|
46
|
-
get queues(): number;
|
|
47
|
-
/**
|
|
48
|
-
* Queue an item for a specific key
|
|
49
|
-
*
|
|
50
|
-
* @param key Key to queue the item for
|
|
51
|
-
* @param parameters Parameters to use when item runs
|
|
52
|
-
* @param signal Optional signal to abort the item
|
|
53
|
-
* @returns Queued item
|
|
54
|
-
*/
|
|
55
|
-
add(key: string, parameters: Tail<CallbackParameters>, signal?: AbortSignal): Queued<ReturnType<Callback>>;
|
|
56
|
-
/**
|
|
57
|
-
* Clear all items for a specific key _(or all items for all keys, if no key is provided)_
|
|
58
|
-
*
|
|
59
|
-
* @param key Optional key to clear the queue for
|
|
60
|
-
*/
|
|
61
|
-
clear(key?: string): void;
|
|
62
|
-
/**
|
|
63
|
-
* Get the queue for a specific key
|
|
64
|
-
*
|
|
65
|
-
* @param key Key to get the queue for
|
|
66
|
-
* @returns Queue for the key, or `undefined` if it doesn't exist
|
|
67
|
-
*/
|
|
68
|
-
get(key: string): Queue<Callback, Tail<CallbackParameters>> | undefined;
|
|
69
|
-
/**
|
|
70
|
-
* Pause the queue for a specific key _(or all queues, if no key is provided)_
|
|
71
|
-
*
|
|
72
|
-
* @param key Optional key to pause the queue for
|
|
73
|
-
*/
|
|
74
|
-
pause(key?: string): void;
|
|
75
|
-
/**
|
|
76
|
-
* Remove a specific item for a specific key
|
|
77
|
-
*
|
|
78
|
-
* @param key Key to remove the item for
|
|
79
|
-
* @param id ID of the item to remove
|
|
80
|
-
*/
|
|
81
|
-
remove(key: string, id: number): void;
|
|
82
|
-
/**
|
|
83
|
-
* Remove a queue and its items for a specific key
|
|
84
|
-
*
|
|
85
|
-
* _(To remove all items for a specific key, use `clear()` instead)_
|
|
86
|
-
*
|
|
87
|
-
* @param key Key to remove the queue for
|
|
88
|
-
*/
|
|
89
|
-
remove(key: string): void;
|
|
90
|
-
/**
|
|
91
|
-
* Remove all queues and their items
|
|
92
|
-
*/
|
|
93
|
-
remove(): void;
|
|
94
|
-
/**
|
|
95
|
-
* Resume the queue for a specific key _(or all queues, if no key is provided)_
|
|
96
|
-
*
|
|
97
|
-
* @param key Optional key to resume the queue for
|
|
98
|
-
*/
|
|
99
|
-
resume(key?: string): void;
|
|
100
|
-
};
|
|
101
|
-
/**
|
|
102
|
-
* A queue that can be used to manage (a)synchronous tasks
|
|
103
|
-
*/
|
|
104
|
-
export type Queue<Callback extends GenericCallback | GenericAsyncCallback, CallbackParameters extends unknown[] = Parameters<Callback>> = {
|
|
105
|
-
/**
|
|
106
|
-
* Is the queue active?
|
|
107
|
-
*/
|
|
108
|
-
get active(): boolean;
|
|
109
|
-
/**
|
|
110
|
-
* Does the queue automatically start when the first item is added?
|
|
111
|
-
*/
|
|
112
|
-
get autostart(): boolean;
|
|
113
|
-
/**
|
|
114
|
-
* Maximum number of runners to process the queue concurrently
|
|
115
|
-
*/
|
|
116
|
-
get concurrency(): number;
|
|
117
|
-
/**
|
|
118
|
-
* Is the queue empty?
|
|
119
|
-
*/
|
|
120
|
-
get empty(): boolean;
|
|
121
|
-
/**
|
|
122
|
-
* Is the queue full?
|
|
123
|
-
*/
|
|
124
|
-
get full(): boolean;
|
|
125
|
-
/**
|
|
126
|
-
* Maximum number of items allowed in the queue
|
|
127
|
-
*/
|
|
128
|
-
get maximum(): number;
|
|
129
|
-
/**
|
|
130
|
-
* Is the queue paused?
|
|
131
|
-
*/
|
|
132
|
-
get paused(): boolean;
|
|
133
|
-
/**
|
|
134
|
-
* Number of items in the queue
|
|
135
|
-
*/
|
|
136
|
-
get size(): number;
|
|
137
|
-
/**
|
|
138
|
-
* Add an item to the queue
|
|
139
|
-
*
|
|
140
|
-
* @param parameters Parameters to use when item runs
|
|
141
|
-
* @param signal Optional signal to abort the item
|
|
142
|
-
* @returns Queued item
|
|
143
|
-
*/
|
|
144
|
-
add(parameters: CallbackParameters, signal?: AbortSignal): Queued<ReturnType<Callback>>;
|
|
145
|
-
/**
|
|
146
|
-
* Remove and reject all items in the queue
|
|
147
|
-
*/
|
|
148
|
-
clear(): void;
|
|
149
|
-
/**
|
|
150
|
-
* Pause the queue
|
|
151
|
-
*
|
|
152
|
-
* - Currently running items will not be stopped
|
|
153
|
-
* - New added items will not run until the queue is resumed
|
|
154
|
-
*/
|
|
155
|
-
pause(): void;
|
|
156
|
-
/**
|
|
157
|
-
* Remove and reject a specific item in the queue
|
|
158
|
-
*
|
|
159
|
-
* @param id ID of queued item
|
|
160
|
-
*/
|
|
161
|
-
remove(id: number): void;
|
|
162
|
-
/**
|
|
163
|
-
* Resume the queue
|
|
164
|
-
*/
|
|
165
|
-
resume(): void;
|
|
166
|
-
};
|
|
167
|
-
/**
|
|
168
|
-
* An error thrown by the Queue when an operation fails
|
|
169
|
-
*/
|
|
170
|
-
export declare class QueueError extends Error {
|
|
171
|
-
constructor(message: string);
|
|
172
|
-
}
|
|
173
|
-
export type QueueOptions = {
|
|
174
|
-
/**
|
|
175
|
-
* Automatically start processing the queue when the first item is added _(defaults to `true`)_
|
|
176
|
-
*/
|
|
177
|
-
autostart?: boolean;
|
|
178
|
-
/**
|
|
179
|
-
* Number of runners to process the queue concurrently _(defaults to `1`)_
|
|
180
|
-
*/
|
|
181
|
-
concurrency?: number;
|
|
182
|
-
/**
|
|
183
|
-
* Maximum number of items allowed in the queue _(defaults to `0`, which means no limit)_
|
|
184
|
-
*/
|
|
185
|
-
maximum?: number;
|
|
186
|
-
};
|
|
187
|
-
/**
|
|
188
|
-
* A queued item
|
|
189
|
-
*/
|
|
190
|
-
export type Queued<Value> = {
|
|
191
|
-
/**
|
|
192
|
-
* ID of the queued item _(can be used to remove it from the queue)_
|
|
193
|
-
*/
|
|
194
|
-
readonly id: number;
|
|
195
|
-
/**
|
|
196
|
-
* Queued promise
|
|
197
|
-
*/
|
|
198
|
-
readonly promise: Promise<Value extends Promise<infer Result> ? Result : Value>;
|
|
199
|
-
};
|
|
200
|
-
type Tail<Values extends any[]> = Values extends [infer _, ...infer Rest] ? Rest : never;
|
|
4
|
+
declare function KeyedQueue(this: any, callback: GenericAsyncCallback, options: Required<QueueOptions>): void;
|
|
5
|
+
declare function Queue(this: any, callback: GenericAsyncCallback, options: Required<QueueOptions>, key?: string): void;
|
|
201
6
|
/**
|
|
202
7
|
* Is the value keyed queue?
|
|
203
8
|
*
|
|
@@ -250,4 +55,5 @@ export declare function queue<Callback extends GenericCallback>(callback: Callba
|
|
|
250
55
|
export declare namespace queue {
|
|
251
56
|
export var keyed: typeof keyedQueue;
|
|
252
57
|
}
|
|
253
|
-
//#endregion
|
|
58
|
+
//#endregion
|
|
59
|
+
export type { KeyedQueue, Queue, QueueOptions, Queued };
|
package/dist/queue.mjs
CHANGED
|
@@ -2,19 +2,8 @@ import { createAborter } from "./internal/aborter.mjs";
|
|
|
2
2
|
import { min } from "./internal/math/aggregate.mjs";
|
|
3
3
|
import { asyncAttempt } from "./internal/result/attempt.mjs";
|
|
4
4
|
import { getBooleanOrDefault, getNumberOrDefault } from "./internal/defaults.mjs";
|
|
5
|
+
import { 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 } from "./models/queue.model.mjs";
|
|
5
6
|
//#region src/queue.ts
|
|
6
|
-
const QUEUE_NAME_KEYED = "keyedQueue";
|
|
7
|
-
const QUEUE_NAME_QUEUE = "queue";
|
|
8
|
-
const QUEUE_PROPERTY = "$queue";
|
|
9
|
-
/**
|
|
10
|
-
* An error thrown by the Queue when an operation fails
|
|
11
|
-
*/
|
|
12
|
-
var QueueError = class extends Error {
|
|
13
|
-
constructor(message) {
|
|
14
|
-
super(message);
|
|
15
|
-
this.name = QUEUE_ERROR_NAME;
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
7
|
function KeyedQueue(callback, options) {
|
|
19
8
|
this[QUEUE_SYMBOL] = {
|
|
20
9
|
callback,
|
|
@@ -158,9 +147,9 @@ function clearQueue() {
|
|
|
158
147
|
const items = this[QUEUE_SYMBOL].items.splice(0);
|
|
159
148
|
const { length } = items;
|
|
160
149
|
for (let index = 0; index < length; index += 1) {
|
|
161
|
-
const
|
|
162
|
-
aborter?.cancel();
|
|
163
|
-
reject(new QueueError(QUEUE_MESSAGE_CLEAR));
|
|
150
|
+
const item = items[index];
|
|
151
|
+
item.aborter?.cancel();
|
|
152
|
+
item.reject(new QueueError(QUEUE_MESSAGE_CLEAR));
|
|
164
153
|
}
|
|
165
154
|
}
|
|
166
155
|
function clearQueues(key) {
|
|
@@ -287,7 +276,7 @@ function isQueue(value) {
|
|
|
287
276
|
return isQueueInstance(QUEUE_NAME_QUEUE, value);
|
|
288
277
|
}
|
|
289
278
|
function isQueueInstance(name, value) {
|
|
290
|
-
return typeof value === "object" && value != null &&
|
|
279
|
+
return typeof value === "object" && value != null && "$queue" in value && value["$queue"] === name;
|
|
291
280
|
}
|
|
292
281
|
function keyedQueue(callback, options) {
|
|
293
282
|
if (typeof callback !== "function") throw new TypeError(QUEUE_MESSAGE_CALLBACK);
|
|
@@ -322,9 +311,9 @@ function removeQueued(id) {
|
|
|
322
311
|
const state = this[QUEUE_SYMBOL];
|
|
323
312
|
const index = state.items.findIndex((item) => item.id === id);
|
|
324
313
|
if (index > -1) {
|
|
325
|
-
const
|
|
326
|
-
aborter?.cancel();
|
|
327
|
-
reject(new QueueError(QUEUE_MESSAGE_REMOVE));
|
|
314
|
+
const item = state.items.splice(index, 1)[0];
|
|
315
|
+
item.aborter?.cancel();
|
|
316
|
+
item.reject(new QueueError(QUEUE_MESSAGE_REMOVE));
|
|
328
317
|
}
|
|
329
318
|
}
|
|
330
319
|
function resumeQueue() {
|
|
@@ -370,20 +359,6 @@ async function run(state) {
|
|
|
370
359
|
}
|
|
371
360
|
state.runners -= 1;
|
|
372
361
|
}
|
|
373
|
-
const QUEUE_ERROR_NAME = "QueueError";
|
|
374
|
-
const QUEUE_HANDLE_CLEAR = "clear";
|
|
375
|
-
const QUEUE_HANDLE_PAUSE = "pause";
|
|
376
|
-
const QUEUE_HANDLE_RESUME = "resume";
|
|
377
|
-
const QUEUE_MESSAGE_CALLBACK = "A Queue requires a callback function";
|
|
378
|
-
const QUEUE_MESSAGE_CLEAR = "Queue was cleared";
|
|
379
|
-
const QUEUE_MESSAGE_KEY = "Key must be a non-empty string";
|
|
380
|
-
const QUEUE_MESSAGE_MAXIMUM = "Queue has reached its maximum size";
|
|
381
|
-
const QUEUE_MESSAGE_REMOVE = "Item removed from queue";
|
|
382
|
-
const QUEUE_STATUS_ACTIVE = "active";
|
|
383
|
-
const QUEUE_STATUS_EMPTY = "empty";
|
|
384
|
-
const QUEUE_STATUS_FULL = "full";
|
|
385
|
-
const QUEUE_STATUS_PAUSED = "paused";
|
|
386
|
-
const QUEUE_SYMBOL = Symbol(QUEUE_PROPERTY);
|
|
387
362
|
queue.keyed = keyedQueue;
|
|
388
363
|
//#endregion
|
|
389
|
-
export {
|
|
364
|
+
export { isKeyedQueue, isQueue, isQueueInstance, keyedQueue, queue };
|
package/dist/random.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getRandomFloatingNumber, getRandomInteger } from "./internal/random.mjs";
|
|
2
2
|
import { shuffle } from "./internal/array/shuffle.mjs";
|
|
3
3
|
import { join } from "./internal/string/misc.mjs";
|
|
4
|
+
import { RANDOM_ALPHABET, RANDOM_BOOLEAN_MODIFIER, RANDOM_HEX_CHARACTERS } from "./models/random.model.mjs";
|
|
4
5
|
//#region src/random.ts
|
|
5
6
|
/**
|
|
6
7
|
* Get a random boolean
|
|
@@ -39,7 +40,7 @@ function getRandomColor(prefix) {
|
|
|
39
40
|
* @returns Random hexadecimal character from `0-9` and `A-F`
|
|
40
41
|
*/
|
|
41
42
|
function getRandomHex() {
|
|
42
|
-
return RANDOM_HEX_CHARACTERS[getRandomInteger(0,
|
|
43
|
+
return RANDOM_HEX_CHARACTERS[getRandomInteger(0, 15)];
|
|
43
44
|
}
|
|
44
45
|
/**
|
|
45
46
|
* Get a random item from an array
|
|
@@ -57,9 +58,5 @@ function getRandomItems(array, amount) {
|
|
|
57
58
|
if (amount === 1) return [array[getRandomInteger(0, array.length - 1)]];
|
|
58
59
|
return typeof amount !== "number" || amount <= 0 || amount >= array.length ? shuffle(array) : shuffle(array).slice(0, amount);
|
|
59
60
|
}
|
|
60
|
-
const RANDOM_ALPHABET = "abcdefghijklmnopqrstuvwxyz";
|
|
61
|
-
const RANDOM_BOOLEAN_MODIFIER = .5;
|
|
62
|
-
const RANDOM_HEX_CHARACTERS = "0123456789ABCDEF";
|
|
63
|
-
const RANDOM_HEX_MAXIMUM = 15;
|
|
64
61
|
//#endregion
|
|
65
62
|
export { getRandomBoolean, getRandomCharacters, getRandomColor, getRandomFloatingNumber as getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems };
|
package/dist/result/match.d.mts
CHANGED
package/dist/result/match.mjs
CHANGED
|
@@ -1,27 +1,39 @@
|
|
|
1
|
+
import { isPlainObject } from "../internal/is.mjs";
|
|
1
2
|
import { isOk, isResult } from "../internal/result/misc.mjs";
|
|
2
3
|
//#region src/result/match.ts
|
|
3
|
-
async function asyncMatchResult(result, first,
|
|
4
|
+
async function asyncMatchResult(result, first, second) {
|
|
4
5
|
let value;
|
|
5
6
|
if (typeof result === "function") value = await result();
|
|
6
7
|
else if (result instanceof Promise) value = await result;
|
|
7
8
|
else value = result;
|
|
8
|
-
if (!isResult(value)) throw new Error(
|
|
9
|
-
|
|
10
|
-
const okHandler = hasObj ? first.ok : first;
|
|
11
|
-
const errorHandler = hasObj ? first.error : error;
|
|
12
|
-
if (isOk(value)) return okHandler(value.value);
|
|
13
|
-
return errorHandler(value.error, value.original);
|
|
9
|
+
if (!isResult(value)) throw new Error(MATCH_MESSAGE_RESULT);
|
|
10
|
+
return handleResult(value, first, second);
|
|
14
11
|
}
|
|
15
|
-
function
|
|
12
|
+
function handleResult(result, first, second) {
|
|
13
|
+
let error;
|
|
14
|
+
let ok;
|
|
15
|
+
if (isPlainObject(first)) {
|
|
16
|
+
ok = first.ok;
|
|
17
|
+
error = first.error;
|
|
18
|
+
} else {
|
|
19
|
+
ok = first;
|
|
20
|
+
error = second;
|
|
21
|
+
}
|
|
22
|
+
if (isOk(result)) {
|
|
23
|
+
if (typeof ok !== "function") throw new Error(MATCH_MESSAGE_OK);
|
|
24
|
+
return ok(result.value);
|
|
25
|
+
}
|
|
26
|
+
if (typeof error !== "function") throw new Error(MATCH_MESSAGE_ERROR);
|
|
27
|
+
return error(result.error, result.original);
|
|
28
|
+
}
|
|
29
|
+
function matchResult(result, first, second) {
|
|
16
30
|
const value = typeof result === "function" ? result() : result;
|
|
17
|
-
if (!isResult(value)) throw new Error(
|
|
18
|
-
|
|
19
|
-
const okHandler = hasObj ? first.ok : first;
|
|
20
|
-
const errorHandler = hasObj ? first.error : error;
|
|
21
|
-
if (isOk(value)) return okHandler(value.value);
|
|
22
|
-
return errorHandler(value.error, value.original);
|
|
31
|
+
if (!isResult(value)) throw new Error(MATCH_MESSAGE_RESULT);
|
|
32
|
+
return handleResult(value, first, second);
|
|
23
33
|
}
|
|
24
|
-
const
|
|
34
|
+
const MATCH_MESSAGE_ERROR = "`result.match` expected an Error callback";
|
|
35
|
+
const MATCH_MESSAGE_OK = "`result.match` expected an Ok callback";
|
|
36
|
+
const MATCH_MESSAGE_RESULT = "`result.match` expected a Result or a function that returns a Result";
|
|
25
37
|
matchResult.async = asyncMatchResult;
|
|
26
38
|
//#endregion
|
|
27
39
|
export { asyncMatchResult, matchResult };
|
package/dist/result/misc.d.mts
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
import { GenericCallback } from "../../models.mjs";
|
|
2
|
-
import { Result, UnwrapValue } from "../../
|
|
1
|
+
import { GenericCallback } from "../../models/index.mjs";
|
|
2
|
+
import { AttemptAsyncFlow, AttemptFlow, Result, UnwrapValue } from "../../models/result.model.mjs";
|
|
3
3
|
//#region src/result/work/flow.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* A synchronous _Flow_, a function that attempts to pipe values through a series of functions
|
|
6
|
-
*/
|
|
7
|
-
export type AttemptFlow<Callback extends GenericCallback, Value> = (...args: Parameters<Callback>) => Result<UnwrapValue<Value>>;
|
|
8
|
-
/**
|
|
9
|
-
* An asynchronous _Flow_, a function that attempts to pipe values through a series of functions
|
|
10
|
-
*/
|
|
11
|
-
export type AttemptFlowPromise<Callback extends GenericCallback, Value> = (...args: Parameters<Callback>) => Promise<Result<UnwrapValue<Value>>>;
|
|
12
4
|
/**
|
|
13
5
|
* Create an asynchronous _Flow_, a function that attempts to pipe a value through a series of functions
|
|
14
6
|
*
|
|
@@ -16,7 +8,7 @@ export type AttemptFlowPromise<Callback extends GenericCallback, Value> = (...ar
|
|
|
16
8
|
*
|
|
17
9
|
* @returns _Flow_ function
|
|
18
10
|
*/
|
|
19
|
-
export declare function attemptAsyncFlow<Fn extends GenericCallback>(fn: Fn):
|
|
11
|
+
export declare function attemptAsyncFlow<Fn extends GenericCallback>(fn: Fn): AttemptAsyncFlow<Fn, ReturnType<Fn>>;
|
|
20
12
|
/**
|
|
21
13
|
* Create an asynchronous _Flow_, a function that pipes values through a series of functions
|
|
22
14
|
*
|
|
@@ -24,7 +16,7 @@ export declare function attemptAsyncFlow<Fn extends GenericCallback>(fn: Fn): At
|
|
|
24
16
|
*
|
|
25
17
|
* @returns _Flow_ function
|
|
26
18
|
*/
|
|
27
|
-
export declare function attemptAsyncFlow<First extends GenericCallback, Second>(first: First, second: (value: Awaited<UnwrapValue<ReturnType<First>>>) => Second):
|
|
19
|
+
export declare function attemptAsyncFlow<First extends GenericCallback, Second>(first: First, second: (value: Awaited<UnwrapValue<ReturnType<First>>>) => Second): AttemptAsyncFlow<First, Second>;
|
|
28
20
|
/**
|
|
29
21
|
* Create an asynchronous _Flow_, a function that pipes values through a series of functions
|
|
30
22
|
*
|
|
@@ -32,7 +24,7 @@ export declare function attemptAsyncFlow<First extends GenericCallback, Second>(
|
|
|
32
24
|
*
|
|
33
25
|
* @returns _Flow_ function
|
|
34
26
|
*/
|
|
35
|
-
export declare function attemptAsyncFlow<First extends GenericCallback, Second, Third>(first: First, second: (value: Awaited<UnwrapValue<ReturnType<First>>>) => Second, third: (value: Awaited<UnwrapValue<Second>>) => Third):
|
|
27
|
+
export declare function attemptAsyncFlow<First extends GenericCallback, Second, Third>(first: First, second: (value: Awaited<UnwrapValue<ReturnType<First>>>) => Second, third: (value: Awaited<UnwrapValue<Second>>) => Third): AttemptAsyncFlow<First, Third>;
|
|
36
28
|
/**
|
|
37
29
|
* Create an asynchronous _Flow_, a function that pipes values through a series of functions
|
|
38
30
|
*
|
|
@@ -40,7 +32,7 @@ export declare function attemptAsyncFlow<First extends GenericCallback, Second,
|
|
|
40
32
|
*
|
|
41
33
|
* @returns _Flow_ function
|
|
42
34
|
*/
|
|
43
|
-
export declare function attemptAsyncFlow<First extends GenericCallback, Second, Third, Fourth>(first: First, second: (value: Awaited<UnwrapValue<ReturnType<First>>>) => Second, third: (value: Awaited<UnwrapValue<Second>>) => Third, fourth: (value: Awaited<UnwrapValue<Third>>) => Fourth):
|
|
35
|
+
export declare function attemptAsyncFlow<First extends GenericCallback, Second, Third, Fourth>(first: First, second: (value: Awaited<UnwrapValue<ReturnType<First>>>) => Second, third: (value: Awaited<UnwrapValue<Second>>) => Third, fourth: (value: Awaited<UnwrapValue<Third>>) => Fourth): AttemptAsyncFlow<First, Fourth>;
|
|
44
36
|
/**
|
|
45
37
|
* Create an asynchronous _Flow_, a function that pipes values through a series of functions
|
|
46
38
|
*
|
|
@@ -48,7 +40,7 @@ export declare function attemptAsyncFlow<First extends GenericCallback, Second,
|
|
|
48
40
|
*
|
|
49
41
|
* @returns _Flow_ function
|
|
50
42
|
*/
|
|
51
|
-
export declare function attemptAsyncFlow<First extends GenericCallback, Second, Third, Fourth, Fifth>(first: First, second: (value: Awaited<UnwrapValue<ReturnType<First>>>) => Second, third: (value: Awaited<UnwrapValue<Second>>) => Third, fourth: (value: Awaited<UnwrapValue<Third>>) => Fourth, fifth: (value: Awaited<UnwrapValue<Fourth>>) => Fifth):
|
|
43
|
+
export declare function attemptAsyncFlow<First extends GenericCallback, Second, Third, Fourth, Fifth>(first: First, second: (value: Awaited<UnwrapValue<ReturnType<First>>>) => Second, third: (value: Awaited<UnwrapValue<Second>>) => Third, fourth: (value: Awaited<UnwrapValue<Third>>) => Fourth, fifth: (value: Awaited<UnwrapValue<Fourth>>) => Fifth): AttemptAsyncFlow<First, Fifth>;
|
|
52
44
|
/**
|
|
53
45
|
* Create an asynchronous _Flow_, a function that pipes values through a series of functions
|
|
54
46
|
*
|
|
@@ -56,7 +48,7 @@ export declare function attemptAsyncFlow<First extends GenericCallback, Second,
|
|
|
56
48
|
*
|
|
57
49
|
* @returns _Flow_ function
|
|
58
50
|
*/
|
|
59
|
-
export declare function attemptAsyncFlow<First extends GenericCallback, Second, Third, Fourth, Fifth, Sixth>(first: First, second: (value: Awaited<UnwrapValue<ReturnType<First>>>) => Second, third: (value: Awaited<UnwrapValue<Second>>) => Third, fourth: (value: Awaited<UnwrapValue<Third>>) => Fourth, fifth: (value: Awaited<UnwrapValue<Fourth>>) => Fifth, sixth: (value: Awaited<UnwrapValue<Fifth>>) => Sixth):
|
|
51
|
+
export declare function attemptAsyncFlow<First extends GenericCallback, Second, Third, Fourth, Fifth, Sixth>(first: First, second: (value: Awaited<UnwrapValue<ReturnType<First>>>) => Second, third: (value: Awaited<UnwrapValue<Second>>) => Third, fourth: (value: Awaited<UnwrapValue<Third>>) => Fourth, fifth: (value: Awaited<UnwrapValue<Fourth>>) => Fifth, sixth: (value: Awaited<UnwrapValue<Fifth>>) => Sixth): AttemptAsyncFlow<First, Sixth>;
|
|
60
52
|
/**
|
|
61
53
|
* Create an asynchronous _Flow_, a function that pipes values through a series of functions
|
|
62
54
|
*
|
|
@@ -64,7 +56,7 @@ export declare function attemptAsyncFlow<First extends GenericCallback, Second,
|
|
|
64
56
|
*
|
|
65
57
|
* @returns _Flow_ function
|
|
66
58
|
*/
|
|
67
|
-
export declare function attemptAsyncFlow<First extends GenericCallback, Second, Third, Fourth, Fifth, Sixth, Seventh>(first: First, second: (value: Awaited<UnwrapValue<ReturnType<First>>>) => Second, third: (value: Awaited<UnwrapValue<Second>>) => Third, fourth: (value: Awaited<UnwrapValue<Third>>) => Fourth, fifth: (value: Awaited<UnwrapValue<Fourth>>) => Fifth, sixth: (value: Awaited<UnwrapValue<Fifth>>) => Sixth, seventh: (value: Awaited<UnwrapValue<Sixth>>) => Seventh):
|
|
59
|
+
export declare function attemptAsyncFlow<First extends GenericCallback, Second, Third, Fourth, Fifth, Sixth, Seventh>(first: First, second: (value: Awaited<UnwrapValue<ReturnType<First>>>) => Second, third: (value: Awaited<UnwrapValue<Second>>) => Third, fourth: (value: Awaited<UnwrapValue<Third>>) => Fourth, fifth: (value: Awaited<UnwrapValue<Fourth>>) => Fifth, sixth: (value: Awaited<UnwrapValue<Fifth>>) => Sixth, seventh: (value: Awaited<UnwrapValue<Sixth>>) => Seventh): AttemptAsyncFlow<First, Seventh>;
|
|
68
60
|
/**
|
|
69
61
|
* Create an asynchronous _Flow_, a function that pipes values through a series of functions
|
|
70
62
|
*
|
|
@@ -72,7 +64,7 @@ export declare function attemptAsyncFlow<First extends GenericCallback, Second,
|
|
|
72
64
|
*
|
|
73
65
|
* @returns _Flow_ function
|
|
74
66
|
*/
|
|
75
|
-
export declare function attemptAsyncFlow<First extends GenericCallback, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth>(first: First, second: (value: Awaited<UnwrapValue<ReturnType<First>>>) => Second, third: (value: Awaited<UnwrapValue<Second>>) => Third, fourth: (value: Awaited<UnwrapValue<Third>>) => Fourth, fifth: (value: Awaited<UnwrapValue<Fourth>>) => Fifth, sixth: (value: Awaited<UnwrapValue<Fifth>>) => Sixth, seventh: (value: Awaited<UnwrapValue<Sixth>>) => Seventh, eighth: (value: Awaited<UnwrapValue<Seventh>>) => Eighth):
|
|
67
|
+
export declare function attemptAsyncFlow<First extends GenericCallback, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth>(first: First, second: (value: Awaited<UnwrapValue<ReturnType<First>>>) => Second, third: (value: Awaited<UnwrapValue<Second>>) => Third, fourth: (value: Awaited<UnwrapValue<Third>>) => Fourth, fifth: (value: Awaited<UnwrapValue<Fourth>>) => Fifth, sixth: (value: Awaited<UnwrapValue<Fifth>>) => Sixth, seventh: (value: Awaited<UnwrapValue<Sixth>>) => Seventh, eighth: (value: Awaited<UnwrapValue<Seventh>>) => Eighth): AttemptAsyncFlow<First, Eighth>;
|
|
76
68
|
/**
|
|
77
69
|
* Create an asynchronous _Flow_, a function that pipes values through a series of functions
|
|
78
70
|
*
|
|
@@ -80,7 +72,7 @@ export declare function attemptAsyncFlow<First extends GenericCallback, Second,
|
|
|
80
72
|
*
|
|
81
73
|
* @returns _Flow_ function
|
|
82
74
|
*/
|
|
83
|
-
export declare function attemptAsyncFlow<First extends GenericCallback, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth>(first: First, second: (value: Awaited<UnwrapValue<ReturnType<First>>>) => Second, third: (value: Awaited<UnwrapValue<Second>>) => Third, fourth: (value: Awaited<UnwrapValue<Third>>) => Fourth, fifth: (value: Awaited<UnwrapValue<Fourth>>) => Fifth, sixth: (value: Awaited<UnwrapValue<Fifth>>) => Sixth, seventh: (value: Awaited<UnwrapValue<Sixth>>) => Seventh, eighth: (value: Awaited<UnwrapValue<Seventh>>) => Eighth, ninth: (value: Awaited<UnwrapValue<Eighth>>) => Ninth):
|
|
75
|
+
export declare function attemptAsyncFlow<First extends GenericCallback, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth>(first: First, second: (value: Awaited<UnwrapValue<ReturnType<First>>>) => Second, third: (value: Awaited<UnwrapValue<Second>>) => Third, fourth: (value: Awaited<UnwrapValue<Third>>) => Fourth, fifth: (value: Awaited<UnwrapValue<Fourth>>) => Fifth, sixth: (value: Awaited<UnwrapValue<Fifth>>) => Sixth, seventh: (value: Awaited<UnwrapValue<Sixth>>) => Seventh, eighth: (value: Awaited<UnwrapValue<Seventh>>) => Eighth, ninth: (value: Awaited<UnwrapValue<Eighth>>) => Ninth): AttemptAsyncFlow<First, Ninth>;
|
|
84
76
|
/**
|
|
85
77
|
* Create an asynchronous _Flow_, a function that pipes values through a series of functions
|
|
86
78
|
*
|
|
@@ -88,7 +80,7 @@ export declare function attemptAsyncFlow<First extends GenericCallback, Second,
|
|
|
88
80
|
*
|
|
89
81
|
* @returns _Flow_ function
|
|
90
82
|
*/
|
|
91
|
-
export declare function attemptAsyncFlow<First extends GenericCallback, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth, Tenth>(first: First, second: (value: Awaited<UnwrapValue<ReturnType<First>>>) => Second, third: (value: Awaited<UnwrapValue<Second>>) => Third, fourth: (value: Awaited<UnwrapValue<Third>>) => Fourth, fifth: (value: Awaited<UnwrapValue<Fourth>>) => Fifth, sixth: (value: Awaited<UnwrapValue<Fifth>>) => Sixth, seventh: (value: Awaited<UnwrapValue<Sixth>>) => Seventh, eighth: (value: Awaited<UnwrapValue<Seventh>>) => Eighth, ninth: (value: Awaited<UnwrapValue<Eighth>>) => Ninth, tenth: (value: Awaited<UnwrapValue<Ninth>>) => Tenth):
|
|
83
|
+
export declare function attemptAsyncFlow<First extends GenericCallback, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth, Tenth>(first: First, second: (value: Awaited<UnwrapValue<ReturnType<First>>>) => Second, third: (value: Awaited<UnwrapValue<Second>>) => Third, fourth: (value: Awaited<UnwrapValue<Third>>) => Fourth, fifth: (value: Awaited<UnwrapValue<Fourth>>) => Fifth, sixth: (value: Awaited<UnwrapValue<Fifth>>) => Sixth, seventh: (value: Awaited<UnwrapValue<Sixth>>) => Seventh, eighth: (value: Awaited<UnwrapValue<Seventh>>) => Eighth, ninth: (value: Awaited<UnwrapValue<Eighth>>) => Ninth, tenth: (value: Awaited<UnwrapValue<Ninth>>) => Tenth): AttemptAsyncFlow<First, Tenth>;
|
|
92
84
|
/**
|
|
93
85
|
* Create an asynchronous _Flow_, a function that pipes values through a series of functions
|
|
94
86
|
*
|
|
@@ -96,7 +88,7 @@ export declare function attemptAsyncFlow<First extends GenericCallback, Second,
|
|
|
96
88
|
*
|
|
97
89
|
* @returns _Flow_ function
|
|
98
90
|
*/
|
|
99
|
-
export declare function attemptAsyncFlow<Fn extends GenericCallback>(fn: Fn, ...fns: Array<(value: Awaited<UnwrapValue<ReturnType<Fn>>>) => unknown>):
|
|
91
|
+
export declare function attemptAsyncFlow<Fn extends GenericCallback>(fn: Fn, ...fns: Array<(value: Awaited<UnwrapValue<ReturnType<Fn>>>) => unknown>): AttemptAsyncFlow<Fn, ReturnType<Fn>>;
|
|
100
92
|
/**
|
|
101
93
|
* Create an asynchronous _Flow_, a function that pipes values through a series of functions
|
|
102
94
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { GenericCallback } from "../../models.mjs";
|
|
2
|
-
import { Result, UnwrapValue } from "../../
|
|
1
|
+
import { GenericCallback } from "../../models/index.mjs";
|
|
2
|
+
import { Result, UnwrapValue } from "../../models/result.model.mjs";
|
|
3
3
|
//#region src/result/work/pipe.d.ts
|
|
4
4
|
type WrapValue<Value> = Result<UnwrapValue<Value>>;
|
|
5
5
|
/**
|
package/dist/string/fuzzy.d.mts
CHANGED
|
@@ -1,90 +1,7 @@
|
|
|
1
|
-
import { PlainObject } from "../models.mjs";
|
|
1
|
+
import { PlainObject } from "../models/index.mjs";
|
|
2
|
+
import { Fuzzy, FuzzyConfiguration, FuzzyItem, FuzzyOptions, FuzzyResult, FuzzyState } from "../models/string/string.fuzzy.model.mjs";
|
|
2
3
|
//#region src/string/fuzzy.d.ts
|
|
3
|
-
|
|
4
|
-
* Fuzzy searcher for an array of items
|
|
5
|
-
*/
|
|
6
|
-
export type Fuzzy<Item> = {
|
|
7
|
-
/**
|
|
8
|
-
* Get items currently being searched through
|
|
9
|
-
*
|
|
10
|
-
* @returns Original items
|
|
11
|
-
*/
|
|
12
|
-
get items(): Item[];
|
|
13
|
-
/**
|
|
14
|
-
* Set new items to search through
|
|
15
|
-
*
|
|
16
|
-
* @param items New items to search through
|
|
17
|
-
*/
|
|
18
|
-
set items(items: Item[]);
|
|
19
|
-
/**
|
|
20
|
-
* Get strings currently being searched through _(the stringified version of `items`)_
|
|
21
|
-
*
|
|
22
|
-
* @returns Stringified items
|
|
23
|
-
*/
|
|
24
|
-
get strings(): string[];
|
|
25
|
-
/**
|
|
26
|
-
* Search for items matching the given value
|
|
27
|
-
*
|
|
28
|
-
* @param value Value to search for
|
|
29
|
-
* @param options Search options
|
|
30
|
-
* @returns Search results, with exact matches _(ordered)_ and similar matches _(ordered by relevance)_
|
|
31
|
-
*/
|
|
32
|
-
search(value: string, options?: FuzzyOptions): FuzzyResult<Item>;
|
|
33
|
-
/**
|
|
34
|
-
* Search for items matching the given value
|
|
35
|
-
*
|
|
36
|
-
* @param value Value to search for
|
|
37
|
-
* @param limit Maximum number of combined items to return in `exact` and `similar`
|
|
38
|
-
* @returns Search results, with exact matches _(ordered)_ and similar matches _(ordered by relevance)_
|
|
39
|
-
*/
|
|
40
|
-
search(value: string, limit: number): FuzzyResult<Item>;
|
|
41
|
-
};
|
|
42
|
-
export type FuzzyConfiguration<Item> = {
|
|
43
|
-
/**
|
|
44
|
-
* Handler to stringify items
|
|
45
|
-
*
|
|
46
|
-
* - May be a function that takes an item and returns a string, or if items are plain objects, a key of the item to use to grab a string value from
|
|
47
|
-
* - Defaults to `getString`
|
|
48
|
-
*/
|
|
49
|
-
handler?: (item: Item) => string;
|
|
50
|
-
} & (Item extends PlainObject ? {
|
|
51
|
-
/**
|
|
52
|
-
* Key to use to stringify items
|
|
53
|
-
*
|
|
54
|
-
* _Prioritized over `handler`_
|
|
55
|
-
*/
|
|
56
|
-
key?: keyof Item;
|
|
57
|
-
} : {}) & FuzzyOptions;
|
|
58
|
-
export type FuzzyOptions = {
|
|
59
|
-
/**
|
|
60
|
-
* Maximum number of combined items to return in `exact` and `similar` _(defaults to all matches)_
|
|
61
|
-
*/
|
|
62
|
-
limit?: number;
|
|
63
|
-
/**
|
|
64
|
-
* Maximum score difference between the best and worst similar matches included in results
|
|
65
|
-
*
|
|
66
|
-
* - Higher values cast a wider net
|
|
67
|
-
* - Defaults to `5`
|
|
68
|
-
*/
|
|
69
|
-
tolerance?: number;
|
|
70
|
-
};
|
|
71
|
-
/**
|
|
72
|
-
* Search results from a fuzzy search, with exact and similar matches
|
|
73
|
-
*/
|
|
74
|
-
export type FuzzyResult<Item> = {
|
|
75
|
-
/**
|
|
76
|
-
* Ordered items that exactly match the search value
|
|
77
|
-
*/
|
|
78
|
-
exact: Item[];
|
|
79
|
-
/**
|
|
80
|
-
* Ordered items that are similar to the search value, ranked by relevance
|
|
81
|
-
*/
|
|
82
|
-
similar: Item[];
|
|
83
|
-
};
|
|
84
|
-
/**
|
|
85
|
-
* Options for fuzzy searching
|
|
86
|
-
*/
|
|
87
|
-
export type FuzzySearchOptions = FuzzyOptions;
|
|
4
|
+
declare function Fuzzy(this: any, state: FuzzyState<unknown>): void;
|
|
88
5
|
/**
|
|
89
6
|
* Create a fuzzy searcher for an array of items
|
|
90
7
|
*
|
|
@@ -132,4 +49,5 @@ export declare namespace fuzzy {
|
|
|
132
49
|
export var is: typeof isFuzzy;
|
|
133
50
|
export var match: typeof fuzzyMatch;
|
|
134
51
|
}
|
|
135
|
-
//#endregion
|
|
52
|
+
//#endregion
|
|
53
|
+
export type { Fuzzy, FuzzyItem, FuzzyOptions, FuzzyResult };
|