@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,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 };
@@ -0,0 +1,76 @@
1
+ import { Constructor } from "../index.mjs";
2
+ //#region src/models/value/value.equal.model.d.ts
3
+ /**
4
+ * Options for value equality comparison
5
+ */
6
+ export type EqualOptions = {
7
+ /**
8
+ * When `true`, strings are compared case-insensitively
9
+ */
10
+ ignoreCase?: boolean;
11
+ /**
12
+ * Keys _(or key expressions)_ to ignore when comparing objects
13
+ */
14
+ ignoreKeys?: string | RegExp | Array<string | RegExp>;
15
+ /**
16
+ * Should `null` and `undefined` be considered equal?
17
+ */
18
+ relaxedNullish?: boolean;
19
+ };
20
+ /**
21
+ * An equalizer function for comparing values for equality, with predefined options
22
+ *
23
+ * Can be used to compare values, and register or deregister equality comparison handlers for specific classes
24
+ */
25
+ export type Equalizer = {
26
+ /**
27
+ * Are two strings equal?
28
+ *
29
+ * @param first First string
30
+ * @param second Second string
31
+ * @param ignoreCase If `true`, comparison will be case-insensitive
32
+ * @returns `true` if the strings are equal, otherwise `false`
33
+ */
34
+ compare(first: string, second: string, ignoreCase?: boolean): boolean;
35
+ /**
36
+ * Are two values equal?
37
+ *
38
+ * @param first First value
39
+ * @param second Second value
40
+ * @returns `true` if the values are equal, otherwise `false`
41
+ */
42
+ compare(first: unknown, second: unknown): boolean;
43
+ /**
44
+ * Deregister a equality comparison handler for a specific class
45
+ *
46
+ * @param constructor Class constructor
47
+ */
48
+ deregister: <Instance>(constructor: Constructor<Instance>) => void;
49
+ /**
50
+ * Register a equality comparison function for a specific class
51
+ *
52
+ * @param constructor Class constructor
53
+ * @param handler Comparison function
54
+ */
55
+ register: <Instance>(constructor: Constructor<Instance>, handler: (first: Instance, second: Instance) => boolean) => void;
56
+ };
57
+ export type InternalEqualizer = {
58
+ [EQUAL_SYMBOL]: EqualizerOptions;
59
+ } & Equalizer;
60
+ export type EqualizerOptions = {
61
+ ignoreCase: boolean;
62
+ ignoreExpressions: EqualizerOptionsKeys<RegExp[]>;
63
+ ignoreKeys: EqualizerOptionsKeys<Set<string>>;
64
+ relaxedNullish: boolean;
65
+ };
66
+ type EqualizerOptionsKeys<Values> = {
67
+ enabled: boolean;
68
+ values: Values;
69
+ };
70
+ export declare const EQUAL_ARRAY_PEEK_PERCENTAGE = 10;
71
+ export declare const EQUAL_ARRAY_THRESHOLD = 100;
72
+ export declare const EQUAL_ERROR_PROPERTIES: string[];
73
+ export declare const EQUAL_EXPRESSION_PROPERTIES: string[];
74
+ export declare const EQUAL_MINIMUM_LENGTH_FOR_SET = 16;
75
+ export declare const EQUAL_SYMBOL: unique symbol;
76
+ //#endregion
@@ -0,0 +1,9 @@
1
+ //#region src/models/value/value.equal.model.ts
2
+ const EQUAL_ARRAY_PEEK_PERCENTAGE = 10;
3
+ const EQUAL_ARRAY_THRESHOLD = 100;
4
+ const EQUAL_ERROR_PROPERTIES = ["name", "message"];
5
+ const EQUAL_EXPRESSION_PROPERTIES = ["source", "flags"];
6
+ const EQUAL_MINIMUM_LENGTH_FOR_SET = 16;
7
+ const EQUAL_SYMBOL = Symbol("equal");
8
+ //#endregion
9
+ export { EQUAL_ARRAY_PEEK_PERCENTAGE, EQUAL_ARRAY_THRESHOLD, EQUAL_ERROR_PROPERTIES, EQUAL_EXPRESSION_PROPERTIES, EQUAL_MINIMUM_LENGTH_FOR_SET, EQUAL_SYMBOL };
@@ -0,0 +1,27 @@
1
+ import { Constructor, GenericCallback } from "../index.mjs";
2
+ //#region src/models/value/value.handler.model.d.ts
3
+ export type BaseHandler = {
4
+ handlers: WeakMap<WeakKey, string | GenericCallback>;
5
+ options: BaseHandlerOptions;
6
+ owner: GenericCallback;
7
+ deregister(constructor: Constructor): void;
8
+ get(first: unknown, second: unknown): string | GenericCallback | undefined;
9
+ register(constructor: Constructor, handler?: string | GenericCallback): void;
10
+ };
11
+ export type BaseHandlerOptions = {
12
+ callback: GenericCallback;
13
+ method?: string;
14
+ };
15
+ export type CompareHandler<Value> = {
16
+ base: BaseHandler;
17
+ handle(first: unknown, second: unknown, ...parameters: unknown[]): Value;
18
+ };
19
+ export type Constructable = {
20
+ constructor: Constructor;
21
+ };
22
+ export type Handleable = Record<string, GenericCallback>;
23
+ export type ValueHandler = {
24
+ base: BaseHandler;
25
+ handle(value: unknown, ...parameters: unknown[]): unknown;
26
+ };
27
+ //#endregion
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,82 @@
1
+ import { ArrayOrPlainObject, NestedPartial, PlainObject, UnionToIntersection } from "../index.mjs";
2
+ //#region src/models/value/value.merge.model.d.ts
3
+ /**
4
+ * Options for assigning values
5
+ */
6
+ export type AssignOptions = BaseOptions;
7
+ type BaseOptions = {
8
+ /**
9
+ * Key _(or key epxressions)_ for values that should be replaced
10
+ *
11
+ * ```ts
12
+ * merge([{items: [1, 2, 3]}, {items: [99]}]); // => {items: [99]}
13
+ * ```
14
+ */
15
+ replaceableObjects?: string | RegExp | Array<string | RegExp>;
16
+ /**
17
+ * Skip nullable values when merging objects?
18
+ *
19
+ * ```ts
20
+ * merge({a: 1, b: 2}, {b: null, c: 3}, {d: null}); // => {a: 1, b: 2, c: 3}
21
+ * ```
22
+ */
23
+ skipNullableAny?: boolean;
24
+ /**
25
+ * Skip nullable values when merging arrays?
26
+ *
27
+ * ```ts
28
+ * merge([1, 2, 3], [null, null, 99]); // => [1, 2, 99]
29
+ * ```
30
+ */
31
+ skipNullableInArrays?: boolean;
32
+ };
33
+ /**
34
+ * An assigner function for assigning values from one or more objects to the first one
35
+ */
36
+ export type Assigner = {
37
+ /**
38
+ * Assign values from one or more objects to the first one
39
+ *
40
+ * @param to Value to assign to
41
+ * @param from Values to assign
42
+ * @returns Assigned value
43
+ */
44
+ assign<To extends PlainObject, From extends PlainObject[]>(to: To, from: [...From]): To & UnionToIntersection<From[number]>;
45
+ };
46
+ export type InternalAssigner = {
47
+ [MERGE_SYMBOL_ASSIGN]: MergingOptions;
48
+ } & Assigner;
49
+ export type InternalMerger = {
50
+ [MERGE_SYMBOL_MERGE]: MergingOptions;
51
+ } & Merger;
52
+ /**
53
+ * Options for merging values
54
+ */
55
+ export type MergeOptions = {
56
+ /**
57
+ * Assign values to the first array or object instead of creating a new one?
58
+ */
59
+ assignValues?: boolean;
60
+ };
61
+ /**
62
+ * A merger function for merging multiple arrays or objects into a single one
63
+ */
64
+ export type Merger = {
65
+ /**
66
+ * Merge multiple arrays or objects into a single one
67
+ *
68
+ * @param values Values to merge
69
+ * @returns Merged value
70
+ */
71
+ merge<Values extends ArrayOrPlainObject[]>(values: Array<NestedPartial<Values[number]>>): UnionToIntersection<Values[number]>;
72
+ };
73
+ export type MergeReplaceableObjectsCallback = (name: string) => boolean;
74
+ export type MergingOptions = {
75
+ assignValues: boolean;
76
+ replaceableObjects: MergeReplaceableObjectsCallback | undefined;
77
+ skipNullableAny: boolean;
78
+ skipNullableInArrays: boolean;
79
+ };
80
+ export declare const MERGE_SYMBOL_ASSIGN: unique symbol;
81
+ export declare const MERGE_SYMBOL_MERGE: unique symbol;
82
+ //#endregion