@mnaoumov/typescript-lib 0.0.0 → 1.0.1

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 (182) hide show
  1. package/@types/debug/package.json +4 -0
  2. package/LICENSE +21 -0
  3. package/README.md +15 -1
  4. package/dist/lib/cjs/@types/debug.d.cts +21 -0
  5. package/dist/lib/cjs/abort-controller.cjs +144 -0
  6. package/dist/lib/cjs/abort-controller.d.cts +136 -0
  7. package/dist/lib/cjs/aggregate-error.cjs +40 -0
  8. package/dist/lib/cjs/aggregate-error.d.cts +24 -0
  9. package/dist/lib/cjs/array-buffer.cjs +38 -0
  10. package/dist/lib/cjs/array-buffer.d.cts +16 -0
  11. package/dist/lib/cjs/array.cjs +76 -0
  12. package/dist/lib/cjs/array.d.cts +46 -0
  13. package/dist/lib/cjs/async-events.cjs +408 -0
  14. package/dist/lib/cjs/async-events.d.cts +456 -0
  15. package/dist/lib/cjs/async-operation-hook.cjs +55 -0
  16. package/dist/lib/cjs/async-operation-hook.d.cts +59 -0
  17. package/dist/lib/cjs/async.cjs +463 -0
  18. package/dist/lib/cjs/async.d.cts +415 -0
  19. package/dist/lib/cjs/beeper.cjs +68 -0
  20. package/dist/lib/cjs/beeper.d.cts +21 -0
  21. package/dist/lib/cjs/blob.cjs +102 -0
  22. package/dist/lib/cjs/blob.d.cts +60 -0
  23. package/dist/lib/cjs/bytes.cjs +56 -0
  24. package/dist/lib/cjs/bytes.d.cts +17 -0
  25. package/dist/lib/cjs/debug-controller.cjs +22 -0
  26. package/dist/lib/cjs/debug-controller.d.cts +87 -0
  27. package/dist/lib/cjs/debug.cjs +204 -0
  28. package/dist/lib/cjs/debug.d.cts +66 -0
  29. package/dist/lib/cjs/desktop-zip-extractor.cjs +157 -0
  30. package/dist/lib/cjs/desktop-zip-extractor.d.cts +96 -0
  31. package/dist/lib/cjs/disposable.cjs +364 -0
  32. package/dist/lib/cjs/disposable.d.cts +387 -0
  33. package/dist/lib/cjs/enum.cjs +42 -0
  34. package/dist/lib/cjs/enum.d.cts +24 -0
  35. package/dist/lib/cjs/error.cjs +239 -0
  36. package/dist/lib/cjs/error.d.cts +182 -0
  37. package/dist/lib/cjs/function.cjs +83 -0
  38. package/dist/lib/cjs/function.d.cts +128 -0
  39. package/dist/lib/cjs/html-element.cjs +283 -0
  40. package/dist/lib/cjs/html-element.d.cts +200 -0
  41. package/dist/lib/cjs/index.cjs +137 -0
  42. package/dist/lib/cjs/index.d.cts +33 -0
  43. package/dist/lib/cjs/jpeg-metadata.cjs +170 -0
  44. package/dist/lib/cjs/jpeg-metadata.d.cts +42 -0
  45. package/dist/lib/cjs/library-references.d.cts +2 -0
  46. package/dist/lib/cjs/library.cjs +100 -0
  47. package/dist/lib/cjs/library.d.cts +96 -0
  48. package/dist/lib/cjs/object-utils.cjs +559 -0
  49. package/dist/lib/cjs/object-utils.d.cts +298 -0
  50. package/dist/lib/cjs/path.cjs +171 -0
  51. package/dist/lib/cjs/path.d.cts +155 -0
  52. package/dist/lib/cjs/reg-exp.cjs +196 -0
  53. package/dist/lib/cjs/reg-exp.d.cts +87 -0
  54. package/dist/lib/cjs/string.cjs +268 -0
  55. package/dist/lib/cjs/string.d.cts +362 -0
  56. package/dist/lib/cjs/transformers/date-transformer.cjs +71 -0
  57. package/dist/lib/cjs/transformers/date-transformer.d.cts +39 -0
  58. package/dist/lib/cjs/transformers/group-transformer.cjs +115 -0
  59. package/dist/lib/cjs/transformers/group-transformer.d.cts +70 -0
  60. package/dist/lib/cjs/transformers/index.cjs +65 -0
  61. package/dist/lib/cjs/transformers/index.d.cts +9 -0
  62. package/dist/lib/cjs/transformers/map-transformer.cjs +71 -0
  63. package/dist/lib/cjs/transformers/map-transformer.d.cts +41 -0
  64. package/dist/lib/cjs/transformers/set-transformer.cjs +71 -0
  65. package/dist/lib/cjs/transformers/set-transformer.d.cts +39 -0
  66. package/dist/lib/cjs/transformers/skip-private-property-transformer.cjs +69 -0
  67. package/dist/lib/cjs/transformers/skip-private-property-transformer.d.cts +36 -0
  68. package/dist/lib/cjs/transformers/transformer.cjs +112 -0
  69. package/dist/lib/cjs/transformers/transformer.d.cts +70 -0
  70. package/dist/lib/cjs/transformers/two-way-map-transformer.cjs +72 -0
  71. package/dist/lib/cjs/transformers/two-way-map-transformer.d.cts +42 -0
  72. package/dist/lib/cjs/transformers/typed-transformer.cjs +36 -0
  73. package/dist/lib/cjs/transformers/typed-transformer.d.cts +39 -0
  74. package/dist/lib/cjs/two-way-map.cjs +150 -0
  75. package/dist/lib/cjs/two-way-map.d.cts +101 -0
  76. package/dist/lib/cjs/type-guards.cjs +70 -0
  77. package/dist/lib/cjs/type-guards.d.cts +84 -0
  78. package/dist/lib/cjs/type.cjs +63 -0
  79. package/dist/lib/cjs/type.d.cts +122 -0
  80. package/dist/lib/cjs/typescript-lib-state.cjs +68 -0
  81. package/dist/lib/cjs/typescript-lib-state.d.cts +56 -0
  82. package/dist/lib/cjs/url.cjs +78 -0
  83. package/dist/lib/cjs/url.d.cts +74 -0
  84. package/dist/lib/cjs/value-provider.cjs +42 -0
  85. package/dist/lib/cjs/value-provider.d.cts +29 -0
  86. package/dist/lib/cjs/value-wrapper.cjs +86 -0
  87. package/dist/lib/cjs/value-wrapper.d.cts +47 -0
  88. package/dist/lib/esm/@types/debug.d.mts +21 -0
  89. package/dist/lib/esm/abort-controller.d.mts +136 -0
  90. package/dist/lib/esm/abort-controller.mjs +115 -0
  91. package/dist/lib/esm/aggregate-error.d.mts +24 -0
  92. package/dist/lib/esm/aggregate-error.mjs +16 -0
  93. package/dist/lib/esm/array-buffer.d.mts +16 -0
  94. package/dist/lib/esm/array-buffer.mjs +14 -0
  95. package/dist/lib/esm/array.d.mts +46 -0
  96. package/dist/lib/esm/array.mjs +49 -0
  97. package/dist/lib/esm/async-events.d.mts +456 -0
  98. package/dist/lib/esm/async-events.mjs +383 -0
  99. package/dist/lib/esm/async-operation-hook.d.mts +59 -0
  100. package/dist/lib/esm/async-operation-hook.mjs +27 -0
  101. package/dist/lib/esm/async.d.mts +415 -0
  102. package/dist/lib/esm/async.mjs +435 -0
  103. package/dist/lib/esm/beeper.d.mts +21 -0
  104. package/dist/lib/esm/beeper.mjs +44 -0
  105. package/dist/lib/esm/blob.d.mts +60 -0
  106. package/dist/lib/esm/blob.mjs +77 -0
  107. package/dist/lib/esm/bytes.d.mts +17 -0
  108. package/dist/lib/esm/bytes.mjs +32 -0
  109. package/dist/lib/esm/debug-controller.d.mts +87 -0
  110. package/dist/lib/esm/debug-controller.mjs +6 -0
  111. package/dist/lib/esm/debug.d.mts +66 -0
  112. package/dist/lib/esm/debug.mjs +168 -0
  113. package/dist/lib/esm/desktop-zip-extractor.d.mts +96 -0
  114. package/dist/lib/esm/desktop-zip-extractor.mjs +136 -0
  115. package/dist/lib/esm/disposable.d.mts +387 -0
  116. package/dist/lib/esm/disposable.mjs +324 -0
  117. package/dist/lib/esm/enum.d.mts +24 -0
  118. package/dist/lib/esm/enum.mjs +17 -0
  119. package/dist/lib/esm/error.d.mts +182 -0
  120. package/dist/lib/esm/error.mjs +204 -0
  121. package/dist/lib/esm/function.d.mts +128 -0
  122. package/dist/lib/esm/function.mjs +52 -0
  123. package/dist/lib/esm/html-element.d.mts +200 -0
  124. package/dist/lib/esm/html-element.mjs +247 -0
  125. package/dist/lib/esm/index.d.mts +33 -0
  126. package/dist/lib/esm/index.mjs +72 -0
  127. package/dist/lib/esm/jpeg-metadata.d.mts +42 -0
  128. package/dist/lib/esm/jpeg-metadata.mjs +145 -0
  129. package/dist/lib/esm/library-references.d.mts +2 -0
  130. package/dist/lib/esm/library.d.mts +96 -0
  131. package/dist/lib/esm/library.mjs +74 -0
  132. package/dist/lib/esm/object-utils.d.mts +298 -0
  133. package/dist/lib/esm/object-utils.mjs +523 -0
  134. package/dist/lib/esm/path.d.mts +155 -0
  135. package/dist/lib/esm/path.mjs +122 -0
  136. package/dist/lib/esm/reg-exp.d.mts +87 -0
  137. package/dist/lib/esm/reg-exp.mjs +169 -0
  138. package/dist/lib/esm/string.d.mts +362 -0
  139. package/dist/lib/esm/string.mjs +230 -0
  140. package/dist/lib/esm/transformers/date-transformer.d.mts +39 -0
  141. package/dist/lib/esm/transformers/date-transformer.mjs +47 -0
  142. package/dist/lib/esm/transformers/group-transformer.d.mts +70 -0
  143. package/dist/lib/esm/transformers/group-transformer.mjs +94 -0
  144. package/dist/lib/esm/transformers/index.d.mts +9 -0
  145. package/dist/lib/esm/transformers/index.mjs +24 -0
  146. package/dist/lib/esm/transformers/map-transformer.d.mts +41 -0
  147. package/dist/lib/esm/transformers/map-transformer.mjs +47 -0
  148. package/dist/lib/esm/transformers/set-transformer.d.mts +39 -0
  149. package/dist/lib/esm/transformers/set-transformer.mjs +47 -0
  150. package/dist/lib/esm/transformers/skip-private-property-transformer.d.mts +36 -0
  151. package/dist/lib/esm/transformers/skip-private-property-transformer.mjs +45 -0
  152. package/dist/lib/esm/transformers/transformer.d.mts +70 -0
  153. package/dist/lib/esm/transformers/transformer.mjs +88 -0
  154. package/dist/lib/esm/transformers/two-way-map-transformer.d.mts +42 -0
  155. package/dist/lib/esm/transformers/two-way-map-transformer.mjs +48 -0
  156. package/dist/lib/esm/transformers/typed-transformer.d.mts +39 -0
  157. package/dist/lib/esm/transformers/typed-transformer.mjs +12 -0
  158. package/dist/lib/esm/two-way-map.d.mts +101 -0
  159. package/dist/lib/esm/two-way-map.mjs +126 -0
  160. package/dist/lib/esm/type-guards.d.mts +84 -0
  161. package/dist/lib/esm/type-guards.mjs +41 -0
  162. package/dist/lib/esm/type.d.mts +122 -0
  163. package/dist/lib/esm/type.mjs +39 -0
  164. package/dist/lib/esm/typescript-lib-state.d.mts +56 -0
  165. package/dist/lib/esm/typescript-lib-state.mjs +40 -0
  166. package/dist/lib/esm/url.d.mts +74 -0
  167. package/dist/lib/esm/url.mjs +50 -0
  168. package/dist/lib/esm/value-provider.d.mts +29 -0
  169. package/dist/lib/esm/value-provider.mjs +18 -0
  170. package/dist/lib/esm/value-wrapper.d.mts +47 -0
  171. package/dist/lib/esm/value-wrapper.mjs +62 -0
  172. package/package.json +153 -13
  173. package/transformers/date-transformer/package.json +6 -0
  174. package/transformers/group-transformer/package.json +6 -0
  175. package/transformers/index/package.json +6 -0
  176. package/transformers/map-transformer/package.json +6 -0
  177. package/transformers/package.json +6 -0
  178. package/transformers/set-transformer/package.json +6 -0
  179. package/transformers/skip-private-property-transformer/package.json +6 -0
  180. package/transformers/transformer/package.json +6 -0
  181. package/transformers/two-way-map-transformer/package.json +6 -0
  182. package/transformers/typed-transformer/package.json +6 -0
