@oscarpalmer/atoms 0.212.0 → 0.214.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (258) 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/instance.mjs +0 -1
  45. package/dist/color/misc/alpha.d.mts +1 -1
  46. package/dist/color/misc/format.d.mts +1 -1
  47. package/dist/color/misc/get.d.mts +1 -1
  48. package/dist/color/misc/is.d.mts +2 -2
  49. package/dist/color/misc/is.mjs +1 -0
  50. package/dist/color/misc/state.d.mts +1 -1
  51. package/dist/color/space/hex.d.mts +1 -1
  52. package/dist/color/space/hsl.d.mts +1 -1
  53. package/dist/color/space/hwb.d.mts +1 -1
  54. package/dist/color/space/rgb.d.mts +1 -1
  55. package/dist/function/limit.d.mts +2 -2
  56. package/dist/function/limit.mjs +2 -1
  57. package/dist/function/once.d.mts +7 -3
  58. package/dist/function/once.mjs +5 -10
  59. package/dist/function/retry.d.mts +4 -14
  60. package/dist/function/retry.mjs +3 -15
  61. package/dist/herald.d.mts +2 -2
  62. package/dist/index.d.mts +466 -351
  63. package/dist/index.mjs +491 -439
  64. package/dist/internal/aborter.d.mts +1 -6
  65. package/dist/internal/aborter.mjs +3 -4
  66. package/dist/internal/array/callbacks.d.mts +3 -7
  67. package/dist/internal/array/chunk.mjs +2 -2
  68. package/dist/internal/array/find.d.mts +5 -23
  69. package/dist/internal/array/find.mjs +5 -9
  70. package/dist/internal/array/get.d.mts +1 -1
  71. package/dist/internal/array/group.d.mts +1 -1
  72. package/dist/internal/array/index-of.d.mts +1 -1
  73. package/dist/internal/array/index-of.mjs +4 -3
  74. package/dist/internal/array/insert.d.mts +2 -5
  75. package/dist/internal/array/insert.mjs +2 -4
  76. package/dist/internal/array/match.d.mts +2 -5
  77. package/dist/internal/array/match.mjs +10 -20
  78. package/dist/internal/array/overlap.d.mts +2 -10
  79. package/dist/internal/array/sets.d.mts +2 -5
  80. package/dist/internal/array/sets.mjs +5 -7
  81. package/dist/internal/function/assert.d.mts +5 -12
  82. package/dist/internal/function/assert.mjs +2 -2
  83. package/dist/internal/function/limit.d.mts +2 -37
  84. package/dist/internal/function/limit.mjs +4 -15
  85. package/dist/internal/function/memoize.d.mts +5 -70
  86. package/dist/internal/function/memoize.mjs +2 -5
  87. package/dist/internal/function/work.d.mts +16 -22
  88. package/dist/internal/function/work.mjs +1 -8
  89. package/dist/internal/herald.d.mts +3 -3
  90. package/dist/internal/herald.mjs +2 -1
  91. package/dist/internal/is.d.mts +1 -1
  92. package/dist/internal/math/aggregate.d.mts +2 -14
  93. package/dist/internal/math/aggregate.mjs +2 -5
  94. package/dist/internal/number.mjs +4 -7
  95. package/dist/internal/result/attempt.d.mts +1 -1
  96. package/dist/internal/result/misc.d.mts +1 -1
  97. package/dist/internal/string/case.mjs +6 -16
  98. package/dist/internal/string/misc.mjs +1 -3
  99. package/dist/internal/subscription.d.mts +1 -100
  100. package/dist/internal/subscription.mjs +3 -9
  101. package/dist/internal/value/compare.d.mts +4 -4
  102. package/dist/internal/value/compare.mjs +1 -1
  103. package/dist/internal/value/equal.d.mts +6 -57
  104. package/dist/internal/value/equal.mjs +5 -10
  105. package/dist/internal/value/get.d.mts +1 -1
  106. package/dist/internal/value/handlers.d.mts +2 -21
  107. package/dist/internal/value/has.d.mts +2 -2
  108. package/dist/internal/value/misc.d.mts +1 -1
  109. package/dist/internal/value/misc.mjs +8 -14
  110. package/dist/internal/value/set.d.mts +1 -1
  111. package/dist/internal/value/set.mjs +2 -2
  112. package/dist/is.mjs +3 -3
  113. package/dist/logger.d.mts +3 -70
  114. package/dist/logger.mjs +2 -5
  115. package/dist/math.d.mts +1 -1
  116. package/dist/math.mjs +2 -1
  117. package/dist/models/aborter.model.d.mts +12 -0
  118. package/dist/models/aborter.model.mjs +5 -0
  119. package/dist/models/array/array.find.model.d.mts +22 -0
  120. package/dist/models/array/array.find.model.mjs +8 -0
  121. package/dist/models/array/array.match.model.d.mts +14 -0
  122. package/dist/models/array/array.match.model.mjs +14 -0
  123. package/dist/models/array/array.misc.model.d.mts +36 -0
  124. package/dist/models/array/array.misc.model.mjs +12 -0
  125. package/dist/models/array/array.sort.model.d.mts +122 -0
  126. package/dist/models/array/array.sort.model.mjs +12 -0
  127. package/dist/models/beacon.model.d.mts +119 -0
  128. package/dist/models/beacon.model.mjs +16 -0
  129. package/dist/{color/models.d.mts → models/color.model.d.mts} +4 -4
  130. package/dist/models/function/assert.model.d.mts +13 -0
  131. package/dist/models/function/assert.model.mjs +4 -0
  132. package/dist/models/function/limiter.model.d.mts +71 -0
  133. package/dist/models/function/limiter.model.mjs +15 -0
  134. package/dist/models/function/memoize.model.d.mts +88 -0
  135. package/dist/models/function/memoize.model.mjs +7 -0
  136. package/dist/models/function/once.model.d.mts +76 -0
  137. package/dist/models/function/once.model.mjs +9 -0
  138. package/dist/models/function/retry.model.d.mts +17 -0
  139. package/dist/models/function/retry.model.mjs +17 -0
  140. package/dist/models/function/work.model.d.mts +20 -0
  141. package/dist/models/function/work.model.mjs +11 -0
  142. package/dist/{internal/models → models}/herald.model.d.mts +3 -3
  143. package/dist/{internal/models → models}/herald.model.mjs +2 -2
  144. package/dist/{models.d.mts → models/index.d.mts} +8 -50
  145. package/dist/models/logger.model.d.mts +83 -0
  146. package/dist/models/logger.model.mjs +7 -0
  147. package/dist/models/math.model.d.mts +16 -0
  148. package/dist/models/math.model.mjs +7 -0
  149. package/dist/models/misc.model.d.mts +10 -0
  150. package/dist/models/misc.model.mjs +11 -0
  151. package/dist/{internal/models → models}/plan.model.d.mts +17 -15
  152. package/dist/{internal/models → models}/plan.model.mjs +1 -1
  153. package/dist/models/promise.model.d.mts +119 -0
  154. package/dist/models/promise.model.mjs +47 -0
  155. package/dist/models/query.model.d.mts +9 -0
  156. package/dist/models/query.model.mjs +14 -0
  157. package/dist/models/queue.model.d.mts +251 -0
  158. package/dist/models/queue.model.mjs +29 -0
  159. package/dist/models/random.model.d.mts +6 -0
  160. package/dist/models/random.model.mjs +7 -0
  161. package/dist/{internal/models → models}/result.model.d.mts +10 -2
  162. package/dist/models/string/string.case.model.d.mts +19 -0
  163. package/dist/models/string/string.case.model.mjs +14 -0
  164. package/dist/models/string/string.fuzzy.model.d.mts +108 -0
  165. package/dist/models/string/string.fuzzy.model.mjs +9 -0
  166. package/dist/models/string/string.misc.model.d.mts +13 -0
  167. package/dist/models/string/string.misc.model.mjs +13 -0
  168. package/dist/models/string/string.normalize.model.d.mts +85 -0
  169. package/dist/models/string/string.normalize.model.mjs +43 -0
  170. package/dist/models/string/string.template.model.d.mts +50 -0
  171. package/dist/models/string/string.template.model.mjs +5 -0
  172. package/dist/models/subscription.model.d.mts +127 -0
  173. package/dist/models/subscription.model.mjs +10 -0
  174. package/dist/models/value/value.clone.model.d.mts +56 -0
  175. package/dist/models/value/value.clone.model.mjs +24 -0
  176. package/dist/models/value/value.diff.model.d.mts +61 -0
  177. package/dist/models/value/value.diff.model.mjs +6 -0
  178. package/dist/models/value/value.equal.model.d.mts +76 -0
  179. package/dist/models/value/value.equal.model.mjs +9 -0
  180. package/dist/models/value/value.handler.model.d.mts +27 -0
  181. package/dist/models/value/value.handler.model.mjs +1 -0
  182. package/dist/models/value/value.merge.model.d.mts +82 -0
  183. package/dist/models/value/value.merge.model.mjs +5 -0
  184. package/dist/models/value/value.misc.model.d.mts +33 -0
  185. package/dist/models/value/value.misc.model.mjs +12 -0
  186. package/dist/models/value/value.transform.model.d.mts +28 -0
  187. package/dist/models/value/value.transform.model.mjs +4 -0
  188. package/dist/plan/generate.d.mts +3 -2
  189. package/dist/plan/generate.mjs +14 -10
  190. package/dist/plan/index.d.mts +1 -1
  191. package/dist/plan/index.mjs +2 -2
  192. package/dist/plan/is.d.mts +31 -2
  193. package/dist/plan/is.mjs +45 -1
  194. package/dist/plan/misc.d.mts +21 -2
  195. package/dist/plan/misc.mjs +32 -2
  196. package/dist/plan/models.d.mts +1 -1
  197. package/dist/plan/result.d.mts +7 -7
  198. package/dist/plan/result.mjs +6 -6
  199. package/dist/plan/run.d.mts +5 -5
  200. package/dist/plan/run.mjs +6 -6
  201. package/dist/promise/delay.d.mts +1 -1
  202. package/dist/promise/delay.mjs +2 -1
  203. package/dist/promise/helpers.d.mts +2 -2
  204. package/dist/promise/helpers.mjs +6 -6
  205. package/dist/promise/index.d.mts +2 -2
  206. package/dist/promise/index.mjs +1 -1
  207. package/dist/promise/misc.d.mts +3 -3
  208. package/dist/promise/misc.mjs +7 -4
  209. package/dist/promise/models.d.mts +2 -106
  210. package/dist/promise/models.mjs +1 -35
  211. package/dist/promise/timed.d.mts +2 -2
  212. package/dist/promise/timed.mjs +3 -3
  213. package/dist/query.d.mts +1 -1
  214. package/dist/query.mjs +5 -15
  215. package/dist/queue.d.mts +6 -200
  216. package/dist/queue.mjs +9 -34
  217. package/dist/random.mjs +2 -5
  218. package/dist/result/match.d.mts +1 -1
  219. package/dist/result/match.mjs +27 -15
  220. package/dist/result/misc.d.mts +1 -1
  221. package/dist/result/work/flow.d.mts +13 -21
  222. package/dist/result/work/flow.mjs +0 -1
  223. package/dist/result/work/pipe.d.mts +2 -2
  224. package/dist/result/work/pipe.mjs +0 -1
  225. package/dist/string/fuzzy.d.mts +5 -87
  226. package/dist/string/fuzzy.mjs +6 -11
  227. package/dist/string/index.mjs +6 -8
  228. package/dist/string/match.mjs +4 -6
  229. package/dist/string/normalize.d.mts +4 -40
  230. package/dist/string/normalize.mjs +9 -48
  231. package/dist/string/template.d.mts +5 -43
  232. package/dist/string/template.mjs +1 -2
  233. package/dist/subscription.d.mts +2 -1
  234. package/dist/value/clone.d.mts +6 -42
  235. package/dist/value/clone.mjs +10 -30
  236. package/dist/value/collection.mjs +2 -0
  237. package/dist/value/diff.d.mts +3 -44
  238. package/dist/value/diff.mjs +1 -3
  239. package/dist/value/freeze.d.mts +1 -5
  240. package/dist/value/index.d.mts +4 -3
  241. package/dist/value/merge.d.mts +6 -64
  242. package/dist/value/merge.mjs +8 -8
  243. package/dist/value/omit.d.mts +1 -1
  244. package/dist/value/pick.d.mts +1 -1
  245. package/dist/value/shake.d.mts +4 -6
  246. package/dist/value/smush.d.mts +4 -6
  247. package/dist/value/smush.mjs +2 -2
  248. package/dist/value/transform.d.mts +6 -22
  249. package/dist/value/transform.mjs +1 -1
  250. package/dist/value/unsmush.d.mts +4 -10
  251. package/package.json +12 -3
  252. package/dist/internal/plan.d.mts +0 -45
  253. package/dist/internal/plan.mjs +0 -70
  254. package/dist/promise/constants.d.mts +0 -17
  255. package/dist/promise/constants.mjs +0 -15
  256. /package/dist/{color/models.mjs → models/color.model.mjs} +0 -0
  257. /package/dist/{internal/models/result.model.mjs → models/index.mjs} +0 -0
  258. /package/dist/{models.mjs → models/result.model.mjs} +0 -0
