@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
@@ -1,46 +1,7 @@
1
- import { PlainObject } from "../models.mjs";
1
+ import { PlainObject } from "../models/index.mjs";
2
+ import { Renderer, TemplateOptions, Templater, TemplaterOptions, TemplaterRenderer } from "../models/string/string.template.model.mjs";
2
3
  //#region src/string/template.d.ts
3
- /**
4
- * Renderer for a string template with variables
5
- *
6
- * @param variables Variables to use
7
- * @param options Templating options
8
- * @returns Templated string
9
- */
10
- type Renderer = (variables?: PlainObject, options?: Partial<TemplateOptions>) => string;
11
- /**
12
- * Options for templating strings
13
- */
14
- export type TemplateOptions = {
15
- /**
16
- * Ignore case when searching for variables?
17
- */
18
- ignoreCase?: boolean;
19
- /**
20
- * Custom pattern for outputting variables
21
- */
22
- pattern?: RegExp;
23
- };
24
- type Templater = {
25
- /**
26
- * Render a string from a template with variables
27
- *
28
- * @returns Templated string
29
- */
30
- render(strings: TemplateStringsArray, ...values: unknown[]): TemplaterRenderer;
31
- /**
32
- * Render a string from a template with variables
33
- *
34
- * @param value Template string
35
- * @param variables Variables to use
36
- * @returns Templated string
37
- */
38
- render(value: string, variables?: PlainObject): string;
39
- };
40
- /**
41
- * Render a template string with variables
42
- */
43
- type TemplaterRenderer = (variables?: PlainObject) => string;
4
+ declare function Templater(this: any, options: TemplaterOptions): void;
44
5
  /**
45
6
  * Create a _Templater_ with predefined options
46
7
  *
@@ -68,4 +29,5 @@ export declare function template(value: string, variables?: PlainObject, options
68
29
  export declare namespace template {
69
30
  export var initialize: typeof initializeTemplater;
70
31
  }
71
- //#endregion
32
+ //#endregion
33
+ export type { Renderer, TemplateOptions, Templater, TemplaterOptions, TemplaterRenderer };
@@ -1,6 +1,7 @@
1
1
  import { isPlainObject, isTemplateStringsArray } from "../internal/is.mjs";
2
2
  import { getString, interpolate } from "../internal/string/misc.mjs";
3
3
  import { getValue } from "../internal/value/get.mjs";
4
+ import { TEMPLATE_EXPRESSION_VARIABLE, TEMPLATE_SYMBOL } from "../models/string/string.template.model.mjs";
4
5
  //#region src/string/template.ts
5
6
  function Templater(options) {
6
7
  this[TEMPLATE_SYMBOL] = options;
@@ -51,8 +52,6 @@ function template(value, ...parameters) {
51
52
  const { ignoreCase, pattern } = createTemplateOptions(parameters[1]);
52
53
  return handleTemplate(value, pattern, ignoreCase, parameters[0]);
53
54
  }
54
- const TEMPLATE_EXPRESSION_VARIABLE = /{{([\s\S]+?)}}/g;
55
- const TEMPLATE_SYMBOL = Symbol("template");
56
55
  template.initialize = initializeTemplater;
57
56
  //#endregion
58
57
  export { initializeTemplater, template };
@@ -1,2 +1,3 @@
1
- import { Subscription, SubscriptionParameters, SubscriptionProperty, Subscriptions, SubscriptionsParameters, isSubscription, isSubscriptions, subscriptions } from "./internal/subscription.mjs";
1
+ import { Subscription, SubscriptionParameters, SubscriptionProperty, Subscriptions, SubscriptionsParameters } from "./models/subscription.model.mjs";
2
+ import { isSubscription, isSubscriptions, subscriptions } from "./internal/subscription.mjs";
2
3
  export { type Subscription, type SubscriptionParameters, type SubscriptionProperty, type Subscriptions, type SubscriptionsParameters, isSubscription, isSubscriptions, subscriptions };
@@ -1,45 +1,8 @@
1
- import { Constructor } from "../models.mjs";
2
- import { ValueHandler } from "../internal/value/handlers.mjs";
1
+ import { Constructor } from "../models/index.mjs";
2
+ import { ValueHandler } from "../models/value/value.handler.model.mjs";
3
+ import { CloneOptions, Cloner } from "../models/value/value.clone.model.mjs";
3
4
  //#region src/value/clone.d.ts
4
- export type CloneOptions = {
5
- /**
6
- * Copy functions instead of returning `undefined`? _(defaults to `false`)_
7
- */
8
- copyFunctions?: boolean;
9
- /**
10
- * Copy symbols instead of returning `Symbol(description)`? _(defaults to `false`)_
11
- */
12
- copySymbols?: boolean;
13
- };
14
- /**
15
- * A cloning function with predefined options
16
- */
17
- export type Cloner = {
18
- /**
19
- * Clone any kind of value
20
- *
21
- * @param value Value to clone
22
- * @returns Cloned value
23
- */
24
- clone<Value>(value: Value): Value;
25
- /**
26
- * Deregister a clone handler for a specific class
27
- *
28
- * _Available as `deregisterCloner` and `template.deregister`_
29
- *
30
- * @param constructor Class constructor
31
- */
32
- deregister: typeof deregisterCloner;
33
- /**
34
- * Register a clone handler for a specific class
35
- *
36
- * _Available as `registerCloner` and `template.register`_
37
- *
38
- * @param constructor Class constructor
39
- * @param handler Method name or clone function _(defaults to method name `clone`)_
40
- */
41
- register: typeof registerCloner;
42
- };
5
+ declare function Cloner(this: any, options: Required<CloneOptions>): void;
43
6
  /**
44
7
  * Clone any kind of value _(deeply, if needed)_
45
8
  *
@@ -90,4 +53,5 @@ export declare namespace clone {
90
53
  export var initialize: typeof initializeCloner;
91
54
  export var register: typeof registerCloner;
92
55
  }
93
- //#endregion
56
+ //#endregion
57
+ export type { CloneOptions, Cloner };
@@ -2,8 +2,8 @@ import { isArrayOrPlainObject, isTypedArray } from "../internal/is.mjs";
2
2
  import { unwrap } from "../internal/result/misc.mjs";
3
3
  import { attempt } from "../internal/result/attempt.mjs";
4
4
  import { createValueHandler } from "../internal/value/handlers.mjs";
5
+ import { CLONE_COPY_OPTIONS, CLONE_DEFAULT_OPTIONS, CLONE_NAME, CLONE_PRIMITIVES, CLONE_SYMBOL } from "../models/value/value.clone.model.mjs";
5
6
  //#region src/value/clone.ts
6
- const CLONE_NAME = "clone";
7
7
  function Cloner(options) {
8
8
  this[CLONE_SYMBOL] = options;
9
9
  }
@@ -40,14 +40,14 @@ function cloneAny(value, parameters, depth, options) {
40
40
  }
41
41
  }
42
42
  function cloneArrayBuffer(value, parameters, depth) {
43
- if (parameters.copy || depth >= CLONE_MAX_DEPTH) return value;
43
+ if (parameters.copy || depth >= 100) return value;
44
44
  const cloned = new ArrayBuffer(value.byteLength);
45
45
  new Uint8Array(cloned).set(new Uint8Array(value));
46
46
  parameters.references.set(value, cloned);
47
47
  return cloned;
48
48
  }
49
49
  function cloneDataView(value, parameters, depth) {
50
- if (parameters.copy || depth >= CLONE_MAX_DEPTH) return value;
50
+ if (parameters.copy || depth >= 100) return value;
51
51
  const buffer = cloneArrayBuffer(value.buffer, parameters, depth);
52
52
  const cloned = new DataView(buffer, value.byteOffset, value.byteLength);
53
53
  parameters.references.set(value, cloned);
@@ -60,7 +60,7 @@ function cloneFromCloner(value) {
60
60
  }, 0);
61
61
  }
62
62
  function cloneMap(map, parameters, depth) {
63
- if (depth >= CLONE_MAX_DEPTH) return map;
63
+ if (depth >= 100) return map;
64
64
  if (parameters.copy) return new Map(map);
65
65
  const cloned = /* @__PURE__ */ new Map();
