@oscarpalmer/atoms 0.186.2 → 0.187.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 (229) hide show
  1. package/dist/array/filter.d.mts +4 -4
  2. package/dist/array/find.d.mts +4 -4
  3. package/dist/array/first.d.mts +4 -4
  4. package/dist/array/get.d.mts +27 -1
  5. package/dist/array/get.mjs +5 -3
  6. package/dist/array/group-by.d.mts +6 -6
  7. package/dist/array/last.d.mts +4 -4
  8. package/dist/array/match.d.mts +7 -6
  9. package/dist/array/move.d.mts +7 -7
  10. package/dist/array/move.mjs +1 -1
  11. package/dist/array/select.d.mts +1 -0
  12. package/dist/array/slice.d.mts +3 -3
  13. package/dist/array/sort.d.mts +10 -7
  14. package/dist/array/sort.mjs +4 -3
  15. package/dist/array/swap.d.mts +1 -1
  16. package/dist/array/swap.mjs +1 -1
  17. package/dist/array/to-map.d.mts +32 -32
  18. package/dist/array/to-record.d.mts +6 -6
  19. package/dist/array/to-set.d.mts +6 -6
  20. package/dist/beacon.d.mts +6 -0
  21. package/dist/beacon.mjs +3 -0
  22. package/dist/color/index.d.mts +6 -2
  23. package/dist/color/index.mjs +6 -2
  24. package/dist/color/instance.d.mts +78 -14
  25. package/dist/color/instance.mjs +78 -14
  26. package/dist/color/misc/get.d.mts +39 -11
  27. package/dist/color/misc/get.mjs +39 -11
  28. package/dist/color/misc/is.d.mts +26 -11
  29. package/dist/color/misc/is.mjs +26 -11
  30. package/dist/color/misc/state.mjs +1 -1
  31. package/dist/color/models.d.mts +7 -4
  32. package/dist/color/space/hex.d.mts +15 -6
  33. package/dist/color/space/hex.mjs +15 -6
  34. package/dist/color/space/hsl.d.mts +10 -4
  35. package/dist/color/space/hsl.mjs +10 -4
  36. package/dist/color/space/rgb.d.mts +21 -12
  37. package/dist/color/space/rgb.mjs +21 -12
  38. package/dist/function/assert.d.mts +20 -14
  39. package/dist/function/assert.mjs +19 -13
  40. package/dist/function/limit.d.mts +8 -6
  41. package/dist/function/limit.mjs +8 -6
  42. package/dist/function/memoize.d.mts +15 -4
  43. package/dist/function/memoize.mjs +18 -4
  44. package/dist/function/once.d.mts +5 -3
  45. package/dist/function/once.mjs +5 -3
  46. package/dist/function/retry.d.mts +5 -2
  47. package/dist/function/retry.mjs +3 -1
  48. package/dist/function/work.d.mts +146 -98
  49. package/dist/{kalas.d.mts → herald.d.mts} +17 -8
  50. package/dist/{kalas.mjs → herald.mjs} +22 -13
  51. package/dist/index.d.mts +1464 -708
  52. package/dist/index.mjs +677 -324
  53. package/dist/internal/array/index-of.d.mts +4 -4
  54. package/dist/internal/array/insert.mjs +1 -1
  55. package/dist/internal/array/shuffle.d.mts +1 -0
  56. package/dist/internal/array/shuffle.mjs +2 -1
  57. package/dist/internal/is.d.mts +26 -8
  58. package/dist/internal/is.mjs +26 -8
  59. package/dist/internal/math/aggregate.d.mts +9 -9
  60. package/dist/internal/number.d.mts +13 -2
  61. package/dist/internal/number.mjs +13 -2
  62. package/dist/internal/random.d.mts +4 -2
  63. package/dist/internal/random.mjs +7 -5
  64. package/dist/internal/result.d.mts +17 -11
  65. package/dist/internal/result.mjs +10 -14
  66. package/dist/internal/string.d.mts +16 -1
  67. package/dist/internal/string.mjs +24 -1
  68. package/dist/internal/value/compare.d.mts +5 -2
  69. package/dist/internal/value/compare.mjs +5 -2
  70. package/dist/internal/value/equal.d.mts +12 -3
  71. package/dist/internal/value/equal.mjs +7 -4
  72. package/dist/internal/value/get.d.mts +17 -17
  73. package/dist/internal/value/has.d.mts +55 -11
  74. package/dist/internal/value/set.d.mts +24 -0
  75. package/dist/is.d.mts +12 -0
  76. package/dist/is.mjs +16 -1
  77. package/dist/logger.d.mts +7 -6
  78. package/dist/logger.mjs +6 -5
  79. package/dist/math.d.mts +36 -18
  80. package/dist/math.mjs +6 -3
  81. package/dist/models.d.mts +3 -3
  82. package/dist/promise/delay.d.mts +2 -0
  83. package/dist/promise/helpers.d.mts +6 -4
  84. package/dist/promise/helpers.mjs +6 -4
  85. package/dist/promise/index.d.mts +49 -38
  86. package/dist/promise/misc.d.mts +10 -7
  87. package/dist/promise/misc.mjs +4 -3
  88. package/dist/promise/models.d.mts +18 -19
  89. package/dist/promise/models.mjs +4 -3
  90. package/dist/promise/timed.d.mts +8 -6
  91. package/dist/query.d.mts +2 -0
  92. package/dist/query.mjs +2 -0
  93. package/dist/queue.d.mts +15 -4
  94. package/dist/queue.mjs +10 -3
  95. package/dist/random.d.mts +9 -2
  96. package/dist/random.mjs +7 -2
  97. package/dist/result/index.d.mts +14 -8
  98. package/dist/result/match.d.mts +18 -10
  99. package/dist/result/misc.d.mts +14 -7
  100. package/dist/result/misc.mjs +4 -2
  101. package/dist/result/models.d.mts +2 -0
  102. package/dist/result/work/flow.d.mts +86 -62
  103. package/dist/result/work/pipe.d.mts +55 -33
  104. package/dist/sized/map.d.mts +19 -16
  105. package/dist/sized/map.mjs +4 -4
  106. package/dist/sized/set.d.mts +20 -16
  107. package/dist/sized/set.mjs +8 -7
  108. package/dist/string/case.d.mts +8 -0
  109. package/dist/string/case.mjs +8 -0
  110. package/dist/string/fuzzy.d.mts +19 -5
  111. package/dist/string/fuzzy.mjs +7 -0
  112. package/dist/string/index.d.mts +17 -2
  113. package/dist/string/index.mjs +7 -9
  114. package/dist/string/match.d.mts +3 -0
  115. package/dist/string/match.mjs +3 -0
  116. package/dist/string/normalize.d.mts +6 -2
  117. package/dist/string/normalize.mjs +5 -2
  118. package/dist/string/template.d.mts +38 -9
  119. package/dist/string/template.mjs +19 -19
  120. package/dist/value/clone.d.mts +25 -4
  121. package/dist/value/clone.mjs +36 -22
  122. package/dist/value/collection.d.mts +9 -6
  123. package/dist/value/collection.mjs +3 -2
  124. package/dist/value/diff.d.mts +3 -1
  125. package/dist/value/diff.mjs +1 -0
  126. package/dist/value/freeze.d.mts +118 -9
  127. package/dist/value/freeze.mjs +56 -14
  128. package/dist/value/index.d.mts +1 -2
  129. package/dist/value/index.mjs +1 -2
  130. package/dist/value/merge.d.mts +11 -5
  131. package/dist/value/merge.mjs +2 -2
  132. package/dist/value/omit.d.mts +1 -0
  133. package/dist/value/omit.mjs +1 -0
  134. package/dist/value/pick.d.mts +1 -0
  135. package/dist/value/pick.mjs +1 -0
  136. package/dist/value/shake.d.mts +1 -0
  137. package/dist/value/shake.mjs +1 -0
  138. package/dist/value/smush.d.mts +1 -0
  139. package/dist/value/smush.mjs +1 -0
  140. package/dist/value/transform.d.mts +7 -3
  141. package/dist/value/unsmush.d.mts +1 -0
  142. package/dist/value/unsmush.mjs +1 -0
  143. package/package.json +11 -7
  144. package/src/array/filter.ts +4 -4
  145. package/src/array/find.ts +4 -4
  146. package/src/array/first.ts +4 -4
  147. package/src/array/get.ts +40 -5
  148. package/src/array/group-by.ts +6 -6
  149. package/src/array/last.ts +4 -4
  150. package/src/array/match.ts +7 -6
  151. package/src/array/move.ts +7 -7
  152. package/src/array/select.ts +1 -0
  153. package/src/array/slice.ts +3 -3
  154. package/src/array/sort.ts +15 -10
  155. package/src/array/swap.ts +1 -1
  156. package/src/array/to-map.ts +32 -32
  157. package/src/array/to-record.ts +6 -6
  158. package/src/array/to-set.ts +6 -6
  159. package/src/beacon.ts +6 -0
  160. package/src/color/index.ts +6 -2
  161. package/src/color/instance.ts +78 -14
  162. package/src/color/misc/get.ts +39 -11
  163. package/src/color/misc/is.ts +26 -11
  164. package/src/color/misc/state.ts +1 -1
  165. package/src/color/models.ts +7 -4
  166. package/src/color/space/hex.ts +15 -6
  167. package/src/color/space/hsl.ts +10 -4
  168. package/src/color/space/rgb.ts +21 -12
  169. package/src/function/assert.ts +20 -14
  170. package/src/function/limit.ts +8 -6
  171. package/src/function/memoize.ts +24 -5
  172. package/src/function/once.ts +5 -3
  173. package/src/function/retry.ts +7 -3
  174. package/src/function/work.ts +146 -98
  175. package/src/{kalas.ts → herald.ts} +23 -14
  176. package/src/index.ts +3 -2
  177. package/src/internal/array/index-of.ts +4 -4
  178. package/src/internal/array/insert.ts +1 -1
  179. package/src/internal/array/shuffle.ts +2 -1
  180. package/src/internal/is.ts +26 -8
  181. package/src/internal/math/aggregate.ts +9 -9
  182. package/src/internal/number.ts +13 -2
  183. package/src/internal/random.ts +10 -4
  184. package/src/internal/result.ts +30 -29
  185. package/src/internal/string.ts +28 -0
  186. package/src/internal/value/compare.ts +5 -2
  187. package/src/internal/value/equal.ts +13 -4
  188. package/src/internal/value/get.ts +17 -17
  189. package/src/internal/value/has.ts +54 -11
  190. package/src/internal/value/set.ts +24 -0
  191. package/src/is.ts +15 -1
  192. package/src/logger.ts +8 -7
  193. package/src/math.ts +36 -18
  194. package/src/models.ts +3 -3
  195. package/src/promise/delay.ts +2 -0
  196. package/src/promise/helpers.ts +6 -4
  197. package/src/promise/index.ts +49 -38
  198. package/src/promise/misc.ts +10 -7
  199. package/src/promise/models.ts +18 -19
  200. package/src/promise/timed.ts +8 -6
  201. package/src/query.ts +2 -0
  202. package/src/queue.ts +15 -4
  203. package/src/random.ts +8 -1
  204. package/src/result/index.ts +14 -8
  205. package/src/result/match.ts +18 -10
  206. package/src/result/misc.ts +17 -9
  207. package/src/result/models.ts +2 -0
  208. package/src/result/work/flow.ts +86 -62
  209. package/src/result/work/pipe.ts +55 -33
  210. package/src/sized/map.ts +20 -17
  211. package/src/sized/set.ts +21 -17
  212. package/src/string/case.ts +8 -0
  213. package/src/string/fuzzy.ts +19 -5
  214. package/src/string/index.ts +18 -15
  215. package/src/string/match.ts +3 -0
  216. package/src/string/normalize.ts +6 -2
  217. package/src/string/template.ts +69 -18
  218. package/src/value/clone.ts +51 -26
  219. package/src/value/collection.ts +9 -6
  220. package/src/value/diff.ts +3 -1
  221. package/src/value/freeze.ts +239 -25
  222. package/src/value/index.ts +0 -1
  223. package/src/value/merge.ts +11 -5
  224. package/src/value/omit.ts +1 -0
  225. package/src/value/pick.ts +1 -0
  226. package/src/value/shake.ts +1 -0
  227. package/src/value/smush.ts +1 -0
  228. package/src/value/transform.ts +7 -3
  229. package/src/value/unsmush.ts +1 -0
