@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.
Files changed (252) hide show
  1. package/dist/array/difference.d.mts +1 -1
  2. package/dist/array/difference.mjs +3 -2
  3. package/dist/array/exists.d.mts +1 -1
  4. package/dist/array/exists.mjs +3 -2
  5. package/dist/array/filter.d.mts +1 -1
  6. package/dist/array/filter.mjs +1 -0
  7. package/dist/array/find.d.mts +1 -1
  8. package/dist/array/find.mjs +4 -3
  9. package/dist/array/first.d.mts +1 -1
  10. package/dist/array/flatten.d.mts +1 -1
  11. package/dist/array/group-by.d.mts +1 -1
  12. package/dist/array/index.d.mts +2 -2
  13. package/dist/array/insert.mjs +3 -2
  14. package/dist/array/intersection.mjs +3 -2
  15. package/dist/array/last.d.mts +1 -1
  16. package/dist/array/move.d.mts +1 -1
  17. package/dist/array/partition.d.mts +1 -1
  18. package/dist/array/partition.mjs +1 -0
  19. package/dist/array/push.mjs +3 -2
  20. package/dist/array/select.d.mts +10 -12
  21. package/dist/array/select.mjs +1 -0
  22. package/dist/array/single.d.mts +1 -1
  23. package/dist/array/single.mjs +1 -0
  24. package/dist/array/slice.d.mts +1 -1
  25. package/dist/array/slice.mjs +4 -5
  26. package/dist/array/sort.d.mts +4 -103
  27. package/dist/array/sort.mjs +6 -14
  28. package/dist/array/splice.mjs +3 -2
  29. package/dist/array/swap.d.mts +1 -1
  30. package/dist/array/to-map.d.mts +1 -1
  31. package/dist/array/to-record.d.mts +1 -1
  32. package/dist/array/to-set.d.mts +1 -1
  33. package/dist/array/toggle.d.mts +1 -1
  34. package/dist/array/union.mjs +3 -2
  35. package/dist/array/unique.d.mts +1 -1
  36. package/dist/array/unique.mjs +3 -2
  37. package/dist/array/update.d.mts +1 -1
  38. package/dist/beacon.d.mts +6 -92
  39. package/dist/beacon.mjs +6 -16
  40. package/dist/color/constants.d.mts +2 -2
  41. package/dist/color/constants.mjs +1 -1
  42. package/dist/color/index.d.mts +1 -1
  43. package/dist/color/instance.d.mts +1 -1
  44. package/dist/color/misc/alpha.d.mts +1 -1
  45. package/dist/color/misc/format.d.mts +1 -1
  46. package/dist/color/misc/get.d.mts +1 -1
  47. package/dist/color/misc/is.d.mts +2 -2
  48. package/dist/color/misc/is.mjs +1 -0
  49. package/dist/color/misc/state.d.mts +1 -1
  50. package/dist/color/space/hex.d.mts +1 -1
  51. package/dist/color/space/hsl.d.mts +1 -1
  52. package/dist/color/space/hwb.d.mts +1 -1
  53. package/dist/color/space/rgb.d.mts +1 -1
  54. package/dist/function/limit.d.mts +2 -2
  55. package/dist/function/limit.mjs +2 -1
  56. package/dist/function/once.d.mts +7 -3
  57. package/dist/function/once.mjs +5 -10
  58. package/dist/function/retry.d.mts +4 -14
  59. package/dist/function/retry.mjs +3 -15
  60. package/dist/herald.d.mts +2 -2
  61. package/dist/index.d.mts +425 -318
  62. package/dist/index.mjs +454 -408
  63. package/dist/internal/aborter.d.mts +1 -6
  64. package/dist/internal/aborter.mjs +3 -4
  65. package/dist/internal/array/callbacks.d.mts +3 -7
  66. package/dist/internal/array/chunk.mjs +2 -2
  67. package/dist/internal/array/find.d.mts +5 -23
  68. package/dist/internal/array/find.mjs +5 -9
  69. package/dist/internal/array/get.d.mts +1 -1
  70. package/dist/internal/array/group.d.mts +1 -1
  71. package/dist/internal/array/index-of.d.mts +1 -1
  72. package/dist/internal/array/index-of.mjs +4 -3
  73. package/dist/internal/array/insert.d.mts +2 -5
  74. package/dist/internal/array/insert.mjs +2 -4
  75. package/dist/internal/array/match.d.mts +2 -5
  76. package/dist/internal/array/match.mjs +10 -20
  77. package/dist/internal/array/overlap.d.mts +2 -10
  78. package/dist/internal/array/sets.d.mts +2 -5
  79. package/dist/internal/array/sets.mjs +5 -7
  80. package/dist/internal/function/assert.d.mts +5 -12
  81. package/dist/internal/function/assert.mjs +2 -2
  82. package/dist/internal/function/limit.d.mts +2 -37
  83. package/dist/internal/function/limit.mjs +4 -15
  84. package/dist/internal/function/memoize.d.mts +5 -70
  85. package/dist/internal/function/memoize.mjs +2 -5
  86. package/dist/internal/function/work.d.mts +16 -22
  87. package/dist/internal/function/work.mjs +1 -8
  88. package/dist/internal/herald.d.mts +3 -3
  89. package/dist/internal/herald.mjs +2 -1
  90. package/dist/internal/is.d.mts +1 -1
  91. package/dist/internal/math/aggregate.d.mts +2 -14
  92. package/dist/internal/math/aggregate.mjs +2 -5
  93. package/dist/internal/number.mjs +4 -7
  94. package/dist/internal/result/attempt.d.mts +1 -1
  95. package/dist/internal/result/misc.d.mts +1 -1
  96. package/dist/internal/string/case.mjs +6 -16
  97. package/dist/internal/string/misc.mjs +1 -2
  98. package/dist/internal/subscription.d.mts +1 -100
  99. package/dist/internal/subscription.mjs +3 -9
  100. package/dist/internal/value/compare.d.mts +4 -4
  101. package/dist/internal/value/compare.mjs +1 -1
  102. package/dist/internal/value/equal.d.mts +6 -57
  103. package/dist/internal/value/equal.mjs +5 -10
  104. package/dist/internal/value/get.d.mts +1 -1
  105. package/dist/internal/value/handlers.d.mts +2 -21
  106. package/dist/internal/value/has.d.mts +2 -2
  107. package/dist/internal/value/misc.d.mts +1 -1
  108. package/dist/internal/value/misc.mjs +8 -14
  109. package/dist/internal/value/set.d.mts +1 -1
  110. package/dist/internal/value/set.mjs +2 -2
  111. package/dist/is.mjs +3 -3
  112. package/dist/logger.d.mts +3 -70
  113. package/dist/logger.mjs +2 -5
  114. package/dist/math.d.mts +1 -1
  115. package/dist/math.mjs +2 -1
  116. package/dist/models/aborter.model.d.mts +12 -0
  117. package/dist/models/aborter.model.mjs +5 -0
  118. package/dist/models/array/array.find.model.d.mts +22 -0
  119. package/dist/models/array/array.find.model.mjs +8 -0
  120. package/dist/models/array/array.match.model.d.mts +14 -0
  121. package/dist/models/array/array.match.model.mjs +14 -0
  122. package/dist/models/array/array.misc.model.d.mts +36 -0
  123. package/dist/models/array/array.misc.model.mjs +12 -0
  124. package/dist/models/array/array.sort.model.d.mts +122 -0
  125. package/dist/models/array/array.sort.model.mjs +12 -0
  126. package/dist/models/beacon.model.d.mts +119 -0
  127. package/dist/models/beacon.model.mjs +16 -0
  128. package/dist/{color/models.d.mts → models/color.model.d.mts} +4 -4
  129. package/dist/models/function/assert.model.d.mts +13 -0
  130. package/dist/models/function/assert.model.mjs +4 -0
  131. package/dist/models/function/limiter.model.d.mts +71 -0
  132. package/dist/models/function/limiter.model.mjs +15 -0
  133. package/dist/models/function/memoize.model.d.mts +88 -0
  134. package/dist/models/function/memoize.model.mjs +7 -0
  135. package/dist/models/function/once.model.d.mts +76 -0
  136. package/dist/models/function/once.model.mjs +9 -0
  137. package/dist/models/function/retry.model.d.mts +17 -0
  138. package/dist/models/function/retry.model.mjs +17 -0
  139. package/dist/models/function/work.model.d.mts +20 -0
  140. package/dist/models/function/work.model.mjs +11 -0
  141. package/dist/{internal/models → models}/herald.model.d.mts +3 -3
  142. package/dist/{internal/models → models}/herald.model.mjs +2 -2
  143. package/dist/{models.d.mts → models/index.d.mts} +5 -47
  144. package/dist/models/logger.model.d.mts +83 -0
  145. package/dist/models/logger.model.mjs +7 -0
  146. package/dist/models/math.model.d.mts +16 -0
  147. package/dist/models/math.model.mjs +7 -0
  148. package/dist/models/misc.model.d.mts +10 -0
  149. package/dist/models/misc.model.mjs +11 -0
  150. package/dist/{internal/models → models}/plan.model.d.mts +3 -3
  151. package/dist/{internal/models → models}/plan.model.mjs +1 -1
  152. package/dist/models/promise.model.d.mts +119 -0
  153. package/dist/models/promise.model.mjs +47 -0
  154. package/dist/models/query.model.d.mts +9 -0
  155. package/dist/models/query.model.mjs +14 -0
  156. package/dist/models/queue.model.d.mts +251 -0
  157. package/dist/models/queue.model.mjs +29 -0
  158. package/dist/models/random.model.d.mts +6 -0
  159. package/dist/models/random.model.mjs +7 -0
  160. package/dist/{internal/models → models}/result.model.d.mts +10 -2
  161. package/dist/models/string/string.case.model.d.mts +19 -0
  162. package/dist/models/string/string.case.model.mjs +14 -0
  163. package/dist/models/string/string.fuzzy.model.d.mts +108 -0
  164. package/dist/models/string/string.fuzzy.model.mjs +9 -0
  165. package/dist/models/string/string.misc.model.d.mts +13 -0
  166. package/dist/models/string/string.misc.model.mjs +13 -0
  167. package/dist/models/string/string.normalize.model.d.mts +85 -0
  168. package/dist/models/string/string.normalize.model.mjs +43 -0
  169. package/dist/models/string/string.template.model.d.mts +50 -0
  170. package/dist/models/string/string.template.model.mjs +5 -0
  171. package/dist/models/subscription.model.d.mts +127 -0
  172. package/dist/models/subscription.model.mjs +10 -0
  173. package/dist/models/value/value.clone.model.d.mts +56 -0
  174. package/dist/models/value/value.clone.model.mjs +24 -0
  175. package/dist/models/value/value.diff.model.d.mts +61 -0
  176. package/dist/models/value/value.diff.model.mjs +6 -0
  177. package/dist/models/value/value.equal.model.d.mts +76 -0
  178. package/dist/models/value/value.equal.model.mjs +9 -0
  179. package/dist/models/value/value.handler.model.d.mts +27 -0
  180. package/dist/models/value/value.handler.model.mjs +1 -0
  181. package/dist/models/value/value.merge.model.d.mts +82 -0
  182. package/dist/models/value/value.merge.model.mjs +5 -0
  183. package/dist/models/value/value.misc.model.d.mts +33 -0
  184. package/dist/models/value/value.misc.model.mjs +12 -0
  185. package/dist/models/value/value.transform.model.d.mts +28 -0
  186. package/dist/models/value/value.transform.model.mjs +4 -0
  187. package/dist/plan/generate.d.mts +3 -2
  188. package/dist/plan/generate.mjs +11 -7
  189. package/dist/plan/index.d.mts +1 -1
  190. package/dist/plan/index.mjs +1 -1
  191. package/dist/plan/is.d.mts +1 -1
  192. package/dist/plan/is.mjs +1 -1
  193. package/dist/plan/misc.d.mts +1 -1
  194. package/dist/plan/models.d.mts +1 -1
  195. package/dist/plan/result.d.mts +2 -2
  196. package/dist/plan/result.mjs +3 -3
  197. package/dist/plan/run.d.mts +1 -1
  198. package/dist/plan/run.mjs +3 -3
  199. package/dist/promise/delay.d.mts +1 -1
  200. package/dist/promise/delay.mjs +2 -1
  201. package/dist/promise/helpers.d.mts +2 -2
  202. package/dist/promise/helpers.mjs +6 -6
  203. package/dist/promise/index.d.mts +2 -2
  204. package/dist/promise/index.mjs +1 -1
  205. package/dist/promise/misc.d.mts +3 -3
  206. package/dist/promise/misc.mjs +7 -4
  207. package/dist/promise/models.d.mts +2 -106
  208. package/dist/promise/models.mjs +1 -35
  209. package/dist/promise/timed.d.mts +2 -2
  210. package/dist/promise/timed.mjs +3 -3
  211. package/dist/query.d.mts +1 -1
  212. package/dist/query.mjs +5 -15
  213. package/dist/queue.d.mts +6 -200
  214. package/dist/queue.mjs +9 -34
  215. package/dist/random.mjs +2 -5
  216. package/dist/result/match.d.mts +1 -1
  217. package/dist/result/match.mjs +27 -15
  218. package/dist/result/misc.d.mts +1 -1
  219. package/dist/result/work/flow.d.mts +13 -21
  220. package/dist/result/work/pipe.d.mts +2 -2
  221. package/dist/string/fuzzy.d.mts +5 -87
  222. package/dist/string/fuzzy.mjs +6 -11
  223. package/dist/string/index.mjs +6 -8
  224. package/dist/string/match.mjs +4 -6
  225. package/dist/string/normalize.d.mts +4 -40
  226. package/dist/string/normalize.mjs +9 -48
  227. package/dist/string/template.d.mts +5 -43
  228. package/dist/string/template.mjs +1 -2
  229. package/dist/subscription.d.mts +2 -1
  230. package/dist/value/clone.d.mts +6 -42
  231. package/dist/value/clone.mjs +10 -30
  232. package/dist/value/collection.mjs +2 -0
  233. package/dist/value/diff.d.mts +3 -44
  234. package/dist/value/diff.mjs +1 -3
  235. package/dist/value/freeze.d.mts +1 -5
  236. package/dist/value/index.d.mts +4 -3
  237. package/dist/value/merge.d.mts +6 -64
  238. package/dist/value/merge.mjs +8 -8
  239. package/dist/value/omit.d.mts +1 -1
  240. package/dist/value/pick.d.mts +1 -1
  241. package/dist/value/shake.d.mts +4 -6
  242. package/dist/value/smush.d.mts +4 -6
  243. package/dist/value/smush.mjs +2 -2
  244. package/dist/value/transform.d.mts +6 -22
  245. package/dist/value/transform.mjs +1 -1
  246. package/dist/value/unsmush.d.mts +4 -10
  247. package/package.json +12 -4
  248. package/dist/promise/constants.d.mts +0 -17
  249. package/dist/promise/constants.mjs +0 -15
  250. /package/dist/{color/models.mjs → models/color.model.mjs} +0 -0
  251. /package/dist/{internal/models/result.model.mjs → models/index.mjs} +0 -0
  252. /package/dist/{models.mjs → models/result.model.mjs} +0 -0