66
66
  for (const [key, value] of map.entries()) cloned.set(cloneAny(key, parameters, depth + 1), cloneAny(value, parameters, depth + 1));
@@ -68,13 +68,13 @@ function cloneMap(map, parameters, depth) {
68
68
  return cloned;
69
69
  }
70
70
  function cloneNode(node, parameters, depth) {
71
- if (parameters.copy || depth >= CLONE_MAX_DEPTH) return node;
71
+ if (parameters.copy || depth >= 100) return node;
72
72
  const cloned = node.cloneNode(true);
73
73
  parameters.references.set(node, cloned);
74
74
  return cloned;
75
75
  }
76
76
  function cloneObject(value, parameters, depth) {
77
- if (depth >= CLONE_MAX_DEPTH) return value;
77
+ if (depth >= 100) return value;
78
78
  const isArray = Array.isArray(value);
79
79
  if (parameters.copy) return isArray ? value.slice() : { ...value };
80
80
  const cloned = isArray ? [] : {};
@@ -88,14 +88,14 @@ function cloneObject(value, parameters, depth) {
88
88
  return cloned;
89
89
  }
90
90
  function cloneRegularExpression(value, parameters, depth) {
91
- if (parameters.copy || depth >= CLONE_MAX_DEPTH) return value;
91
+ if (parameters.copy || depth >= 100) return value;
92
92
  const cloned = new RegExp(value.source, value.flags);
93
93
  cloned.lastIndex = value.lastIndex;
94
94
  parameters.references.set(value, cloned);
95
95
  return cloned;
96
96
  }
97
97
  function cloneSet(set, parameters, depth) {
98
- if (depth >= CLONE_MAX_DEPTH) return set;
98
+ if (depth >= 100) return set;
99
99
  if (parameters.copy) return new Set(set);
100
100
  const cloned = /* @__PURE__ */ new Set();
101
101
  for (const value of set.values()) cloned.add(cloneAny(value, parameters, depth + 1));
@@ -103,7 +103,7 @@ function cloneSet(set, parameters, depth) {
103
103
  return cloned;
104
104
  }
105
105
  function cloneTypedArray(value, parameters, depth) {
106
- if (parameters.copy || depth >= CLONE_MAX_DEPTH) return value;
106
+ if (parameters.copy || depth >= 100) return value;
107
107
  const cloned = new value.constructor(value);
108
108
  parameters.references.set(value, cloned);
109
109
  return cloned;
@@ -155,35 +155,15 @@ function registerCloner(constructor, handler) {
155
155
  cloneHandler.base.register(constructor, handler);
156
156
  }
157
157
  function tryStructuredClone(value, parameters, depth) {
158
- if (depth >= CLONE_MAX_DEPTH) return value;
158
+ if (depth >= 100) return value;
159
159
  const cloned = unwrap(attempt(() => structuredClone(value)), value);
160
160
  parameters.references.set(value, cloned);
161
161
  return cloned;
162
162
  }
163
- const CLONE_COPY_OPTIONS = {
164
- copyFunctions: true,
165
- copySymbols: true
166
- };
167
- const CLONE_DEFAULT_OPTIONS = {
168
- copyFunctions: false,
169
- copySymbols: false
170
- };
171
- const CLONE_MAX_DEPTH = 100;
172
163
  const cloneHandler = createValueHandler(clone, {
173
164
  callback: tryStructuredClone,
174
165
  method: CLONE_NAME
175
166
  });
176
- const CLONE_PRIMITIVES = {
177
- bigint: true,
178
- boolean: true,
179
- function: false,
180
- number: true,
181
- object: false,
182
- string: true,
183
- symbol: false,
184
- undefined: true
185
- };
186
- const CLONE_SYMBOL = Symbol(CLONE_NAME);
187
167
  clone.deregister = deregisterCloner;
188
168
  clone.handlers = cloneHandler;
189
169
  clone.initialize = initializeCloner;
@@ -1,3 +1,4 @@
1
+ import { isPrimitive } from "../internal/is.mjs";
1
2
  import { equal } from "../internal/value/equal.mjs";
2
3
  //#region src/value/collection.ts
3
4
  function inMap(map, value, key) {
@@ -18,6 +19,7 @@ function inMap(map, value, key) {
18
19
  function inSet(set, value) {
19
20
  if (!(set instanceof Set)) return false;
20
21
  if (set.has(value)) return true;
22
+ if (isPrimitive(value)) return false;
21
23
  for (const item of set) if (equal(item, value)) return true;
22
24
  return false;
23
25
  }
@@ -1,47 +1,5 @@
1
+ import { DiffOptions, DiffResult } from "../models/value/value.diff.model.mjs";
1
2
  //#region src/value/diff.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
- 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
3
  /**
46
4
  * Find the differences between two values
47
5
  *
@@ -51,4 +9,5 @@ export type DiffValue<First = unknown, Second = First> = {
51
9
  * @returns Difference result
52
10
  */
53
11
  export declare function diff<First, Second = First>(first: First, second: Second, options?: DiffOptions): DiffResult<First, Second>;
54
- //#endregion
12
+ //#endregion
13
+ export type { DiffOptions, DiffResult };
@@ -2,6 +2,7 @@ import { isArrayOrPlainObject } from "../internal/is.mjs";
2
2
  import { max, min } from "../internal/math/aggregate.mjs";
3
3
  import { join } from "../internal/string/misc.mjs";
4
4
  import { equal } from "../internal/value/equal.mjs";
5
+ import { DIFF_FULL, DIFF_NONE, DIFF_PARTIAL } from "../models/value/value.diff.model.mjs";
5
6
  //#region src/value/diff.ts
6
7
  /**
7
8
  * Find the differences between two values
@@ -101,8 +102,5 @@ function setChanges(parameters) {
101
102
  const diffsLength = diffs.length;
102
103
  for (let diffIndex = 0; diffIndex < diffsLength; diffIndex += 1) changes.push(diffs[diffIndex]);
103
104
  }
104
- const DIFF_FULL = "full";
105
- const DIFF_NONE = "none";
106
- const DIFF_PARTIAL = "partial";
107
105
  //#endregion
108
106
  export { diff };
@@ -1,9 +1,5 @@
1
- import { PlainObject } from "../models.mjs";
1
+ import { Frozen, PlainObject } from "../models/index.mjs";
2
2
  //#region src/value/freeze.d.ts
3
- /**
4
- * A frozen value with readonly properties _(going as deep as possible)_
5
- */
6
- export type Frozen<Value> = Value extends unknown[] ? Readonly<Value> : Value extends PlainObject ? { readonly [Key in keyof Value]: Frozen<Value[Key]>; } : Value extends Map<infer Key, infer Value> ? ReadonlyMap<Key, Frozen<Value>> : Value extends Set<infer Item> ? ReadonlySet<Frozen<Item>> : Readonly<Value>;
7
3
  /**
8
4
  * Freeze an array and its indiced values, but not any nested values
9
5
  *
@@ -1,6 +1,7 @@
1
+ import { Shaken, Smushed, Unsmushed } from "../models/value/value.misc.model.mjs";
1
2
  import { omit } from "./omit.mjs";
2
3
  import { pick } from "./pick.mjs";
3
- import { Shaken, shake } from "./shake.mjs";
4
- import { Smushed, smush } from "./smush.mjs";
5
- import { Unsmushed, unsmush } from "./unsmush.mjs";
4
+ import { shake } from "./shake.mjs";
5
+ import { smush } from "./smush.mjs";
6
+ import { unsmush } from "./unsmush.mjs";
6
7
  export { type Shaken, type Smushed, type Unsmushed, omit, pick, shake, smush, unsmush };
@@ -1,67 +1,8 @@
1
- import { ArrayOrPlainObject, NestedPartial, PlainObject, UnionToIntersection } from "../models.mjs";
1
+ import { ArrayOrPlainObject, PlainObject, UnionToIntersection } from "../models/index.mjs";
2
+ import { AssignOptions, Assigner, MergeOptions, Merger, MergingOptions } from "../models/value/value.merge.model.mjs";
2
3
  //#region src/value/merge.d.ts
3
- /**
4
- * Options for assigning values
5
- */
6
- export type AssignOptions = Omit<MergeOptions, "assignValues">;
7
- /**
8
- * An assigner function for assigning values from one or more objects to the first one
9
- */
10
- export type Assigner = {
11
- /**
12
- * Assign values from one or more objects to the first one
13
- *
14
- * @param to Value to assign to
15
- * @param from Values to assign
16
- * @returns Assigned value
17
- */
18
- assign<To extends PlainObject, From extends PlainObject[]>(to: To, from: [...From]): To & UnionToIntersection<From[number]>;
19
- };
20
- /**
21
- * Options for merging values
22
- */
23
- export type MergeOptions = {
24
- /**
25
- * Assign values to the first array or object instead of creating a new one?
26
- */
27
- assignValues?: boolean;
28
- /**
29
- * Key _(or key epxressions)_ for values that should be replaced
30
- *
31
- * ```ts
32
- * merge([{items: [1, 2, 3]}, {items: [99]}]); // => {items: [99]}
33
- * ```
34
- */
35
- replaceableObjects?: string | RegExp | Array<string | RegExp>;
36
- /**
37
- * Skip nullable values when merging objects?
38
- *
39
- * ```ts
40
- * merge({a: 1, b: 2}, {b: null, c: 3}, {d: null}); // => {a: 1, b: 2, c: 3}
41
- * ```
42
- */
43
- skipNullableAny?: boolean;
44
- /**
45
- * Skip nullable values when merging arrays?
46
- *
47
- * ```ts
48
- * merge([1, 2, 3], [null, null, 99]); // => [1, 2, 99]
49
- * ```
50
- */
51
- skipNullableInArrays?: boolean;
52
- };
53
- /**
54
- * A merger function for merging multiple arrays or objects into a single one
55
- */
56
- export type Merger = {
57
- /**
58
- * Merge multiple arrays or objects into a single one
59
- *
60
- * @param values Values to merge
61
- * @returns Merged value
62
- */
63
- merge<Values extends ArrayOrPlainObject[]>(values: Array<NestedPartial<Values[number]>>): UnionToIntersection<Values[number]>;
64
- };
4
+ declare function Assigner(this: any, options: MergingOptions): void;
5
+ declare function Merger(this: any, options: MergingOptions): void;
65
6
  /**
66
7
  * Assign values from one or more objects to the first one
67
8
  *
@@ -103,4 +44,5 @@ export declare namespace assign {
103
44
  export declare namespace merge {
104
45
  export var initialize: typeof initializeMerger;
105
46
  }
106
- //#endregion
47
+ //#endregion
48
+ export type { AssignOptions, Assigner, MergeOptions, Merger };
@@ -1,4 +1,5 @@
1
1
  import { isArrayOrPlainObject } from "../internal/is.mjs";
2
+ import { MERGE_SYMBOL_ASSIGN, MERGE_SYMBOL_MERGE } from "../models/value/value.merge.model.mjs";
2
3
  //#region src/value/merge.ts
3
4
  function Assigner(options) {
4
5
  this[MERGE_SYMBOL_ASSIGN] = {
@@ -20,21 +21,22 @@ Merger.prototype.merge = mergeFromMerger;
20
21
  * @returns Assigned value
21
22
  */
22
23
  function assign(to, from, options) {
23
- const actual = createMergeOptions(options);
24
+ const actual = createMergingOptions(options);
24
25
  actual.assignValues = true;
25
26
  return mergeValues([to, ...from], actual);
26
27
  }
27
28
  function assignFromAssigner(to, from) {
28
29
  return mergeValues([to, ...from], this[MERGE_SYMBOL_ASSIGN]);
29
30
  }
30
- function createMergeOptions(options) {
31
+ function createMergingOptions(input) {
31
32
  const actual = {
32
33
  assignValues: false,
33
34
  replaceableObjects: void 0,
34
35
  skipNullableAny: false,
35
36
  skipNullableInArrays: false
36
37
  };
37
- if (typeof options !== "object" || options == null) return actual;
38
+ if (typeof input !== "object" || input == null) return actual;
39
+ const options = input;
38
40
  actual.replaceableObjects = getReplaceableObjects(options.replaceableObjects);
39
41
  actual.assignValues = options.assignValues === true;
40
42
  actual.skipNullableAny = options.skipNullableAny === true;
@@ -55,7 +57,7 @@ function getReplaceableObjects(value) {
55
57
  * @returns Assigner function
56
58
  */
57
59
  function initializeAssigner(options) {
58
- return new Assigner(createMergeOptions(options));
60
+ return new Assigner(createMergingOptions(options));
59
61
  }
60
62
  /**
61
63
  * Create a merger with predefined options
@@ -66,7 +68,7 @@ function initializeAssigner(options) {
66
68
  * @returns Merger function
67
69
  */
68
70
  function initializeMerger(options) {
69
- return new Merger(createMergeOptions(options));
71
+ return new Merger(createMergingOptions(options));
70
72
  }
71
73
  /**
72
74
  * Merge multiple arrays or objects into a single one
@@ -76,7 +78,7 @@ function initializeMerger(options) {
76
78
  * @returns Merged value
77
79
  */
78
80
  function merge(values, options) {
79
- return mergeValues(values, createMergeOptions(options));
81
+ return mergeValues(values, createMergingOptions(options));
80
82
  }
81
83
  function mergeFromMerger(values) {
82
84
  return mergeValues(values, this[MERGE_SYMBOL_MERGE]);
@@ -110,8 +112,6 @@ function mergeValues(values, options, prefix) {
110
112
  if (actual.length > 1) return mergeObjects(actual, options, options.assignValues ? actual[0] : void 0, prefix);
111
113
  return options.assignValues ? actual[0] : Array.isArray(actual[0]) ? actual[0].slice() : { ...actual[0] };
112
114
  }
113
- const MERGE_SYMBOL_ASSIGN = Symbol("assign");
114
- const MERGE_SYMBOL_MERGE = Symbol("merge");
115
115
  assign.initialize = initializeAssigner;
116
116
  merge.initialize = initializeMerger;
117
117
  //#endregion
@@ -1,4 +1,4 @@
1
- import { PlainObject } from "../models.mjs";
1
+ import { PlainObject } from "../models/index.mjs";
2
2
  //#region src/value/omit.d.ts
3
3
  /**
4
4
  * Create a new object without the specified keys
@@ -1,4 +1,4 @@
1
- import { PlainObject } from "../models.mjs";
1
+ import { PlainObject } from "../models/index.mjs";
2
2
  //#region src/value/pick.d.ts
3
3
  /**
4
4
  * Create a new object with only the specified keys
@@ -1,9 +1,6 @@
1
- import { PlainObject } from "../models.mjs";
1
+ import { PlainObject } from "../models/index.mjs";
2
+ import { Shaken } from "../models/value/value.misc.model.mjs";
2
3
  //#region src/value/shake.d.ts
3
- /**
4
- * A shaken object, without any `undefined` values
5
- */
6
- export type Shaken<Value extends PlainObject> = { [Key in keyof Value]: Value[Key] extends undefined ? never : Value[Key]; };
7
4
  /**
8
5
  * Shake an object, removing all keys with `undefined` values
9
6
  *
@@ -11,4 +8,5 @@ export type Shaken<Value extends PlainObject> = { [Key in keyof Value]: Value[Ke
11
8
  * @returns Shaken object
12
9
  */
13
10
  export declare function shake<Value extends PlainObject>(value: Value): Shaken<Value>;
14
- //#endregion
11
+ //#endregion
12
+ export type { Shaken };
@@ -1,9 +1,6 @@
1
- import { NestedKeys, NestedValue, PlainObject, Simplify, ToString } from "../models.mjs";
1
+ import { PlainObject } from "../models/index.mjs";
2
+ import { Smushed } from "../models/value/value.misc.model.mjs";
2
3
  //#region src/value/smush.d.ts
3
- /**
4
- * A smushed object, with all nested objects flattened into a single level, using dot notation keys
5
- */
6
- export type Smushed<Value extends PlainObject> = Simplify<{ [NestedKey in NestedKeys<Value>]: NestedValue<Value, ToString<NestedKey>>; }>;
7
4
  /**
8
5
  * Smush an object into a flat object that uses dot notation keys
9
6
  *
@@ -11,4 +8,5 @@ export type Smushed<Value extends PlainObject> = Simplify<{ [NestedKey in Nested
11
8
  * @returns Smushed object with dot notation keys
12
9
  */
13
10
  export declare function smush<Value extends PlainObject>(value: Value): Smushed<Value>;
14
- //#endregion
11
+ //#endregion
12
+ export type { Smushed };
@@ -1,8 +1,9 @@
1
1
  import { isArrayOrPlainObject } from "../internal/is.mjs";
2
+ import "../models/value/value.misc.model.mjs";
2
3
  import { join } from "../internal/string/misc.mjs";
3
4
  //#region src/value/smush.ts
4
5
  function flattenObject(value, depth, smushed, prefix) {
5
- if (depth >= SMUSH_MAX_DEPTH) return {};
6
+ if (depth >= 100) return {};
6
7
  if (smushed.has(value)) return smushed.get(value);
7
8
  const keys = Object.keys(value);
8
9
  const { length } = keys;
@@ -34,6 +35,5 @@ function flattenObject(value, depth, smushed, prefix) {
34
35
  function smush(value) {
35
36
  return typeof value === "object" && value !== null ? flattenObject(value, 0, /* @__PURE__ */ new WeakMap()) : {};
36
37
  }
37
- const SMUSH_MAX_DEPTH = 100;
38
38
  //#endregion
39
39
  export { smush };
@@ -1,25 +1,8 @@
1
- import { PlainObject } from "../models.mjs";
1
+ import { PlainObject } from "../models/index.mjs";
2
+ import { TransformCallback, TransformCallbacks, TransformHandler } from "../models/value/value.transform.model.mjs";
2
3
  //#region src/value/transform.d.ts
3
- /**
4
- * A callback transform an object's properties
5
- */
6
- type TransformCallback<Value extends PlainObject, Key extends keyof Value> = (key: Key, value: Value[Key]) => Value[Key];
7
- /**
8
- * A collection of keyed callbacks to transform an object's properties
9
- */
10
- type TransformCallbacks<Value extends PlainObject> = Partial<{ [Key in keyof Value]: (value: Value[Key]) => Value[Key]; }>;
11
- /**
12
- * A transformer for an object, with predefined callbacks for transforming its properties
13
- */
14
- export type Transformer<Value extends PlainObject> = {
15
- /**
16
- * Transform an object's properties
17
- *
18
- * @param value Object to transform
19
- * @returns Transformed object
20
- */
21
- transform(value: Value): Value;
22
- };
4
+ declare function Transformer(this: any, transformer: ReturnType<typeof getTransformHandler>): void;
5
+ declare function getTransformHandler<Value extends PlainObject, Key extends keyof Value>(input: unknown): TransformHandler<Value> | undefined;
23
6
  /**
24
7
  * Initialize a transformer for an object with a transformer function
25
8
  *
@@ -57,4 +40,5 @@ export declare function transform<Value extends PlainObject>(value: Value, trans
57
40
  export declare namespace transform {
58
41
  export var initialize: typeof initializeTransformer;
59
42
  }
60
- //#endregion
43
+ //#endregion
44
+ export type { TransformCallback, TransformCallbacks, Transformer };
@@ -1,4 +1,5 @@
1
1
  import { isNonPlainObject } from "../internal/is.mjs";
2
+ import { TRANSFORM_SYMBOL } from "../models/value/value.transform.model.mjs";
2
3
  //#region src/value/transform.ts
3
4
  function Transformer(transformer) {
4
5
  this[TRANSFORM_SYMBOL] = transformer;
@@ -37,7 +38,6 @@ function transformValue(value) {
37
38
  }
38
39
  return value;
39
40
  }
40
- const TRANSFORM_SYMBOL = Symbol("transform");
41
41
  transform.initialize = initializeTransformer;
42
42
  //#endregion
43
43
  export { initializeTransformer, transform };
@@ -1,13 +1,6 @@
1
- import { PlainObject, Simplify, UnionToIntersection } from "../models.mjs";
1
+ import { PlainObject } from "../models/index.mjs";
2
+ import { Unsmushed } from "../models/value/value.misc.model.mjs";
2
3
  //#region src/value/unsmush.d.ts
3
- /**
4
- * Thanks, type-fest!
5
- */
6
- type KeysOfUnion<ObjectType> = keyof UnionToIntersection<ObjectType extends unknown ? Record<keyof ObjectType, never> : never>;
7
- /**
8
- * An unsmushed object, with all dot notation keys turned into nested keys
9
- */
10
- export type Unsmushed<Value extends PlainObject> = Simplify<Omit<{ [UnionKey in KeysOfUnion<Value>]: Value[UnionKey]; }, `${string}.${string}`>>;
11
4
  /**
12
5
  * Unsmush a smushed object _(turning dot notation keys into nested keys)_
13
6
  *
@@ -15,4 +8,5 @@ export type Unsmushed<Value extends PlainObject> = Simplify<Omit<{ [UnionKey in
15
8
  * @returns Unsmushed object with nested keys
16
9
  */
17
10
  export declare function unsmush<Value extends PlainObject>(value: Value): Unsmushed<Value>;
18
- //#endregion
11
+ //#endregion
12
+ export type { Unsmushed };