@@ -38,6 +38,7 @@ export type NormalizeOptions = {
38
38
  export type Normalizer = {
39
39
  /**
40
40
  * Normalize a string
41
+ *
41
42
  * @param value String to normalize
42
43
  * @returns Normalized string
43
44
  */
@@ -52,6 +53,7 @@ type Options = Required<NormalizeOptions>;
52
53
 
53
54
  /**
54
55
  * Deburr a string, removing diacritical marks
56
+ *
55
57
  * @param value String to deburr
56
58
  * @returns Deburred string
57
59
  */
@@ -89,7 +91,8 @@ function getNormalizeOptions(input?: NormalizeOptions): Options {
89
91
  /**
90
92
  * Initialize a string normalizer
91
93
  *
92
- * Available as `initializeNormalizer` and `normalize.initialize`
94
+ * _Available as `initializeNormalizer` and `normalize.initialize`_
95
+ *
93
96
  * @param options Normalization options
94
97
  * @returns Normalizer function
95
98
  */
@@ -102,7 +105,8 @@ export function initializeNormalizer(options?: NormalizeOptions): Normalizer {
102
105
  /**
103
106
  * Normalize a string
104
107
  *
105
- * By default, the string will be trimmed, deburred, and then lowercased
108
+ * _By default, the string will be trimmed, deburred, and then lowercased_
109
+ *
106
110
  * @param value String to normalize
107
111
  * @param options Normalization options
108
112
  * @returns Normalized string
@@ -1,10 +1,19 @@
1
- import {isPlainObject} from '../internal/is';
2
- import {getString} from '../internal/string';
1
+ import {isPlainObject, isTemplateStringsArray} from '../internal/is';
2
+ import {getString, interpolate} from '../internal/string';
3
3
  import {getValue} from '../internal/value/get';
4
4
  import type {PlainObject} from '../models';
5
5
 
6
6
  // #region Types
7
7
 
8
+ /**
9
+ * Renderer for a string template with variables
10
+ *
11
+ * @param variables Variables to use
12
+ * @param options Templating options
13
+ * @returns Templated string
14
+ */
15
+ type Renderer = (variables?: PlainObject, options?: Partial<TemplateOptions>) => string;
16
+
8
17
  /**
9
18
  * Options for templating strings
10
19
  */
@@ -19,18 +28,39 @@ export type TemplateOptions = {
19
28
  pattern?: RegExp;
20
29
  };
21
30
 
31
+ type Templater = {
32
+ /**
33
+ * Render a string from a template with variables
34
+ *
35
+ * @returns Templated string
36
+ */
37
+ (strings: TemplateStringsArray, ...values: unknown[]): TemplaterRenderer;
38
+
39
+ /**
40
+ * Render a string from a template with variables
41
+ *
42
+ * @param value Template string
43
+ * @param variables Variables to use
44
+ * @returns Templated string
45
+ */
46
+ (value: string, variables?: PlainObject): string;
47
+ };
48
+
22
49
  /**
23
- * Render a string from a template with variables
24
- * @param value Template string
25
- * @param variables Variables to use
26
- * @returns Templated string
50
+ * Render a template string with variables
27
51
  */
28
- type Templater = (value: string, variables?: PlainObject) => string;
52
+ type TemplaterRenderer = (variables?: PlainObject) => string;
29
53
 
30
54
  // #endregion
31
55
 
32
56
  // #region Functions
33
57
 
58
+ function getRenderer(strings: TemplateStringsArray, values: unknown[]): Renderer {
59
+ return (variables?: PlainObject, options?: Partial<TemplateOptions>) => {
60
+ return template(interpolate(strings, values), variables, options);
61
+ };
62
+ }
63
+
34
64
  function getTemplateOptions(input?: Partial<TemplateOptions>): Required<TemplateOptions> {
35
65
  const options = isPlainObject(input) ? (input as TemplateOptions) : {};
36
66
 
@@ -50,7 +80,7 @@ function handleTemplate(
50
80
  return '';
51
81
  }
52
82
 
53
- if (typeof variables !== 'object' || variables === null) {
83
+ if (typeof variables !== 'object' || variables === null || Object.keys(variables).length === 0) {
54
84
  return value;
55
85
  }
56
86
 
@@ -68,22 +98,34 @@ function handleTemplate(
68
98
  }
69
99
 
70
100
  /**
71
- * Create a templater with predefined options
101
+ * Create a _Templater_ with predefined options
102
+ *
103
+ * _Available as `initializeTemplater` and `template.initialize`_
72
104
  *
73
- * Available as `initializeTemplater` and `template.initialize`
74
105
  * @param options Templating options
75
- * @returns Templater function
106
+ * @returns _Templater_ function
76
107
  */
77
108
  export function initializeTemplater(options?: Partial<TemplateOptions>): Templater {
78
109
  const {ignoreCase, pattern} = getTemplateOptions(options);
79
110
 
80
- return (value: string, variables?: PlainObject): string => {
81
- return handleTemplate(value, pattern, ignoreCase, variables);
82
- };
111
+ return ((value: string | TemplateStringsArray, ...parameters: unknown[]) => {
112
+ return isTemplateStringsArray(value)
113
+ ? (variables?: PlainObject) =>
114
+ handleTemplate(interpolate(value, parameters), pattern, ignoreCase, variables)
115
+ : handleTemplate(value, pattern, ignoreCase, parameters[0] as PlainObject);
116
+ }) as Templater;
83
117
  }
84
118
 
119
+ /**
120
+ * Get a _Renderer_ for a string template
121
+ *
122
+ * @returns _Renderer_ function
123
+ */
124
+ export function template(strings: TemplateStringsArray, ...values: unknown[]): Renderer;
125
+
85
126
  /**
86
127
  * Render a string from a template with variables
128
+ *
87
129
  * @param value Template string
88
130
  * @param variables Variables to use
89
131
  * @param options Templating options
@@ -91,12 +133,21 @@ export function initializeTemplater(options?: Partial<TemplateOptions>): Templat
91
133
  */
92
134
  export function template(
93
135
  value: string,
94
- variables: PlainObject,
136
+ variables?: PlainObject,
95
137
  options?: Partial<TemplateOptions>,
96
- ): string {
97
- const {ignoreCase, pattern} = getTemplateOptions(options);
138
+ ): string;
139
+
140
+ export function template(
141
+ value: string | TemplateStringsArray,
142
+ ...parameters: unknown[]
143
+ ): string | Renderer {
144
+ if (isTemplateStringsArray(value)) {
145
+ return getRenderer(value, parameters);
146
+ }
147
+
148
+ const {ignoreCase, pattern} = getTemplateOptions(parameters[1] as Partial<TemplateOptions>);
98
149
 
99
- return handleTemplate(value, pattern, ignoreCase, variables);
150
+ return handleTemplate(value, pattern, ignoreCase, parameters[0] as PlainObject);
100
151
  }
101
152
 
102
153
  template.initialize = initializeTemplater;
@@ -10,15 +10,25 @@ const CLONE_NAME = 'clone';
10
10
 
11
11
  // #region Functions
12
12
 
13
+ /**
14
+ * Clone any kind of value _(shallowly)_
15
+ *
16
+ * @param value Value to clone
17
+ * @param flat Clone only the value itself, without cloning nested values
18
+ * @returns Cloned value
19
+ */
20
+ export function clone<Value>(value: Value, flat: true): Value;
21
+
13
22
  /**
14
23
  * Clone any kind of value _(deeply, if needed)_
24
+ *
15
25
  * @param value Value to clone
16
26
  * @returns Cloned value
17
27
  */
18
28
  export function clone<Value>(value: Value): Value;
19
29
 
20
- export function clone(value: unknown): unknown {
21
- return cloneValue(value, 0, new WeakMap());
30
+ export function clone(value: unknown, flat?: boolean): unknown {
31
+ return flat === true ? copy(value) : cloneValue(value, 0, new WeakMap(), false);
22
32
  }
23
33
 
24
34
  clone.handlers = getSelfHandlers(clone, {
@@ -69,6 +79,7 @@ function cloneMap(
69
79
  map: Map<unknown, unknown>,
70
80
  depth: number,
71
81
  references: WeakMap<WeakKey, unknown>,
82
+ flat: boolean,
72
83
  ): Map<unknown, unknown> {
73
84
  if (depth >= MAX_CLONE_DEPTH) {
74
85
  return map;
@@ -79,8 +90,8 @@ function cloneMap(
79
90
 
80
91
  for (const entry of entries) {
81
92
  cloned.set(
82
- cloneValue(entry[0], depth + 1, references),
83
- cloneValue(entry[1], depth + 1, references),
93
+ flat ? entry[0] : cloneValue(entry[0], depth + 1, references, false),
94
+ flat ? entry[1] : cloneValue(entry[1], depth + 1, references, false),
84
95
  );
85
96
  }
86
97
 
@@ -101,12 +112,13 @@ function cloneNode(node: Node, depth: number, references: WeakMap<WeakKey, unkno
101
112
  return cloned;
102
113
  }
103
114
 
104
- function clonePlainObject(
115
+ function cloneObject(
105
116
  value: ArrayOrPlainObject,
106
117
  depth: number,
107
118
  references: WeakMap<WeakKey, unknown>,
119
+ flat: boolean,
108
120
  ): ArrayOrPlainObject {
109
- if (depth >= MAX_CLONE_DEPTH) {
121
+ if (flat || depth >= MAX_CLONE_DEPTH) {
110
122
  return Array.isArray(value) ? value.slice() : {...value};
111
123
  }
112
124
 
@@ -117,7 +129,7 @@ function clonePlainObject(
117
129
  for (let index = 0; index < length; index += 1) {
118
130
  const key = keys[index];
119
131
 
120
- cloned[key] = cloneValue((value as PlainObject)[key], depth + 1, references);
132
+ cloned[key] = cloneValue((value as PlainObject)[key], depth + 1, references, false);
121
133
  }
122
134
 
123
135
  references.set(value, cloned);
@@ -147,6 +159,7 @@ function cloneSet(
147
159
  set: Set<unknown>,
148
160
  depth: number,
149
161
  references: WeakMap<WeakKey, unknown>,
162
+ flat: boolean,
150
163
  ): Set<unknown> {
151
164
  if (depth >= MAX_CLONE_DEPTH) {
152
165
  return set;
@@ -157,7 +170,7 @@ function cloneSet(
157
170
  const {length} = values;
158
171
 
159
172
  for (let index = 0; index < length; index += 1) {
160
- cloned.add(cloneValue(values[index], depth + 1, references));
173
+ cloned.add(flat ? values[index] : cloneValue(values[index], depth + 1, references, false));
161
174
  }
162
175
 
163
176
  references.set(set, cloned);
@@ -181,26 +194,23 @@ function cloneTypedArray(
181
194
  return cloned as TypedArray;
182
195
  }
183
196
 
184
- function cloneValue(value: unknown, depth: number, references: WeakMap<WeakKey, unknown>): unknown {
197
+ function cloneValue(
198
+ value: unknown,
199
+ depth: number,
200
+ references: WeakMap<WeakKey, unknown>,
201
+ flat: boolean,
202
+ ): unknown {
185
203
  switch (true) {
186
204
  case value == null:
187
- return value;
188
-
189
205
  case typeof value === 'bigint':
190
- return BigInt(value);
191
-
192
206
  case typeof value === 'boolean':
193
- return Boolean(value);
207
+ case typeof value === 'number':
208
+ case typeof value === 'string':
209
+ return value;
194
210
 
195
211
  case typeof value === 'function':
196
212
  return;
197
213
 
198
- case typeof value === 'number':
199
- return Number(value);
200
-
201
- case typeof value === 'string':
202
- return String(value);
203
-
204
214
  case typeof value === 'symbol':
205
215
  return Symbol(value.description);
206
216
 
@@ -220,16 +230,16 @@ function cloneValue(value: unknown, depth: number, references: WeakMap<WeakKey,
220
230
  return cloneRegularExpression(value, depth, references);
221
231
 
222
232
  case value instanceof Map:
223
- return cloneMap(value, depth, references);
233
+ return cloneMap(value, depth, references, flat);
224
234
 
225
235
  case typeof Node !== 'undefined' && value instanceof Node:
226
236
  return cloneNode(value, depth, references);
227
237
 
228
238
  case value instanceof Set:
229
- return cloneSet(value, depth, references);
239
+ return cloneSet(value, depth, references, flat);
230
240
 
231
241
  case isArrayOrPlainObject(value):
232
- return clonePlainObject(value, depth, references);
242
+ return cloneObject(value, depth, references, flat);
233
243
 
234
244
  case isTypedArray(value):
235
245
  return cloneTypedArray(value, depth, references);
@@ -239,10 +249,24 @@ function cloneValue(value: unknown, depth: number, references: WeakMap<WeakKey,
239
249
  }
240
250
  }
241
251
 
252
+ /**
253
+ * Copy any kind of value
254
+ *
255
+ * - Clones the value shallowly, without cloning nested values
256
+ * - To copy a value deeply, use `clone` instead
257
+ *
258
+ * @param value Value to copy
259
+ * @returns Copied value
260
+ */
261
+ export function copy<Value>(value: Value): Value {
262
+ return cloneValue(value, 0, new WeakMap(), true) as Value;
263
+ }
264
+
242
265
  /**
243
266
  * Deregister a clone handler for a specific class
244
267
  *
245
- * Available as `deregisterCloner` and `template.deregister`
268
+ * _Available as `deregisterCloner` and `template.deregister`_
269
+ *
246
270
  * @param constructor Class constructor
247
271
  */
248
272
  export function deregisterCloner<Instance>(constructor: Constructor<Instance>): void {
@@ -252,9 +276,10 @@ export function deregisterCloner<Instance>(constructor: Constructor<Instance>):
252
276
  /**
253
277
  * Register a clone handler for a specific class
254
278
  *
255
- * Available as `registerCloner` and `template.register`
279
+ * _Available as `registerCloner` and `template.register`_
280
+ *
256
281
  * @param constructor Class constructor
257
- * @param handler Method name or clone function _(defaults to `clone`)_
282
+ * @param handler Method name or clone function _(defaults to method name `clone`)_
258
283
  */
259
284
  export function registerCloner<Instance>(
260
285
  constructor: Constructor<Instance>,
@@ -1,16 +1,18 @@
1
1
  import {equal} from '../internal/value/equal';
2
2
 
3
3
  /**
4
- * Does the value exist for a key in a map?
5
- * @param map Map to check in
4
+ * Does the value exist for a key in a _Map_?
5
+ *
6
+ * @param map _Map_ to check in
6
7
  * @param value Value to check for
7
8
  * @returns `true` if the value exists, otherwise `false`
8
9
  */
9
10
  export function inMap<Value>(map: Map<unknown, Value>, value: Value): boolean;
10
11
 
11
12
  /**
12
- * Does the value exist for a key in a map?
13
- * @param map Map to check in
13
+ * Does the value exist for a key in a _Map_?
14
+ *
15
+ * @param map _Map_ to check in
14
16
  * @param value Value to check for
15
17
  * @param key To return the key for the value
16
18
  * @returns The key for the value if it exists, otherwise `undefined`
@@ -36,8 +38,9 @@ export function inMap<Key, Value>(map: Map<Key, Value>, value: Value, key?: unkn
36
38
  }
37
39
 
38
40
  /**
39
- * Does the value exist in a set?
40
- * @param set Set to check in
41
+ * Does the value exist in a _Set_?
42
+ *
43
+ * @param set _Set_ to check in
41
44
  * @param value Value to check for
42
45
  * @returns `true` if the value exists, otherwise `false`
43
46
  */
package/src/value/diff.ts CHANGED
@@ -27,7 +27,8 @@ export type DiffResult<First, Second = First> = {
27
27
  */
28
28
  type: DiffType;
29
29
  /**
30
- * - The differences between the two values
30
+ * The differences between the two values
31
+ *
31
32
  * - Keys are in dot notation
32
33
  * - Values are objects with `from` and `to` properties
33
34
  */
@@ -68,6 +69,7 @@ type Parameters = {
68
69
 
69
70
  /**
70
71
  * Find the differences between two values
72
+ *
71
73
  * @param first First value
72
74
  * @param second Second value
73
75
  * @param options Comparison options