@@ -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
@@ -0,0 +1,13 @@
1
+ //#region src/models/string/string.misc.model.ts
2
+ const STRING_DELIMITER_UUID_DEFAULT = "-";
3
+ const STRING_DELIMITER_UUID_HTML = "_";
4
+ const STRING_EXPRESSION_IGNORED = /(^|\.)(__proto__|constructor|prototype)(\.|$)/i;
5
+ const STRING_EXPRESSION_WORDS = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
6
+ const STRING_EXPRESSION_WHITESPACE_PREFIX = /^(\s+)/;
7
+ const STRING_MATCH_ENDS_WITH = "endsWith";
8
+ const STRING_MATCH_INCLUDES = "includes";
9
+ const STRING_MATCH_STARTS_WITH = "startsWith";
10
+ const STRING_NEWLINE = "\n";
11
+ const STRING_ZERO = "0";
12
+ //#endregion
13
+ export { STRING_DELIMITER_UUID_DEFAULT, STRING_DELIMITER_UUID_HTML, STRING_EXPRESSION_IGNORED, STRING_EXPRESSION_WHITESPACE_PREFIX, STRING_EXPRESSION_WORDS, STRING_MATCH_ENDS_WITH, STRING_MATCH_INCLUDES, STRING_MATCH_STARTS_WITH, STRING_NEWLINE, STRING_ZERO };
@@ -0,0 +1,85 @@
1
+ //#region src/models/string/string.normalize.model.d.ts
2
+ export type InternalNormalizer = {
3
+ [NORMALIZE_SYMBOL]: Required<NormalizeOptions>;
4
+ } & Normalizer;
5
+ /**
6
+ * Options for normalizing a string
7
+ */
8
+ export type NormalizeOptions = {
9
+ /**
10
+ * Remove diacritical marks from the string? _(defaults to `true`)_
11
+ */
12
+ deburr?: boolean;
13
+ /**
14
+ * Convert the string to lower case? _(defaults to `true`)_
15
+ */
16
+ lowerCase?: boolean;
17
+ /**
18
+ * Remove special characters from the string? _(defaults to `false`)_
19
+ *
20
+ * _(Punctuation and symbol characters are considered special)_
21
+ */
22
+ special?: boolean;
23
+ /**
24
+ * Trim the string? _(defaults to `true`)_
25
+ */
26
+ trim?: boolean;
27
+ /**
28
+ * Shorten consecutive whitespace characters to a single space? _(defaults to `true`)_
29
+ */
30
+ whitespace?: boolean;
31
+ };
32
+ /**
33
+ * String normalizer function
34
+ */
35
+ export type Normalizer = {
36
+ /**
37
+ * Normalize a string
38
+ *
39
+ * @param value String to normalize
40
+ * @returns Normalized string
41
+ */
42
+ normalize(value: string): string;
43
+ };
44
+ export type NormalizerOptions = Required<NormalizeOptions>;
45
+ export declare const NORMALIZE_DEBURR_CHARACTERS: {
46
+ Æ: string;
47
+ æ: string;
48
+ Ð: string;
49
+ ð: string;
50
+ Đ: string;
51
+ đ: string;
52
+ Ħ: string;
53
+ ħ: string;
54
+ IJ: string;
55
+ ij: string;
56
+ İ: string;
57
+ ı: string;
58
+ ĸ: string;
59
+ Ŀ: string;
60
+ ŀ: string;
61
+ Ł: string;
62
+ ł: string;
63
+ Ŋ: string;
64
+ ŋ: string;
65
+ ʼn: string;
66
+ Œ: string;
67
+ œ: string;
68
+ Ø: string;
69
+ ø: string;
70
+ ſ: string;
71
+ ß: string;
72
+ Þ: string;
73
+ þ: string;
74
+ Ŧ: string;
75
+ ŧ: string;
76
+ };
77
+ export declare const NORMALIZE_DEBURR_NORMALIZATION = "NFD";
78
+ export declare const NORMALIZE_DEBURR_PATTERN_CHARACTERS: RegExp;
79
+ export declare const NORMALIZE_DEBURR_PATTERN_SIMPLE: RegExp;
80
+ export declare const NORMALIZE_NORMALIZATION_NORMALIZATION: string;
81
+ export declare const NORMALIZE_SPECIAL_PATTERN: RegExp;
82
+ export declare const NORMALIZE_SPECIAL_REPLACEMENT = "";
83
+ export declare const NORMALIZE_SYMBOL: unique symbol;
84
+ export declare const NORMALIZE_WHITESPACE_REPLACEMENT = " ";
85
+ //#endregion
@@ -0,0 +1,43 @@
1
+ //#region src/models/string/string.normalize.model.ts
2
+ const NORMALIZE_DEBURR_CHARACTERS = {
3
+ Æ: "AE",
4
+ æ: "ae",
5
+ Ð: "D",
6
+ ð: "d",
7
+ Đ: "D",
8
+ đ: "d",
9
+ Ħ: "H",
10
+ ħ: "h",
11
+ IJ: "IJ",
12
+ ij: "ij",
13
+ İ: "I",
14
+ ı: "i",
15
+ ĸ: "k",
16
+ Ŀ: "L",
17
+ ŀ: "l",
18
+ Ł: "L",
19
+ ł: "l",
20
+ Ŋ: "N",
21
+ ŋ: "n",
22
+ ʼn: "'n",
23
+ Œ: "OE",
24
+ œ: "oe",
25
+ Ø: "O",
26
+ ø: "o",
27
+ ſ: "s",
28
+ ß: "ss",
29
+ Þ: "TH",
30
+ þ: "th",
31
+ Ŧ: "T",
32
+ ŧ: "t"
33
+ };
34
+ const NORMALIZE_DEBURR_NORMALIZATION = "NFD";
35
+ const NORMALIZE_DEBURR_PATTERN_CHARACTERS = new RegExp(`(${Object.keys(NORMALIZE_DEBURR_CHARACTERS).join("|")})`, "g");
36
+ const NORMALIZE_DEBURR_PATTERN_SIMPLE = /[\u0300-\u036f]/g;
37
+ const NORMALIZE_NORMALIZATION_NORMALIZATION = "NFC";
38
+ const NORMALIZE_SPECIAL_PATTERN = /[\p{P}\p{S}]/gu;
39
+ const NORMALIZE_SPECIAL_REPLACEMENT = "";
40
+ const NORMALIZE_SYMBOL = Symbol("normalize");
41
+ const NORMALIZE_WHITESPACE_REPLACEMENT = " ";
42
+ //#endregion
43
+ export { NORMALIZE_DEBURR_CHARACTERS, NORMALIZE_DEBURR_NORMALIZATION, NORMALIZE_DEBURR_PATTERN_CHARACTERS, NORMALIZE_DEBURR_PATTERN_SIMPLE, NORMALIZE_NORMALIZATION_NORMALIZATION, NORMALIZE_SPECIAL_PATTERN, NORMALIZE_SPECIAL_REPLACEMENT, NORMALIZE_SYMBOL, NORMALIZE_WHITESPACE_REPLACEMENT };
@@ -0,0 +1,50 @@
1
+ import { PlainObject } from "../index.mjs";
2
+ //#region src/models/string/string.template.model.d.ts
3
+ export type InternalTemplater = {
4
+ [TEMPLATE_SYMBOL]: Required<TemplateOptions>;
5
+ } & Templater;
6
+ /**
7
+ * Renderer for a string template with variables
8
+ *
9
+ * @param variables Variables to use
10
+ * @param options Templating options
11
+ * @returns Templated string
12
+ */
13
+ export type Renderer = (variables?: PlainObject, options?: Partial<TemplateOptions>) => string;
14
+ /**
15
+ * Options for templating strings
16
+ */
17
+ export type TemplateOptions = {
18
+ /**
19
+ * Ignore case when searching for variables?
20
+ */
21
+ ignoreCase?: boolean;
22
+ /**
23
+ * Custom pattern for outputting variables
24
+ */
25
+ pattern?: RegExp;
26
+ };
27
+ export type Templater = {
28
+ /**
29
+ * Render a string from a template with variables
30
+ *
31
+ * @returns Templated string
32
+ */
33
+ render(strings: TemplateStringsArray, ...values: unknown[]): TemplaterRenderer;
34
+ /**
35
+ * Render a string from a template with variables
36
+ *
37
+ * @param value Template string
38
+ * @param variables Variables to use
39
+ * @returns Templated string
40
+ */
41
+ render(value: string, variables?: PlainObject): string;
42
+ };
43
+ export type TemplaterOptions = Required<TemplateOptions>;
44
+ /**
45
+ * Render a template string with variables
46
+ */
47
+ export type TemplaterRenderer = (variables?: PlainObject) => string;
48
+ export declare const TEMPLATE_EXPRESSION_VARIABLE: RegExp;
49
+ export declare const TEMPLATE_SYMBOL: unique symbol;
50
+ //#endregion
@@ -0,0 +1,5 @@
1
+ //#region src/models/string/string.template.model.ts
2
+ const TEMPLATE_EXPRESSION_VARIABLE = /{{([\s\S]+?)}}/g;
3
+ const TEMPLATE_SYMBOL = Symbol("template");
4
+ //#endregion
5
+ export { TEMPLATE_EXPRESSION_VARIABLE, TEMPLATE_SYMBOL };
@@ -0,0 +1,127 @@
1
+ import { Key } from "./index.mjs";
2
+ import { Aborter } from "./aborter.model.mjs";
3
+ //#region src/models/subscription.model.d.ts
4
+ export type InternalSubscription = {
5
+ [SUBSCRIPTION_SYMBOL]: SubscriptionState;
6
+ } & Subscription;
7
+ export type InternalSubscriptions = {
8
+ [SUBSCRIPTION_SYMBOL]: SubscriptionsState;
9
+ } & Subscriptions;
10
+ export type Subscription = {
11
+ /**
12
+ * Is the subscription active?
13
+ */
14
+ get active(): boolean;
15
+ /**
16
+ * Unsubscribe from changes
17
+ */
18
+ unsubscribe(): void;
19
+ };
20
+ /**
21
+ * Parameters for creating a subscription
22
+ */
23
+ export type SubscriptionParameters = {
24
+ /**
25
+ * Is the owner of the subscription alive? _(defaults to `true`)_
26
+ */
27
+ isActive?: () => boolean;
28
+ /**
29
+ * Key used to identify a subscription _(defaults to `undefined`)_
30
+ */
31
+ key?: unknown;
32
+ /**
33
+ * Signal used to abort the subscription _(defaults to `undefined`)_
34
+ */
35
+ signal?: AbortSignal;
36
+ /**
37
+ * Value used to identify a subscription
38
+ */
39
+ value: unknown;
40
+ };
41
+ /**
42
+ * Property information for subscription identification
43
+ */
44
+ export type SubscriptionProperty = {
45
+ /**
46
+ * Name of the property used to identify a subscription
47
+ */
48
+ key: string;
49
+ /**
50
+ * Value of the property used to identify a subscription
51
+ */
52
+ value: unknown;
53
+ };
54
+ export type SubscriptionState = {
55
+ aborter?: Aborter;
56
+ active: boolean;
57
+ parameters: SubscriptionParameters;
58
+ subscriptions: SubscriptionsState;
59
+ };
60
+ export type Subscriptions<Value = unknown> = {
61
+ /**
62
+ * Items of the subscriptions store
63
+ *
64
+ * - `any` - Set of subscriptions _(for unkeyed subscriptions)_
65
+ * - `keyed` - Map of keys to sets of subscriptions _(for keyed subscriptions)_
66
+ */
67
+ readonly items: Readonly<SubscriptionsItems>;
68
+ /**
69
+ * Values of the subscriptions store
70
+ *
71
+ * - `from.any` - Map of values to subscriptions _(for unkeyed subscriptions)_
72
+ * - `from.keyed` - Map of keys to maps of values to subscriptions _(for keyed subscriptions)_
73
+ * - `to.any` - Map of subscriptions to values _(for unkeyed subscriptions)_
74
+ * - `to.keyed` - Map of keys to maps of subscriptions to values _(for keyed subscriptions)_
75
+ */
76
+ readonly values: Readonly<SubscriptionsValues<Value>>;
77
+ /**
78
+ * Clear all subscriptions
79
+ */
80
+ clear(): void;
81
+ /**
82
+ * Create _(or retrieve)_ a subscription
83
+ *
84
+ * @param parameters Subscription parameters
85
+ * @returns Tuple holding subsccription and existing boolean
86
+ */
87
+ create(parameters: SubscriptionParameters): [Subscription, boolean];
88
+ };
89
+ /**
90
+ * Parameters for creating a subscription store
91
+ */
92
+ export type SubscriptionsParameters = {
93
+ /**
94
+ * Allow any or specific keys for subscriptions? _(defaults to `false`, which prevents keyed subscriptions)_
95
+ */
96
+ keys?: boolean | Set<Key>;
97
+ /**
98
+ * Property information for subscription identification
99
+ */
100
+ property?: SubscriptionProperty;
101
+ };
102
+ export type SubscriptionsState = {
103
+ items: SubscriptionsItems;
104
+ keys: boolean | Set<Key>;
105
+ property: SubscriptionProperty;
106
+ values: SubscriptionsValues;
107
+ };
108
+ export type SubscriptionsItems = {
109
+ any: Set<Subscription>;
110
+ keyed?: Map<Key, Set<Subscription>>;
111
+ };
112
+ export type SubscriptionsValues<Value = unknown> = {
113
+ from: SubscriptionsValuesItem<Value, Subscription>;
114
+ to: SubscriptionsValuesItem<Subscription, Value>;
115
+ };
116
+ export type SubscriptionsValuesItem<MapKey, MapValue> = {
117
+ any: Map<MapKey, MapValue>;
118
+ keyed?: Map<Key, Map<MapKey, MapValue>>;
119
+ };
120
+ export declare const SUBSCRIPTION_DISALLOWED_KEY = "Disallowed key for subscription";
121
+ export declare const SUBSCRIPTION_INVALID_KEY = "Invalid key for subscription";
122
+ export declare const SUBSCRIPTION_INVALID_VALUE = "A subscription requires a non-null value to identify it";
123
+ export declare const SUBSCRIPTION_NAME = "subscription";
124
+ export declare const SUBSCRIPTION_PROPERTY = "$subscription";
125
+ export declare const SUBSCRIPTION_STORE = "subscriptions";
126
+ export declare const SUBSCRIPTION_SYMBOL: unique symbol;
127
+ //#endregion
@@ -0,0 +1,10 @@
1
+ //#region src/models/subscription.model.ts
2
+ const SUBSCRIPTION_DISALLOWED_KEY = "Disallowed key for subscription";
3
+ const SUBSCRIPTION_INVALID_KEY = "Invalid key for subscription";
4
+ const SUBSCRIPTION_INVALID_VALUE = "A subscription requires a non-null value to identify it";
5
+ const SUBSCRIPTION_NAME = "subscription";
6
+ const SUBSCRIPTION_PROPERTY = "$subscription";
7
+ const SUBSCRIPTION_STORE = "subscriptions";
8
+ const SUBSCRIPTION_SYMBOL = Symbol(SUBSCRIPTION_PROPERTY);
9
+ //#endregion
10
+ export { SUBSCRIPTION_DISALLOWED_KEY, SUBSCRIPTION_INVALID_KEY, SUBSCRIPTION_INVALID_VALUE, SUBSCRIPTION_NAME, SUBSCRIPTION_PROPERTY, SUBSCRIPTION_STORE, SUBSCRIPTION_SYMBOL };
@@ -0,0 +1,56 @@
1
+ import { Constructor } from "../index.mjs";
2
+ //#region src/models/value/value.clone.model.d.ts
3
+ export type CloneOptions = {
4
+ /**
5
+ * Copy functions instead of returning `undefined`? _(defaults to `false`)_
6
+ */
7
+ copyFunctions?: boolean;
8
+ /**
9
+ * Copy symbols instead of returning `Symbol(description)`? _(defaults to `false`)_
10
+ */
11
+ copySymbols?: boolean;
12
+ };
13
+ export type CloneParameters = {
14
+ copy: boolean;
15
+ options: Required<CloneOptions>;
16
+ references: WeakMap<WeakKey, unknown>;
17
+ };
18
+ /**
19
+ * A cloning function with predefined options
20
+ */
21
+ export type Cloner = {
22
+ /**
23
+ * Clone any kind of value
24
+ *
25
+ * @param value Value to clone
26
+ * @returns Cloned value
27
+ */
28
+ clone<Value>(value: Value): Value;
29
+ /**
30
+ * Deregister a clone handler for a specific class
31
+ *
32
+ * _Available as `deregisterCloner` and `template.deregister`_
33
+ *
34
+ * @param constructor Class constructor
35
+ */
36
+ deregister<Instance>(constructor: Constructor<Instance>): void;
37
+ /**
38
+ * Register a clone handler for a specific class
39
+ *
40
+ * _Available as `registerCloner` and `template.register`_
41
+ *
42
+ * @param constructor Class constructor
43
+ * @param handler Method name or clone function _(defaults to method name `clone`)_
44
+ */
45
+ register<Instance>(constructor: Constructor<Instance>, handler?: string | ((value: Instance) => Instance)): void;
46
+ };
47
+ export type InternalCloner = {
48
+ [CLONE_SYMBOL]: Required<CloneOptions>;
49
+ } & Cloner;
50
+ export declare const CLONE_NAME = "clone";
51
+ export declare const CLONE_COPY_OPTIONS: Required<CloneOptions>;
52
+ export declare const CLONE_DEFAULT_OPTIONS: Required<CloneOptions>;
53
+ export declare const CLONE_MAX_DEPTH = 100;
54
+ export declare const CLONE_PRIMITIVES: Record<string, boolean>;
55
+ export declare const CLONE_SYMBOL: unique symbol;
56
+ //#endregion
@@ -0,0 +1,24 @@
1
+ //#region src/models/value/value.clone.model.ts
2
+ const CLONE_NAME = "clone";
3
+ const CLONE_COPY_OPTIONS = {
4
+ copyFunctions: true,
5
+ copySymbols: true
6
+ };
7
+ const CLONE_DEFAULT_OPTIONS = {
8
+ copyFunctions: false,
9
+ copySymbols: false
10
+ };
11
+ const CLONE_MAX_DEPTH = 100;
12
+ const CLONE_PRIMITIVES = {
13
+ bigint: true,
14
+ boolean: true,
15
+ function: false,
16
+ number: true,
17
+ object: false,
18
+ string: true,
19
+ symbol: false,
20
+ undefined: true
21
+ };
22
+ const CLONE_SYMBOL = Symbol(CLONE_NAME);
23
+ //#endregion
24
+ export { CLONE_COPY_OPTIONS, CLONE_DEFAULT_OPTIONS, CLONE_MAX_DEPTH, CLONE_NAME, CLONE_PRIMITIVES, CLONE_SYMBOL };
@@ -0,0 +1,61 @@
1
+ //#region src/models/value/value.diff.model.d.ts
2
+ /**
3
+ * Options for value comparison
4
+ */
5
+ export type DiffOptions = {
6
+ /**
7
+ * Should `null` and `undefined` be considered equal and ignored in results?
8
+ */
9
+ relaxedNullish?: boolean;
10
+ };
11
+ /**
12
+ * The result of a comparison beteen two values
13
+ */
14
+ export type DiffResult<First, Second = First> = {
15
+ /**
16
+ * The original values that were compared
17
+ */
18
+ original: DiffValue<First, Second>;
19
+ /**
20
+ * The type of difference between the two values
21
+ */
22
+ type: DiffType;
23
+ /**
24
+ * The differences between the two values
25
+ *
26
+ * - Keys are in dot notation
27
+ * - Values are objects with `from` and `to` properties
28
+ */
29
+ values: Record<string, DiffValue>;
30
+ };
31
+ export type DiffType = "full" | "none" | "partial";
32
+ /**
33
+ * The difference between two values
34
+ */
35
+ export type DiffValue<First = unknown, Second = First> = {
36
+ /**
37
+ * The value from the first value
38
+ */
39
+ from: First;
40
+ /**
41
+ * The value from the second value
42
+ */
43
+ to: Second;
44
+ };
45
+ export type DiffKeyedValue = {
46
+ key: string;
47
+ } & DiffValue;
48
+ export type DiffParameters = {
49
+ changes: DiffKeyedValue[];
50
+ key: PropertyKey;
51
+ options: Required<DiffOptions>;
52
+ values: {
53
+ first: unknown;
54
+ second: unknown;
55
+ };
56
+ prefix?: string;
57
+ };
58
+ export declare const DIFF_FULL: DiffType;
59
+ export declare const DIFF_NONE: DiffType;
60
+ export declare const DIFF_PARTIAL: DiffType;
61
+ //#endregion
@@ -0,0 +1,6 @@
1
+ //#region src/models/value/value.diff.model.ts
2
+ const DIFF_FULL = "full";
3
+ const DIFF_NONE = "none";
4
+ const DIFF_PARTIAL = "partial";
5
+ //#endregion
6
+ export { DIFF_FULL, DIFF_NONE, DIFF_PARTIAL };