@mnaoumov/typescript-lib 0.0.0 → 1.0.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 (180) hide show
  1. package/@types/debug/package.json +4 -0
  2. package/LICENSE +21 -0
  3. package/README.md +7 -1
  4. package/dist/lib/cjs/@types/debug.d.cts +21 -0
  5. package/dist/lib/cjs/abort-controller.cjs +202 -0
  6. package/dist/lib/cjs/abort-controller.d.cts +135 -0
  7. package/dist/lib/cjs/aggregate-error.cjs +98 -0
  8. package/dist/lib/cjs/aggregate-error.d.cts +24 -0
  9. package/dist/lib/cjs/array-buffer.cjs +96 -0
  10. package/dist/lib/cjs/array-buffer.d.cts +16 -0
  11. package/dist/lib/cjs/array.cjs +134 -0
  12. package/dist/lib/cjs/array.d.cts +46 -0
  13. package/dist/lib/cjs/async-events.cjs +466 -0
  14. package/dist/lib/cjs/async-events.d.cts +456 -0
  15. package/dist/lib/cjs/async-operation-hook.cjs +113 -0
  16. package/dist/lib/cjs/async-operation-hook.d.cts +59 -0
  17. package/dist/lib/cjs/async.cjs +521 -0
  18. package/dist/lib/cjs/async.d.cts +414 -0
  19. package/dist/lib/cjs/beeper.cjs +126 -0
  20. package/dist/lib/cjs/beeper.d.cts +21 -0
  21. package/dist/lib/cjs/blob.cjs +160 -0
  22. package/dist/lib/cjs/blob.d.cts +59 -0
  23. package/dist/lib/cjs/bytes.cjs +114 -0
  24. package/dist/lib/cjs/bytes.d.cts +17 -0
  25. package/dist/lib/cjs/debug-controller.cjs +80 -0
  26. package/dist/lib/cjs/debug-controller.d.cts +87 -0
  27. package/dist/lib/cjs/debug.cjs +235 -0
  28. package/dist/lib/cjs/debug.d.cts +66 -0
  29. package/dist/lib/cjs/desktop-zip-extractor.cjs +215 -0
  30. package/dist/lib/cjs/desktop-zip-extractor.d.cts +95 -0
  31. package/dist/lib/cjs/disposable.cjs +414 -0
  32. package/dist/lib/cjs/disposable.d.cts +387 -0
  33. package/dist/lib/cjs/enum.cjs +100 -0
  34. package/dist/lib/cjs/enum.d.cts +24 -0
  35. package/dist/lib/cjs/error.cjs +297 -0
  36. package/dist/lib/cjs/error.d.cts +181 -0
  37. package/dist/lib/cjs/function.cjs +141 -0
  38. package/dist/lib/cjs/function.d.cts +128 -0
  39. package/dist/lib/cjs/html-element.cjs +341 -0
  40. package/dist/lib/cjs/html-element.d.cts +199 -0
  41. package/dist/lib/cjs/index.cjs +195 -0
  42. package/dist/lib/cjs/index.d.cts +33 -0
  43. package/dist/lib/cjs/jpeg-metadata.cjs +228 -0
  44. package/dist/lib/cjs/jpeg-metadata.d.cts +42 -0
  45. package/dist/lib/cjs/library.cjs +158 -0
  46. package/dist/lib/cjs/library.d.cts +96 -0
  47. package/dist/lib/cjs/object-utils.cjs +617 -0
  48. package/dist/lib/cjs/object-utils.d.cts +298 -0
  49. package/dist/lib/cjs/path.cjs +202 -0
  50. package/dist/lib/cjs/path.d.cts +154 -0
  51. package/dist/lib/cjs/reg-exp.cjs +254 -0
  52. package/dist/lib/cjs/reg-exp.d.cts +87 -0
  53. package/dist/lib/cjs/string.cjs +326 -0
  54. package/dist/lib/cjs/string.d.cts +361 -0
  55. package/dist/lib/cjs/transformers/date-transformer.cjs +129 -0
  56. package/dist/lib/cjs/transformers/date-transformer.d.cts +39 -0
  57. package/dist/lib/cjs/transformers/group-transformer.cjs +173 -0
  58. package/dist/lib/cjs/transformers/group-transformer.d.cts +70 -0
  59. package/dist/lib/cjs/transformers/index.cjs +123 -0
  60. package/dist/lib/cjs/transformers/index.d.cts +9 -0
  61. package/dist/lib/cjs/transformers/map-transformer.cjs +129 -0
  62. package/dist/lib/cjs/transformers/map-transformer.d.cts +41 -0
  63. package/dist/lib/cjs/transformers/set-transformer.cjs +129 -0
  64. package/dist/lib/cjs/transformers/set-transformer.d.cts +39 -0
  65. package/dist/lib/cjs/transformers/skip-private-property-transformer.cjs +127 -0
  66. package/dist/lib/cjs/transformers/skip-private-property-transformer.d.cts +36 -0
  67. package/dist/lib/cjs/transformers/transformer.cjs +170 -0
  68. package/dist/lib/cjs/transformers/transformer.d.cts +70 -0
  69. package/dist/lib/cjs/transformers/two-way-map-transformer.cjs +130 -0
  70. package/dist/lib/cjs/transformers/two-way-map-transformer.d.cts +42 -0
  71. package/dist/lib/cjs/transformers/typed-transformer.cjs +94 -0
  72. package/dist/lib/cjs/transformers/typed-transformer.d.cts +39 -0
  73. package/dist/lib/cjs/two-way-map.cjs +208 -0
  74. package/dist/lib/cjs/two-way-map.d.cts +101 -0
  75. package/dist/lib/cjs/type-guards.cjs +128 -0
  76. package/dist/lib/cjs/type-guards.d.cts +84 -0
  77. package/dist/lib/cjs/type.cjs +121 -0
  78. package/dist/lib/cjs/type.d.cts +122 -0
  79. package/dist/lib/cjs/typescript-lib-state.cjs +126 -0
  80. package/dist/lib/cjs/typescript-lib-state.d.cts +56 -0
  81. package/dist/lib/cjs/url.cjs +136 -0
  82. package/dist/lib/cjs/url.d.cts +74 -0
  83. package/dist/lib/cjs/value-provider.cjs +100 -0
  84. package/dist/lib/cjs/value-provider.d.cts +28 -0
  85. package/dist/lib/cjs/value-wrapper.cjs +144 -0
  86. package/dist/lib/cjs/value-wrapper.d.cts +47 -0
  87. package/dist/lib/esm/@types/debug.d.mts +21 -0
  88. package/dist/lib/esm/abort-controller.d.mts +135 -0
  89. package/dist/lib/esm/abort-controller.mjs +159 -0
  90. package/dist/lib/esm/aggregate-error.d.mts +24 -0
  91. package/dist/lib/esm/aggregate-error.mjs +60 -0
  92. package/dist/lib/esm/array-buffer.d.mts +16 -0
  93. package/dist/lib/esm/array-buffer.mjs +58 -0
  94. package/dist/lib/esm/array.d.mts +46 -0
  95. package/dist/lib/esm/array.mjs +93 -0
  96. package/dist/lib/esm/async-events.d.mts +456 -0
  97. package/dist/lib/esm/async-events.mjs +427 -0
  98. package/dist/lib/esm/async-operation-hook.d.mts +59 -0
  99. package/dist/lib/esm/async-operation-hook.mjs +71 -0
  100. package/dist/lib/esm/async.d.mts +414 -0
  101. package/dist/lib/esm/async.mjs +479 -0
  102. package/dist/lib/esm/beeper.d.mts +21 -0
  103. package/dist/lib/esm/beeper.mjs +88 -0
  104. package/dist/lib/esm/blob.d.mts +59 -0
  105. package/dist/lib/esm/blob.mjs +121 -0
  106. package/dist/lib/esm/bytes.d.mts +17 -0
  107. package/dist/lib/esm/bytes.mjs +76 -0
  108. package/dist/lib/esm/debug-controller.d.mts +87 -0
  109. package/dist/lib/esm/debug-controller.mjs +50 -0
  110. package/dist/lib/esm/debug.d.mts +66 -0
  111. package/dist/lib/esm/debug.mjs +185 -0
  112. package/dist/lib/esm/desktop-zip-extractor.d.mts +95 -0
  113. package/dist/lib/esm/desktop-zip-extractor.mjs +180 -0
  114. package/dist/lib/esm/disposable.d.mts +387 -0
  115. package/dist/lib/esm/disposable.mjs +360 -0
  116. package/dist/lib/esm/enum.d.mts +24 -0
  117. package/dist/lib/esm/enum.mjs +61 -0
  118. package/dist/lib/esm/error.d.mts +181 -0
  119. package/dist/lib/esm/error.mjs +248 -0
  120. package/dist/lib/esm/function.d.mts +128 -0
  121. package/dist/lib/esm/function.mjs +96 -0
  122. package/dist/lib/esm/html-element.d.mts +199 -0
  123. package/dist/lib/esm/html-element.mjs +291 -0
  124. package/dist/lib/esm/index.d.mts +33 -0
  125. package/dist/lib/esm/index.mjs +116 -0
  126. package/dist/lib/esm/jpeg-metadata.d.mts +42 -0
  127. package/dist/lib/esm/jpeg-metadata.mjs +189 -0
  128. package/dist/lib/esm/library.d.mts +96 -0
  129. package/dist/lib/esm/library.mjs +118 -0
  130. package/dist/lib/esm/object-utils.d.mts +298 -0
  131. package/dist/lib/esm/object-utils.mjs +567 -0
  132. package/dist/lib/esm/path.d.mts +154 -0
  133. package/dist/lib/esm/path.mjs +139 -0
  134. package/dist/lib/esm/reg-exp.d.mts +87 -0
  135. package/dist/lib/esm/reg-exp.mjs +213 -0
  136. package/dist/lib/esm/string.d.mts +361 -0
  137. package/dist/lib/esm/string.mjs +274 -0
  138. package/dist/lib/esm/transformers/date-transformer.d.mts +39 -0
  139. package/dist/lib/esm/transformers/date-transformer.mjs +91 -0
  140. package/dist/lib/esm/transformers/group-transformer.d.mts +70 -0
  141. package/dist/lib/esm/transformers/group-transformer.mjs +138 -0
  142. package/dist/lib/esm/transformers/index.d.mts +9 -0
  143. package/dist/lib/esm/transformers/index.mjs +68 -0
  144. package/dist/lib/esm/transformers/map-transformer.d.mts +41 -0
  145. package/dist/lib/esm/transformers/map-transformer.mjs +91 -0
  146. package/dist/lib/esm/transformers/set-transformer.d.mts +39 -0
  147. package/dist/lib/esm/transformers/set-transformer.mjs +91 -0
  148. package/dist/lib/esm/transformers/skip-private-property-transformer.d.mts +36 -0
  149. package/dist/lib/esm/transformers/skip-private-property-transformer.mjs +89 -0
  150. package/dist/lib/esm/transformers/transformer.d.mts +70 -0
  151. package/dist/lib/esm/transformers/transformer.mjs +132 -0
  152. package/dist/lib/esm/transformers/two-way-map-transformer.d.mts +42 -0
  153. package/dist/lib/esm/transformers/two-way-map-transformer.mjs +92 -0
  154. package/dist/lib/esm/transformers/typed-transformer.d.mts +39 -0
  155. package/dist/lib/esm/transformers/typed-transformer.mjs +56 -0
  156. package/dist/lib/esm/two-way-map.d.mts +101 -0
  157. package/dist/lib/esm/two-way-map.mjs +170 -0
  158. package/dist/lib/esm/type-guards.d.mts +84 -0
  159. package/dist/lib/esm/type-guards.mjs +85 -0
  160. package/dist/lib/esm/type.d.mts +122 -0
  161. package/dist/lib/esm/type.mjs +83 -0
  162. package/dist/lib/esm/typescript-lib-state.d.mts +56 -0
  163. package/dist/lib/esm/typescript-lib-state.mjs +84 -0
  164. package/dist/lib/esm/url.d.mts +74 -0
  165. package/dist/lib/esm/url.mjs +94 -0
  166. package/dist/lib/esm/value-provider.d.mts +28 -0
  167. package/dist/lib/esm/value-provider.mjs +62 -0
  168. package/dist/lib/esm/value-wrapper.d.mts +47 -0
  169. package/dist/lib/esm/value-wrapper.mjs +106 -0
  170. package/package.json +111 -13
  171. package/transformers/date-transformer/package.json +6 -0
  172. package/transformers/group-transformer/package.json +6 -0
  173. package/transformers/index/package.json +6 -0
  174. package/transformers/map-transformer/package.json +6 -0
  175. package/transformers/package.json +6 -0
  176. package/transformers/set-transformer/package.json +6 -0
  177. package/transformers/skip-private-property-transformer/package.json +6 -0
  178. package/transformers/transformer/package.json +6 -0
  179. package/transformers/two-way-map-transformer/package.json +6 -0
  180. package/transformers/typed-transformer/package.json +6 -0