@@ -0,0 +1,96 @@
1
+ /// <reference lib="dom" />
2
+ /// <reference lib="dom.iterable" />
3
+ /// <reference lib="es2022" />
4
+ /// <reference lib="esnext.disposable" />
5
+ /// <reference types="node" />
6
+ /**
7
+ * @file
8
+ *
9
+ * Helpers for working with the `@mnaoumov/typescript-lib` library.
10
+ */
11
+ /**
12
+ * A name of the `@mnaoumov/typescript-lib` library.
13
+ */
14
+ export declare const LIBRARY_NAME = "@mnaoumov/typescript-lib";
15
+ /**
16
+ * The debug namespace the library's own debuggers live under until {@link Library.init} supplies another.
17
+ */
18
+ export declare const DEFAULT_DEBUG_NAMESPACE = "typescript-lib";
19
+ /**
20
+ * Parameters for {@link Library.init}.
21
+ *
22
+ * These are purely cosmetic values the host injects once at initialization, so the library itself carries
23
+ * no knowledge of who hosts it.
24
+ */
25
+ export interface LibraryInitParams {
26
+ /**
27
+ * The URL of the guide explaining how to turn debug messages on and off, named in the library's debug messages.
28
+ * Without one, the messages name no guide.
29
+ */
30
+ readonly debugGuideUrl?: string;
31
+ /**
32
+ * The namespace the library's own debuggers live under. Defaults to {@link DEFAULT_DEBUG_NAMESPACE}.
33
+ * A host that publishes its own debug namespace to its users passes it here, so their filters keep matching.
34
+ */
35
+ readonly debugNamespace?: string;
36
+ /**
37
+ * The namespace prefix prepended to the library's debug namespaces (e.g. `${pluginId}:`).
38
+ */
39
+ readonly debugPrefixNamespace: string;
40
+ /**
41
+ * Whether debug logging should append a rich DevTools stack trace.
42
+ */
43
+ readonly shouldPrintStackTrace: boolean;
44
+ }
45
+ /**
46
+ * The single, deterministic initialization entry point for the `@mnaoumov/typescript-lib` library.
47
+ *
48
+ * The host calls {@link Library.init} exactly once to push its cosmetic configuration; the library only
49
+ * reads it through the getters. Calling {@link Library.init} more than once throws —
50
+ * {@link Library.resetToDefault} clears the state (e.g. between tests, or on unload) and allows
51
+ * re-initialization.
52
+ */
53
+ declare class LibraryContext {
54
+ /**
55
+ * The URL of the guide explaining how to turn debug messages on and off. Empty until {@link init} is called with one.
56
+ *
57
+ * @returns The debug guide URL.
58
+ */
59
+ get debugGuideUrl(): string;
60
+ /**
61
+ * The namespace the library's own debuggers live under.
62
+ *
63
+ * @returns The debug namespace.
64
+ */
65
+ get debugNamespace(): string;
66
+ /**
67
+ * The namespace prefix prepended to the library's debug namespaces. Empty until {@link init} is called.
68
+ *
69
+ * @returns The debug namespace prefix.
70
+ */
71
+ get debugPrefixNamespace(): string;
72
+ /**
73
+ * Whether debug logging should append a rich DevTools stack trace. `false` until {@link init} is called.
74
+ *
75
+ * @returns Whether to print stack traces.
76
+ */
77
+ get shouldPrintStackTrace(): boolean;
78
+ private isInitialized;
79
+ private params;
80
+ /**
81
+ * Initializes the library with the host's cosmetic configuration. Must be called exactly once; calling it
82
+ * again before {@link resetToDefault} throws.
83
+ *
84
+ * @param params - The cosmetic configuration to inject.
85
+ */
86
+ init(params: LibraryInitParams): void;
87
+ /**
88
+ * Resets the library back to its default (uninitialized) state, allowing {@link init} to be called again.
89
+ */
90
+ resetToDefault(): void;
91
+ }
92
+ /**
93
+ * The single {@link LibraryContext} instance — the library's deterministic initialization entry point.
94
+ */
95
+ export declare const Library: LibraryContext;
96
+ export {};
@@ -0,0 +1,74 @@
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
+ const LIBRARY_NAME = "@mnaoumov/typescript-lib";
7
+ const DEFAULT_DEBUG_NAMESPACE = "typescript-lib";
8
+ const DEFAULT_PARAMS = {
9
+ debugPrefixNamespace: "",
10
+ shouldPrintStackTrace: false
11
+ };
12
+ class LibraryContext {
13
+ /**
14
+ * The URL of the guide explaining how to turn debug messages on and off. Empty until {@link init} is called with one.
15
+ *
16
+ * @returns The debug guide URL.
17
+ */
18
+ get debugGuideUrl() {
19
+ return this.params.debugGuideUrl ?? "";
20
+ }
21
+ /**
22
+ * The namespace the library's own debuggers live under.
23
+ *
24
+ * @returns The debug namespace.
25
+ */
26
+ get debugNamespace() {
27
+ return this.params.debugNamespace ?? DEFAULT_DEBUG_NAMESPACE;
28
+ }
29
+ /**
30
+ * The namespace prefix prepended to the library's debug namespaces. Empty until {@link init} is called.
31
+ *
32
+ * @returns The debug namespace prefix.
33
+ */
34
+ get debugPrefixNamespace() {
35
+ return this.params.debugPrefixNamespace;
36
+ }
37
+ /**
38
+ * Whether debug logging should append a rich DevTools stack trace. `false` until {@link init} is called.
39
+ *
40
+ * @returns Whether to print stack traces.
41
+ */
42
+ get shouldPrintStackTrace() {
43
+ return this.params.shouldPrintStackTrace;
44
+ }
45
+ isInitialized = false;
46
+ params = { ...DEFAULT_PARAMS };
47
+ /**
48
+ * Initializes the library with the host's cosmetic configuration. Must be called exactly once; calling it
49
+ * again before {@link resetToDefault} throws.
50
+ *
51
+ * @param params - The cosmetic configuration to inject.
52
+ */
53
+ init(params) {
54
+ if (this.isInitialized) {
55
+ throw new Error(`${LIBRARY_NAME} is already initialized. Call Library.resetToDefault() before initializing again.`);
56
+ }
57
+ this.isInitialized = true;
58
+ this.params = { ...params };
59
+ }
60
+ /**
61
+ * Resets the library back to its default (uninitialized) state, allowing {@link init} to be called again.
62
+ */
63
+ resetToDefault() {
64
+ this.isInitialized = false;
65
+ this.params = { ...DEFAULT_PARAMS };
66
+ }
67
+ }
68
+ const Library = new LibraryContext();
69
+ export {
70
+ DEFAULT_DEBUG_NAMESPACE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BLFNBQUssZ0JBQWdCO0FBQ3JCLFNBQUssU0FBUyxFQUFFLEdBQUcsT0FBTztBQUFBLEVBQzVCO0FBQUE7QUFBQTtBQUFBO0FBQUEsRUFLTyxpQkFBdUI7QUFDNUIsU0FBSyxnQkFBZ0I7QUFDckIsU0FBSyxTQUFTLEVBQUUsR0FBRyxlQUFlO0FBQUEsRUFDcEM7QUFDRjtBQUtPLE1BQU0sVUFBVSxJQUFJLGVBQWU7IiwKICAibmFtZXMiOiBbXQp9Cg==
@@ -0,0 +1,298 @@
1
+ /// <reference path="./library-references.d.mts" />
2
+ /**
3
+ * @file
4
+ *
5
+ * Contains utility functions for Objects.
6
+ */
7
+ import type { RequiredKeysOf, UndefinedOnPartialDeep } from 'type-fest';
8
+ import type { GenericObject } from './type-guards.mjs';
9
+ import type { ExactMembers, StringKeys } from './type.mjs';
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 {};