@@ -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 "../../models.mjs";
2
- //#region src/internal/models/result.model.d.ts
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 };
@@ -0,0 +1,108 @@
1
+ import { PlainObject } from "../index.mjs";
2
+ //#region src/models/string/string.fuzzy.model.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 FuzzyItem<Item> = {
59
+ item: Item;
60
+ haystack: string;
61
+ };
62
+ export type FuzzyOptions = {
63
+ /**
64
+ * Maximum number of combined items to return in `exact` and `similar` _(defaults to all matches)_
65
+ */
66
+ limit?: number;
67
+ /**
68
+ * Maximum score difference between the best and worst similar matches included in results
69
+ *
70
+ * - Higher values cast a wider net
71
+ * - Defaults to `5`
72
+ */
73
+ tolerance?: number;
74
+ };
75
+ /**
76
+ * Search results from a fuzzy search, with exact and similar matches
77
+ */
78
+ export type FuzzyResult<Item> = {
79
+ /**
80
+ * Ordered items that exactly match the search value
81
+ */
82
+ exact: Item[];
83
+ /**
84
+ * Ordered items that are similar to the search value, ranked by relevance
85
+ */
86
+ similar: Item[];
87
+ };
88
+ /**
89
+ * Options for fuzzy searching
90
+ */
91
+ export type FuzzySearchOptions = FuzzyOptions;
92
+ export type FuzzyState<Item> = {
93
+ handler(item: Item): string;
94
+ items: Item[];
95
+ limit?: number;
96
+ strings: string[];
97
+ tolerance: number;
98
+ };
99
+ export type InternalFuzzy<Item = unknown> = {
100
+ [FUZZY_SYMBOL]: FuzzyState<Item>;
101
+ } & Fuzzy<Item>;
102
+ export declare const FUZZY_LENGTH_DIVISOR = 3;
103
+ export declare const FUZZY_MESSAGE_ARRAY = "Fuzzy requires an array of items";
104
+ export declare const FUZZY_MESSAGE_HANDLER = "Fuzzy requires a key or function to stringify items";
105
+ export declare const FUZZY_PROPERTY = "$fuzzy";
106
+ export declare const FUZZY_PROXIMITY_THRESHOLD = 5;
107
+ export declare const FUZZY_SYMBOL: unique symbol;
108
+ //#endregion
@@ -0,0 +1,9 @@
1
+ //#region src/models/string/string.fuzzy.model.ts
2
+ const FUZZY_LENGTH_DIVISOR = 3;
3
+ const FUZZY_MESSAGE_ARRAY = "Fuzzy requires an array of items";
4
+ const FUZZY_MESSAGE_HANDLER = "Fuzzy requires a key or function to stringify items";
5
+ const FUZZY_PROPERTY = "$fuzzy";
6
+ const FUZZY_PROXIMITY_THRESHOLD = 5;
7
+ const FUZZY_SYMBOL = Symbol(FUZZY_PROPERTY);
8
+ //#endregion
9
+ export { FUZZY_LENGTH_DIVISOR, FUZZY_MESSAGE_ARRAY, FUZZY_MESSAGE_HANDLER, FUZZY_PROPERTY, FUZZY_PROXIMITY_THRESHOLD, FUZZY_SYMBOL };
@@ -0,0 +1,13 @@
1
+ //#region src/models/string/string.misc.model.d.ts
2
+ export type StringMatch = "endsWith" | "includes" | "startsWith";
3
+ export declare const STRING_DELIMITER_UUID_DEFAULT = "-";
4
+ export declare const STRING_DELIMITER_UUID_HTML = "_";
5
+ export declare const STRING_EXPRESSION_IGNORED: RegExp;
6
+ export declare const STRING_EXPRESSION_WORDS: RegExp;
7
+ export declare const STRING_EXPRESSION_WHITESPACE_PREFIX: RegExp;
8
+ export declare const STRING_MATCH_ENDS_WITH: StringMatch;
9
+ export declare const STRING_MATCH_INCLUDES: StringMatch;
10
+ export declare const STRING_MATCH_STARTS_WITH: StringMatch;
11
+ export declare const STRING_NEWLINE = "\n";
12
+ export declare const STRING_ZERO = "0";
13
+ //#endregion