@@ -0,0 +1,298 @@
1
+ /// <reference path="./library.d.cts" />
2
+ /**
3
+ * @file
4
+ *
5
+ * Contains utility functions for Objects.
6
+ */
7
+ import type { RequiredKeysOf, UndefinedOnPartialDeep } from 'type-fest' with { 'resolution-mode': 'import' };
8
+ import type { GenericObject } from './type-guards.cjs';
9
+ import type { ExactMembers, StringKeys } from './type.cjs';
10
+ /**
11
+ * Specifies how functions should be handled in the JSON output.
12
+ */
13
+ export declare enum FunctionHandlingMode {
14
+ /**
15
+ * Excludes functions from the JSON output.
16
+ */
17
+ Exclude = "exclude",
18
+ /**
19
+ * Includes the full function definition in the JSON output.
20
+ */
21
+ Full = "full",
22
+ /**
23
+ * Includes only the function name in the JSON output.
24
+ */
25
+ NameOnly = "nameOnly"
26
+ }
27
+ /**
28
+ * Options for {@link toJson}.
29
+ */
30
+ export interface ToJsonOptions {
31
+ /**
32
+ * Specifies how functions should be handled in the JSON output.
33
+ *
34
+ * @default {@link FunctionHandlingMode.Exclude}
35
+ */
36
+ readonly functionHandlingMode: FunctionHandlingMode;
37
+ /**
38
+ * Specifies the maximum depth of nested objects to include in the JSON output.
39
+ * Use `-1` for no limit.
40
+ *
41
+ * @default `-1`
42
+ */
43
+ readonly maxDepth: number;
44
+ /**
45
+ * Specifies whether to catch errors in `toJSON()` and replace them with a placeholder.
46
+ *
47
+ * @default `false`
48
+ */
49
+ readonly shouldCatchToJSONErrors: boolean;
50
+ /**
51
+ * Specifies whether to handle circular references in the JSON output.
52
+ *
53
+ * @default `false`
54
+ */
55
+ readonly shouldHandleCircularReferences: boolean;
56
+ /**
57
+ * Specifies whether to handle errors in the JSON output.
58
+ *
59
+ * @default `false`
60
+ */
61
+ readonly shouldHandleErrors: boolean;
62
+ /**
63
+ * Specifies whether to handle `undefined` values in the JSON output.
64
+ *
65
+ * @default `false`
66
+ */
67
+ readonly shouldHandleUndefined: boolean;
68
+ /**
69
+ * Specifies whether to sort the keys of the JSON output.
70
+ *
71
+ * @default `false`
72
+ */
73
+ readonly shouldSortKeys: boolean;
74
+ /**
75
+ * Specifies the indentation of the JSON output. This can be a number of spaces or a string.
76
+ *
77
+ * @default `2`
78
+ */
79
+ readonly space: number | string;
80
+ /**
81
+ * Specifies the substitutions to use in the JSON output.
82
+ */
83
+ readonly tokenSubstitutions: Partial<TokenSubstitutions>;
84
+ }
85
+ interface ModuleWithDefaultExport<T> {
86
+ default: T;
87
+ }
88
+ interface TokenSubstitutions {
89
+ circularReference: string;
90
+ maxDepthLimitReached: string;
91
+ toJSONFailed: string;
92
+ }
93
+ /**
94
+ * Parameters for {@link setNestedPropertyValue}.
95
+ */
96
+ export interface SetNestedPropertyValueParams {
97
+ /**
98
+ * The object to set the nested property value in.
99
+ */
100
+ readonly $object: GenericObject;
101
+ /**
102
+ * The path to the nested property.
103
+ */
104
+ readonly path: string;
105
+ /**
106
+ * The value to set.
107
+ */
108
+ readonly value: unknown;
109
+ }
110
+ type KeysWithUndefined<T> = KeysWithUndefinedMap<T>[keyof T];
111
+ type KeysWithUndefinedMap<T> = {
112
+ [K in keyof T]-?: undefined extends T[K] ? K : never;
113
+ };
114
+ type MandatoryKeysWithUndefined<T extends object> = Extract<RequiredKeysOf<T> & StringKeys<T>, KeysWithUndefined<T>>;
115
+ type RemoveUndefinedOverload<T extends object> = MandatoryKeysWithUndefined<T> extends never ? [obj: T] : never;
116
+ type RemoveUndefinedWithKeysOverload<T extends object, K extends readonly string[]> = [obj: T, keysToKeep: ExactMembers<MandatoryKeysWithUndefined<T>, K>];
117
+ /**
118
+ * Assigns properties from one or more source objects to a target object, including non-enumerable properties.
119
+ *
120
+ * @typeParam T - The target object type.
121
+ * @typeParam U - The source object type.
122
+ * @param target - The target object to assign properties to.
123
+ * @param source - The source object to assign properties from.
124
+ * @returns The target object with the assigned properties.
125
+ */
126
+ export declare function assignWithNonEnumerableProperties<T extends object, U>(target: T, source: U): T & U;
127
+ /**
128
+ * Assigns properties from one or more source objects to a target object, including non-enumerable properties.
129
+ *
130
+ * @typeParam T - The target object type.
131
+ * @typeParam U - The first source object type.
132
+ * @typeParam V - The second source object type.
133
+ * @param target - The target object to assign properties to.
134
+ * @param source1 - The first source object to assign properties from.
135
+ * @param source2 - The second source object to assign properties from.
136
+ * @returns The target object with the assigned properties.
137
+ */
138
+ export declare function assignWithNonEnumerableProperties<T extends object, U, V>(target: T, source1: U, source2: V): T & U & V;
139
+ /**
140
+ * Assigns properties from one or more source objects to a target object, including non-enumerable properties.
141
+ *
142
+ * @typeParam T - The target object type.
143
+ * @typeParam U - The first source object type.
144
+ * @typeParam V - The second source object type.
145
+ * @typeParam W - The third source object type.
146
+ * @param target - The target object to assign properties to.
147
+ * @param source1 - The first source object to assign properties from.
148
+ * @param source2 - The second source object to assign properties from.
149
+ * @param source3 - The third source object to assign properties from.
150
+ * @returns The target object with the assigned properties.
151
+ */
152
+ export declare function assignWithNonEnumerableProperties<T extends object, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W;
153
+ /**
154
+ * Casts a value to a specific type.
155
+ *
156
+ * @typeParam T - The target type to cast to.
157
+ * @param value - The value to cast.
158
+ * @returns The value as the specified type.
159
+ */
160
+ export declare function castTo<T>(value: unknown): T;
161
+ /**
162
+ * Clones an object, including non-enumerable properties.
163
+ *
164
+ * @typeParam T - The type of the object.
165
+ * @param $object - The object to clone.
166
+ * @returns A new object with the same properties as the original object, including non-enumerable properties.
167
+ */
168
+ export declare function cloneWithNonEnumerableProperties<T extends object>($object: T): T;
169
+ /**
170
+ * Deletes multiple properties from an object.
171
+ *
172
+ * @typeParam T - The type of the object.
173
+ * @param $object - The object to delete the properties from.
174
+ * @param propertyNames - The names of the properties to delete.
175
+ * @returns `true` if any of the properties were present, otherwise `false`.
176
+ */
177
+ export declare function deleteProperties<T extends object>($object: T, propertyNames: (keyof T)[]): boolean;
178
+ /**
179
+ * Deletes a property from an object.
180
+ *
181
+ * @typeParam T - The type of the object.
182
+ * @param $object - The object to delete the property from.
183
+ * @param propertyName - The name of the property to delete.
184
+ * @returns `true` if the property was present, otherwise `false`.
185
+ */
186
+ export declare function deleteProperty<T extends object>($object: T, propertyName: keyof T): boolean;
187
+ /**
188
+ * Extracts the default export from a module.
189
+ *
190
+ * Useful to handle incorrect default export interop between ESM and CJS.
191
+ *
192
+ * @typeParam T - The type of the default export.
193
+ * @param module - The module to extract the default export from.
194
+ * @returns The default export.
195
+ */
196
+ export declare function extractDefaultExportInterop<T>(module: ModuleWithDefaultExport<T> | T): T;
197
+ /**
198
+ * Gets all entries of an object.
199
+ *
200
+ * @typeParam T - The type of the object.
201
+ * @param $object - The object to get the entries of.
202
+ * @returns An array of all entries of the object.
203
+ */
204
+ export declare function getAllEntries<T extends object>($object: T): [StringKeys<T>, T[StringKeys<T>]][];
205
+ /**
206
+ * Gets all keys of an object.
207
+ * Includes fields and properties.
208
+ *
209
+ * @typeParam T - The type of the object.
210
+ * @param $object - The object to get the keys of.
211
+ * @returns An array of all keys of the object.
212
+ */
213
+ export declare function getAllKeys<T extends object>($object: T): StringKeys<T>[];
214
+ /**
215
+ * Gets the value of a nested property from an object.
216
+ *
217
+ * @param $object - The object to get the nested property value from.
218
+ * @param path - The path to the nested property.
219
+ * @returns The value of the nested property.
220
+ */
221
+ export declare function getNestedPropertyValue($object: GenericObject, path: string): unknown;
222
+ /**
223
+ * Gets the prototype of the specified object.
224
+ *
225
+ * @typeParam T - The type of the object.
226
+ * @param instance - The object instance to retrieve the prototype of.
227
+ * @returns The prototype of the object.
228
+ */
229
+ export declare function getPrototypeOf<T>(instance: T): T;
230
+ /**
231
+ * Compares two values to determine if they are deeply equal.
232
+ *
233
+ * @param a - The first value to compare.
234
+ * @param b - The second value to compare.
235
+ * @returns `true` if the values are deeply equal, otherwise `false`.
236
+ */
237
+ export declare function isDeepEqual(a: unknown, b: unknown): boolean;
238
+ /**
239
+ * Retrieves the name of a property of a given type `T`.
240
+ *
241
+ * @typeParam T - The type of the object containing the property.
242
+ * @param name - The name of the property as a string.
243
+ * @returns The name of the property.
244
+ */
245
+ export declare function nameof<T extends object>(name: StringKeys<T>): StringKeys<T>;
246
+ /**
247
+ * Normalizes optional properties to allow `undefined` assignment in strict mode.
248
+ *
249
+ * This utility provides a workaround for the `exactOptionalPropertyTypes` TypeScript flag,
250
+ * which prohibits directly assigning `undefined` to optional properties when the type
251
+ * explicitly omits `undefined`.
252
+ *
253
+ * Example:
254
+ * ```typescript
255
+ * // With `exactOptionalPropertyTypes: true`
256
+ * const x: { prop?: string } = { prop: undefined }; // Compiler error
257
+ *
258
+ * // Using this utility:
259
+ * const y: { prop?: string } = normalizeOptionalProperties<{ prop?: string }>({ prop: undefined }); // Works
260
+ * ```
261
+ *
262
+ * @typeParam T - The target type with optional properties to normalize.
263
+ * @param $object - The object to normalize, allowing explicit `undefined` for optional properties.
264
+ * @returns The normalized object, compatible with `exactOptionalPropertyTypes`.
265
+ */
266
+ export declare function normalizeOptionalProperties<T>($object: UndefinedOnPartialDeep<T>): T;
267
+ /**
268
+ * Removes all `undefined` properties from an object when there are no mandatory keys with `undefined` values.
269
+ *
270
+ * @typeParam Type - The type of the object.
271
+ * @param $arguments - The arguments to the function.
272
+ * @returns The object with all `undefined` properties removed.
273
+ */
274
+ export declare function removeUndefinedProperties<Type extends object>(...$arguments: RemoveUndefinedOverload<Type>): Type;
275
+ /**
276
+ * Removes all `undefined` properties from an object when there are mandatory keys with `undefined` values.
277
+ *
278
+ * @typeParam Type - The type of the object.
279
+ * @typeParam KeysToKeep - The keys to keep.
280
+ * @param $arguments - The arguments to the function.
281
+ * @returns The object with all `undefined` properties removed.
282
+ */
283
+ export declare function removeUndefinedProperties<Type extends object, const KeysToKeep extends readonly string[]>(...$arguments: RemoveUndefinedWithKeysOverload<Type, KeysToKeep>): Type;
284
+ /**
285
+ * Sets the value of a nested property in an object.
286
+ *
287
+ * @param params - The parameters for setting the nested property value.
288
+ */
289
+ export declare function setNestedPropertyValue(params: SetNestedPropertyValueParams): void;
290
+ /**
291
+ * Converts a given value to a JSON string.
292
+ *
293
+ * @param value - The value to be converted to JSON. This can be of any type.
294
+ * @param options - Options for customizing the JSON conversion process.
295
+ * @returns The JSON string representation of the input value.
296
+ */
297
+ export declare function toJson(value: unknown, options?: Partial<ToJsonOptions>): string;
298
+ export {};
@@ -0,0 +1,202 @@
1
+ /*
2
+ THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
3
+ if you want to view the source, please visit the github repository of this plugin
4
+ */
5
+
6
+ (function () {
7
+ function ensureDisposeSymbols(symbolConstructor = Symbol) {
8
+ symbolConstructor.asyncDispose ??= symbolConstructor.for('Symbol.asyncDispose');
9
+ symbolConstructor.dispose ??= symbolConstructor.for('Symbol.dispose');
10
+ }
11
+
12
+ function ensureBrowserProcess() {
13
+ const browserProcess = {
14
+ browser: true,
15
+ cwd() {
16
+ return '/';
17
+ },
18
+ env: {},
19
+ platform: 'android'
20
+ };
21
+
22
+ // eslint-disable-next-line obsidianmd/no-global-this, unicorn/no-unnecessary-global-this -- Must stay `globalThis`-qualified: in the emitted banner a bare `process` is a free identifier, so reading it where the host has none throws a ReferenceError instead of yielding `undefined`. That is the very case this function exists to handle.
23
+ const existingProcess = globalThis.process;
24
+
25
+ if (!existingProcess) {
26
+ // eslint-disable-next-line obsidianmd/no-global-this -- Actively use globalThis.
27
+ globalThis.process = browserProcess;
28
+ return;
29
+ }
30
+
31
+ if (existingProcess.versions?.node) {
32
+ return;
33
+ }
34
+
35
+ const existingProcessRecord = existingProcess;
36
+
37
+ for (const [key, value] of Object.entries(browserProcess)) {
38
+ existingProcessRecord[key] ??= value;
39
+ }
40
+
41
+ existingProcessRecord['browser'] = true;
42
+ }
43
+
44
+ function keepName($unknown) {
45
+ return $unknown;
46
+ }
47
+
48
+ (function initCjs() {
49
+ // eslint-disable-next-line obsidianmd/no-global-this -- Actively use globalThis.
50
+ const globalThisRecord = globalThis;
51
+ ensureDisposeSymbols();
52
+ globalThisRecord['__name'] ??= keepName;
53
+ globalThisRecord['__extractDefault'] ??= extractDefault;
54
+
55
+ ensureBrowserProcess();
56
+
57
+ // eslint-disable-next-line unicorn/consistent-function-scoping -- Serialized with initCjs into the banner; at module scope it would be left out of it.
58
+ function extractDefault(module) {
59
+ return module && module.__esModule && 'default' in module ? module.default : module;
60
+ }
61
+ })();
62
+ })();
63
+
64
+ "use strict";
65
+ var __create = Object.create;
66
+ var __defProp = Object.defineProperty;
67
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
68
+ var __getOwnPropNames = Object.getOwnPropertyNames;
69
+ var __getProtoOf = Object.getPrototypeOf;
70
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
71
+ var __export = (target, all) => {
72
+ for (var name in all)
73
+ __defProp(target, name, { get: all[name], enumerable: true });
74
+ };
75
+ var __copyProps = (to, from, except, desc) => {
76
+ if (from && typeof from === "object" || typeof from === "function") {
77
+ for (let key of __getOwnPropNames(from))
78
+ if (!__hasOwnProp.call(to, key) && key !== except)
79
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
80
+ }
81
+ return to;
82
+ };
83
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
84
+ // If the importer is in node compatibility mode or this is not an ESM
85
+ // file that has been converted to a CommonJS file using a Babel-
86
+ // compatible transform (i.e. "__esModule" has not been set), then set
87
+ // "default" to the CommonJS "module.exports" for node compatibility.
88
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
89
+ mod
90
+ ));
91
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
92
+ var path_exports = {};
93
+ __export(path_exports, {
94
+ basename: () => basename,
95
+ delimiter: () => delimiter,
96
+ dirname: () => dirname,
97
+ extname: () => extname,
98
+ format: () => format,
99
+ getFileName: () => getFileName,
100
+ getFolderName: () => getFolderName,
101
+ isAbsolute: () => isAbsolute,
102
+ join: () => join,
103
+ makeFileName: () => makeFileName,
104
+ normalizeIfRelative: () => normalizeIfRelative,
105
+ normalizePath: () => normalizePath,
106
+ parse: () => parse,
107
+ posix: () => posix,
108
+ relative: () => relative,
109
+ resolve: () => resolve,
110
+ separator: () => separator,
111
+ toPosixBuffer: () => toPosixBuffer,
112
+ toPosixPath: () => toPosixPath
113
+ });
114
+ module.exports = __toCommonJS(path_exports);
115
+ var import_path_browserify = __toESM(__extractDefault(require('path-browserify')), 1);
116
+ var import_string = require('./string.cjs');
117
+ const WINDOWS_DRIVE_REG_EXP = /^[a-zA-Z]:\//;
118
+ const WINDOWS_POSIX_LIKE_PATH_REG_EXP = /[a-zA-Z]:\/[^:]*$/;
119
+ const posix = import_path_browserify.default.posix;
120
+ const delimiter = posix.delimiter;
121
+ const separator = import_path_browserify.default.posix.sep;
122
+ const basename = posix.basename;
123
+ const dirname = posix.dirname;
124
+ const extname = posix.extname;
125
+ const format = posix.format;
126
+ function isAbsolute(path) {
127
+ return posix.isAbsolute(path) || WINDOWS_POSIX_LIKE_PATH_REG_EXP.exec(path)?.[0] === path;
128
+ }
129
+ const join = posix.join;
130
+ const normalizePath = posix.normalize;
131
+ const parse = posix.parse;
132
+ function getFileName(importMetaUrl) {
133
+ return resolve(decodeURI(new URL(importMetaUrl).pathname));
134
+ }
135
+ function getFolderName(importMetaUrl) {
136
+ return dirname(getFileName(importMetaUrl));
137
+ }
138
+ function makeFileName(params) {
139
+ return params.fileExtension ? `${params.fileBaseName}.${params.fileExtension}` : params.fileBaseName;
140
+ }
141
+ function normalizeIfRelative(path) {
142
+ return path.startsWith("/") || path.includes(":") ? path : (0, import_string.ensureStartsWith)({
143
+ $string: path,
144
+ prefix: "./"
145
+ });
146
+ }
147
+ function relative(from, to) {
148
+ const resolvedFrom = resolve(from);
149
+ const resolvedTo = resolve(to);
150
+ const fromDrive = WINDOWS_DRIVE_REG_EXP.exec(resolvedFrom)?.[0].toUpperCase();
151
+ const toDrive = WINDOWS_DRIVE_REG_EXP.exec(resolvedTo)?.[0].toUpperCase();
152
+ return fromDrive === toDrive ? posix.relative(toRootedPosixPath(upperCaseDrive(resolvedFrom)), toRootedPosixPath(upperCaseDrive(resolvedTo))) : resolvedTo;
153
+ }
154
+ function resolve(...pathSegments) {
155
+ const rootedSegments = pathSegments.map((segment) => toRootedPosixPath(segment));
156
+ if (rootedSegments.every((segment) => !segment.startsWith("/"))) {
157
+ rootedSegments.unshift(toRootedPosixPath(process.cwd()));
158
+ }
159
+ const path = posix.resolve(...rootedSegments);
160
+ const match = WINDOWS_POSIX_LIKE_PATH_REG_EXP.exec(path);
161
+ return match?.[0] ?? path;
162
+ }
163
+ function toPosixBuffer(buffer) {
164
+ return Buffer.from(toPosixPath(String(buffer)));
165
+ }
166
+ function toPosixPath(path) {
167
+ return (0, import_string.replaceAll)({
168
+ $string: path,
169
+ replacer: "/",
170
+ searchValue: "\\"
171
+ });
172
+ }
173
+ function toRootedPosixPath(path) {
174
+ const posixPath = toPosixPath(path);
175
+ return WINDOWS_DRIVE_REG_EXP.test(posixPath) ? `/${posixPath}` : posixPath;
176
+ }
177
+ function upperCaseDrive(path) {
178
+ return path.replace(WINDOWS_DRIVE_REG_EXP, (drive) => drive.toUpperCase());
179
+ }
180
+ // Annotate the CommonJS export names for ESM import in node:
181
+ 0 && (module.exports = {
182
+ basename,
183
+ delimiter,
184
+ dirname,
185
+ extname,
186
+ format,
187
+ getFileName,
188
+ getFolderName,
189
+ isAbsolute,
190
+ join,
191
+ makeFileName,
192
+ normalizeIfRelative,
193
+ normalizePath,
194
+ parse,
195
+ posix,
196
+ relative,
197
+ resolve,
198
+ separator,
199
+ toPosixBuffer,
200
+ toPosixPath
201
+ });
202
+ //# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vLi4vLi4vc3JjL3BhdGgudHMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbIi8qKlxuICogQGZpbGVcbiAqXG4gKiBDb250YWlucyB1dGlsaXR5IGZ1bmN0aW9ucyBmb3IgaGFuZGxpbmcgcGF0aHMuXG4gKi9cblxuaW1wb3J0IHBhdGhCcm93c2VyaWZ5IGZyb20gJ3BhdGgtYnJvd3NlcmlmeSc7XG5cbmltcG9ydCB7XG4gIGVuc3VyZVN0YXJ0c1dpdGgsXG4gIHJlcGxhY2VBbGxcbn0gZnJvbSAnLi9zdHJpbmcudHMnO1xuXG5jb25zdCBXSU5ET1dTX0RSSVZFX1JFR19FWFAgPSAvXlthLXpBLVpdOlxcLy87XG5jb25zdCBXSU5ET1dTX1BPU0lYX0xJS0VfUEFUSF9SRUdfRVhQID0gL1thLXpBLVpdOlxcL1teOl0qJC87XG5cbi8qKlxuICogUHJvdmlkZXMgbWV0aG9kcyBmb3IgaGFuZGxpbmcgUE9TSVggcGF0aHMuXG4gKi9cbmV4cG9ydCBjb25zdCBwb3NpeCA9IHBhdGhCcm93c2VyaWZ5LnBvc2l4O1xuXG4vKipcbiAqIEEgUE9TSVggcGF0aCBkZWxpbWl0ZXIuXG4gKi9cbmV4cG9ydCBjb25zdCBkZWxpbWl0ZXIgPSBwb3NpeC5kZWxpbWl0ZXI7XG5cbi8qKlxuICogQSBQT1NJWCBzZWdtZW50IHNlcGFyYXRvci5cbiAqL1xuZXhwb3J0IGNvbnN0IHNlcGFyYXRvciA9IHBhdGhCcm93c2VyaWZ5LnBvc2l4LnNlcDtcblxuLyoqXG4gKiBSZXR1cm5zIHRoZSBiYXNlIG5hbWUgb2YgYSBmaWxlLCBvcHRpb25hbGx5IHJlbW92aW5nIHRoZSBmaWxlI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+ import pathBrowserify from 'path-browserify';
8
+ /**
9
+ * Provides methods for handling POSIX paths.
10
+ */
11
+ export declare const posix: pathBrowserify.Path;
12
+ /**
13
+ * A POSIX path delimiter.
14
+ */
15
+ export declare const delimiter: string;
16
+ /**
17
+ * A POSIX segment separator.
18
+ */
19
+ export declare const separator: string;
20
+ /**
21
+ * Returns the base name of a file, optionally removing the file extension.
22
+ *
23
+ * @param path - The path to get the base name from.
24
+ * @param ext - An optional extension to remove from the base name.
25
+ * @returns The base name of the file.
26
+ */
27
+ export declare const basename: (this: void, path: string, ext?: string) => string;
28
+ /**
29
+ * Returns the directory name of a path.
30
+ *
31
+ * `directory` is used instead of `folder` to preserve compatibility with `node:path` module.
32
+ *
33
+ * @param path - The path to get the directory name from.
34
+ * @returns The directory name of the path.
35
+ */
36
+ export declare const dirname: (this: void, path: string) => string;
37
+ /**
38
+ * Returns the file extension of a path.
39
+ *
40
+ * @param path - The path to get the extension from.
41
+ * @returns The file extension of the path.
42
+ */
43
+ export declare const extname: (this: void, path: string) => string;
44
+ /**
45
+ * Formats a path object into a path string.
46
+ *
47
+ * @param pathObject - The path object to format.
48
+ * @returns The formatted path string.
49
+ */
50
+ export declare const format: (this: void, pathObject: Partial<pathBrowserify.PathObject>) => string;
51
+ /**
52
+ * Determines if a path is absolute.
53
+ *
54
+ * @param path - The path to check.
55
+ * @returns `true` if the path is absolute, `false` otherwise.
56
+ */
57
+ export declare function isAbsolute(path: string): boolean;
58
+ /**
59
+ * Joins multiple path segments into a single path.
60
+ *
61
+ * @param paths - The path segments to join.
62
+ * @returns The joined path.
63
+ */
64
+ export declare const join: (this: void, ...paths: string[]) => string;
65
+ /**
66
+ * Normalizes a path, resolving '..' and '.' segments.
67
+ *
68
+ * @param path - The path to normalize.
69
+ * @returns The normalized path.
70
+ */
71
+ export declare const normalizePath: (this: void, path: string) => string;
72
+ /**
73
+ * Parses a path string into a path object.
74
+ *
75
+ * @param path - The path string to parse.
76
+ * @returns The parsed path object.
77
+ */
78
+ export declare const parse: (this: void, path: string) => pathBrowserify.PathObject;
79
+ /**
80
+ * Parameters for {@link makeFileName}.
81
+ */
82
+ export interface MakeFileNameParams {
83
+ /**
84
+ * The file name to append the extension to.
85
+ */
86
+ readonly fileBaseName: string;
87
+ /**
88
+ * The extension to append to the file name.
89
+ */
90
+ readonly fileExtension: string;
91
+ }
92
+ /**
93
+ * Gets the file name from the `import(dot)meta(dot)url`, converting it to a POSIX-style path.
94
+ *
95
+ * @param importMetaUrl - The `import(dot)meta(dot)url` from which to extract the file name.
96
+ * @returns The POSIX-style file name.
97
+ */
98
+ export declare function getFileName(importMetaUrl: string): string;
99
+ /**
100
+ * Gets the folder name from the `import(dot)meta(dot)url`, converting it to a POSIX-style path.
101
+ *
102
+ * @param importMetaUrl - The `import(dot)meta(dot)url` from which to extract the folder name.
103
+ * @returns The POSIX-style folder name.
104
+ */
105
+ export declare function getFolderName(importMetaUrl: string): string;
106
+ /**
107
+ * Makes a file name by appending an extension to a given file name.
108
+ * If the extension is empty, the file name is returned as is.
109
+ *
110
+ * @param params - The parameters for making the file name.
111
+ * @returns The file name with the extension appended.
112
+ */
113
+ export declare function makeFileName(params: MakeFileNameParams): string;
114
+ /**
115
+ * Normalizes a given path by ensuring it is relative, adding "./" if necessary.
116
+ *
117
+ * @param path - The path to normalize.
118
+ * @returns The normalized path, starting with "./" if it was relative.
119
+ */
120
+ export declare function normalizeIfRelative(path: string): string;
121
+ /**
122
+ * Returns the relative path from one path to another.
123
+ *
124
+ * `path-browserify`'s own `relative` cannot be used directly: it resolves a relative argument against
125
+ * `process.cwd()`, which on Windows is `F:\...` rather than a POSIX absolute path, and its slicing then assumes a
126
+ * leading `/` - so `relative('src', '../x')` came back as `'../..x'`. Both arguments are resolved through
127
+ * {@link resolve} here instead, and rooted at `/` before the POSIX comparison.
128
+ *
129
+ * @param from - The starting path.
130
+ * @param to - The destination path.
131
+ * @returns The relative path from `from` to `to`.
132
+ */
133
+ export declare function relative(from: string, to: string): string;
134
+ /**
135
+ * Resolves a sequence of paths or path segments into an absolute path.
136
+ *
137
+ * @param pathSegments - The sequence of path segments to resolve.
138
+ * @returns The resolved absolute path.
139
+ */
140
+ export declare function resolve(...pathSegments: string[]): string;
141
+ /**
142
+ * Converts a buffer containing a path to a POSIX-style buffer by replacing backslashes with forward slashes.
143
+ *
144
+ * @param buffer - The buffer to convert.
145
+ * @returns A new buffer containing the POSIX-style path.
146
+ */
147
+ export declare function toPosixBuffer(buffer: Buffer): Buffer;
148
+ /**
149
+ * Converts a given path to a POSIX-style path by replacing backslashes with forward slashes.
150
+ *
151
+ * @param path - The path to convert.
152
+ * @returns The POSIX-style path.
153
+ */
154
+ export declare function toPosixPath(path: string): string;