@pawells/typescript-common 1.0.1 → 1.1.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 (142) hide show
  1. package/README.md +177 -2
  2. package/build/array/array-chunk.d.ts +10 -4
  3. package/build/array/array-chunk.d.ts.map +1 -1
  4. package/build/array/array-chunk.js +10 -4
  5. package/build/array/array-chunk.js.map +1 -1
  6. package/build/array/array-contains.d.ts +11 -3
  7. package/build/array/array-contains.d.ts.map +1 -1
  8. package/build/array/array-contains.js +11 -3
  9. package/build/array/array-contains.js.map +1 -1
  10. package/build/array/array-group-by.d.ts +14 -5
  11. package/build/array/array-group-by.d.ts.map +1 -1
  12. package/build/array/array-group-by.js +14 -5
  13. package/build/array/array-group-by.js.map +1 -1
  14. package/build/array/array-shuffle.d.ts +12 -3
  15. package/build/array/array-shuffle.d.ts.map +1 -1
  16. package/build/array/array-shuffle.js +12 -3
  17. package/build/array/array-shuffle.js.map +1 -1
  18. package/build/array/assert.d.ts +115 -0
  19. package/build/array/assert.d.ts.map +1 -0
  20. package/build/array/assert.js +182 -0
  21. package/build/array/assert.js.map +1 -0
  22. package/build/array/index.d.ts +1 -0
  23. package/build/array/index.d.ts.map +1 -1
  24. package/build/array/index.js +1 -0
  25. package/build/array/index.js.map +1 -1
  26. package/build/array/unique.d.ts +13 -3
  27. package/build/array/unique.d.ts.map +1 -1
  28. package/build/array/unique.js +13 -3
  29. package/build/array/unique.js.map +1 -1
  30. package/build/asserts/errors.d.ts +129 -0
  31. package/build/asserts/errors.d.ts.map +1 -0
  32. package/build/asserts/errors.js +149 -0
  33. package/build/asserts/errors.js.map +1 -0
  34. package/build/asserts/generic.d.ts +436 -0
  35. package/build/asserts/generic.d.ts.map +1 -0
  36. package/build/asserts/generic.js +543 -0
  37. package/build/asserts/generic.js.map +1 -0
  38. package/build/asserts/index.d.ts +41 -0
  39. package/build/asserts/index.d.ts.map +1 -0
  40. package/build/asserts/index.js +41 -0
  41. package/build/asserts/index.js.map +1 -0
  42. package/build/asserts/internal-utils.d.ts +53 -0
  43. package/build/asserts/internal-utils.d.ts.map +1 -0
  44. package/build/asserts/internal-utils.js +108 -0
  45. package/build/asserts/internal-utils.js.map +1 -0
  46. package/build/asserts/types.d.ts +180 -0
  47. package/build/asserts/types.d.ts.map +1 -0
  48. package/build/asserts/types.js +2 -0
  49. package/build/asserts/types.js.map +1 -0
  50. package/build/asserts/utils.d.ts +92 -0
  51. package/build/asserts/utils.d.ts.map +1 -0
  52. package/build/asserts/utils.js +103 -0
  53. package/build/asserts/utils.js.map +1 -0
  54. package/build/boolean/assert.d.ts +66 -0
  55. package/build/boolean/assert.d.ts.map +1 -0
  56. package/build/boolean/assert.js +76 -0
  57. package/build/boolean/assert.js.map +1 -0
  58. package/build/boolean/index.d.ts +9 -0
  59. package/build/boolean/index.d.ts.map +1 -0
  60. package/build/boolean/index.js +9 -0
  61. package/build/boolean/index.js.map +1 -0
  62. package/build/enum/enum-entries.d.ts +8 -3
  63. package/build/enum/enum-entries.d.ts.map +1 -1
  64. package/build/enum/enum-entries.js +8 -3
  65. package/build/enum/enum-entries.js.map +1 -1
  66. package/build/enum/enum-key-by-value.d.ts +10 -5
  67. package/build/enum/enum-key-by-value.d.ts.map +1 -1
  68. package/build/enum/enum-key-by-value.js +10 -5
  69. package/build/enum/enum-key-by-value.js.map +1 -1
  70. package/build/enum/enum-keys.d.ts +12 -3
  71. package/build/enum/enum-keys.d.ts.map +1 -1
  72. package/build/enum/enum-keys.js +12 -3
  73. package/build/enum/enum-keys.js.map +1 -1
  74. package/build/enum/enum-safe-value.d.ts +11 -6
  75. package/build/enum/enum-safe-value.d.ts.map +1 -1
  76. package/build/enum/enum-safe-value.js +11 -6
  77. package/build/enum/enum-safe-value.js.map +1 -1
  78. package/build/enum/validate-enum-value.d.ts +10 -5
  79. package/build/enum/validate-enum-value.d.ts.map +1 -1
  80. package/build/enum/validate-enum-value.js +10 -5
  81. package/build/enum/validate-enum-value.js.map +1 -1
  82. package/build/index.d.ts +5 -0
  83. package/build/index.d.ts.map +1 -1
  84. package/build/index.js +12 -0
  85. package/build/index.js.map +1 -1
  86. package/build/number/assert.d.ts +154 -0
  87. package/build/number/assert.d.ts.map +1 -0
  88. package/build/number/assert.js +153 -0
  89. package/build/number/assert.js.map +1 -0
  90. package/build/number/index.d.ts +9 -0
  91. package/build/number/index.d.ts.map +1 -0
  92. package/build/number/index.js +9 -0
  93. package/build/number/index.js.map +1 -0
  94. package/build/object/assert.d.ts +138 -0
  95. package/build/object/assert.d.ts.map +1 -0
  96. package/build/object/assert.js +204 -0
  97. package/build/object/assert.js.map +1 -0
  98. package/build/object/clone.d.ts +17 -6
  99. package/build/object/clone.d.ts.map +1 -1
  100. package/build/object/clone.js +17 -6
  101. package/build/object/clone.js.map +1 -1
  102. package/build/object/filter-cached.d.ts +15 -3
  103. package/build/object/filter-cached.d.ts.map +1 -1
  104. package/build/object/filter-cached.js +15 -3
  105. package/build/object/filter-cached.js.map +1 -1
  106. package/build/object/has-circular-reference.d.ts +12 -3
  107. package/build/object/has-circular-reference.d.ts.map +1 -1
  108. package/build/object/has-circular-reference.js +12 -3
  109. package/build/object/has-circular-reference.js.map +1 -1
  110. package/build/object/index.d.ts +1 -0
  111. package/build/object/index.d.ts.map +1 -1
  112. package/build/object/index.js +1 -0
  113. package/build/object/index.js.map +1 -1
  114. package/build/object/key-value-pairs.d.ts +11 -3
  115. package/build/object/key-value-pairs.d.ts.map +1 -1
  116. package/build/object/key-value-pairs.js +11 -3
  117. package/build/object/key-value-pairs.js.map +1 -1
  118. package/build/object/map-cached.d.ts +14 -3
  119. package/build/object/map-cached.d.ts.map +1 -1
  120. package/build/object/map-cached.js +14 -3
  121. package/build/object/map-cached.js.map +1 -1
  122. package/build/object/merge.d.ts +18 -7
  123. package/build/object/merge.d.ts.map +1 -1
  124. package/build/object/merge.js +18 -7
  125. package/build/object/merge.js.map +1 -1
  126. package/build/object/omit.d.ts +13 -4
  127. package/build/object/omit.d.ts.map +1 -1
  128. package/build/object/omit.js +13 -4
  129. package/build/object/omit.js.map +1 -1
  130. package/build/string/assert.d.ts +100 -0
  131. package/build/string/assert.d.ts.map +1 -0
  132. package/build/string/assert.js +185 -0
  133. package/build/string/assert.js.map +1 -0
  134. package/build/string/formatting.d.ts +10 -3
  135. package/build/string/formatting.d.ts.map +1 -1
  136. package/build/string/formatting.js +10 -3
  137. package/build/string/formatting.js.map +1 -1
  138. package/build/string/index.d.ts +1 -0
  139. package/build/string/index.d.ts.map +1 -1
  140. package/build/string/index.js +1 -0
  141. package/build/string/index.js.map +1 -1
  142. package/package.json +1 -1
@@ -0,0 +1,436 @@
1
+ import type { IAssertException, TGuard, TValidationPredicate } from './types.js';
2
+ /**
3
+ * Type alias for constructor functions.
4
+ * Represents any class constructor that can be instantiated.
5
+ */
6
+ export type TConstructorFunction<T = any> = new (...args: any[]) => T;
7
+ /**
8
+ * Error thrown when a nullish assertion fails — the value is not null or undefined
9
+ * but was expected to be. Used by {@link AssertNull} when the provided value is a
10
+ * live (non-null) reference.
11
+ *
12
+ * @example
13
+ * throw new NullError('Expected value to be null or undefined');
14
+ */
15
+ export declare class NullError extends Error {
16
+ constructor(message?: string);
17
+ }
18
+ /**
19
+ * Error thrown when a non-null assertion fails — the value is null or undefined
20
+ * but was expected to be non-nullish. Used by {@link AssertNotNull} when the
21
+ * provided value is absent.
22
+ *
23
+ * @example
24
+ * throw new NotNullError('Expected a non-null value but received null');
25
+ */
26
+ export declare class NotNullError extends Error {
27
+ constructor(message?: string);
28
+ }
29
+ /**
30
+ * Error thrown when a custom predicate assertion fails.
31
+ *
32
+ * @example
33
+ * throw new PredicateError('Predicate assertion failed');
34
+ */
35
+ export declare class PredicateError extends Error {
36
+ constructor(message?: string);
37
+ }
38
+ /**
39
+ * Error thrown when a value does not conform to a user-supplied type guard.
40
+ *
41
+ * @example
42
+ * throw new TypeGuardError('Value does not conform to the required type');
43
+ */
44
+ export declare class TypeGuardError extends Error {
45
+ constructor(message?: string);
46
+ }
47
+ /**
48
+ * Error thrown when a value is not an instance of the expected constructor.
49
+ *
50
+ * @example
51
+ * throw new InstanceOfError('Value is not an instance of the expected type');
52
+ */
53
+ export declare class InstanceOfError extends Error {
54
+ constructor(message?: string);
55
+ }
56
+ /**
57
+ * Error thrown when a value is not a function.
58
+ *
59
+ * @example
60
+ * throw new FunctionError('Value is not a function');
61
+ */
62
+ export declare class FunctionError extends Error {
63
+ constructor(message?: string);
64
+ }
65
+ /**
66
+ * Error thrown when a value is not a symbol.
67
+ *
68
+ * @example
69
+ * throw new SymbolError('Value is not a symbol');
70
+ */
71
+ export declare class SymbolError extends Error {
72
+ constructor(message?: string);
73
+ }
74
+ /**
75
+ * Error thrown when a class does not extend the expected base class.
76
+ *
77
+ * @example
78
+ * throw new ExtendsError('Class does not extend the expected base class');
79
+ */
80
+ export declare class ExtendsError extends Error {
81
+ constructor(message?: string);
82
+ }
83
+ /**
84
+ * Asserts that a value equals an expected value using deep equality comparison.
85
+ *
86
+ * This function performs a comprehensive deep equality check between the provided value and
87
+ * the expected value using ObjectUtils.Equals. The comparison algorithm handles:
88
+ * - Primitive values (numbers, strings, booleans, null, undefined)
89
+ * - Complex nested objects with multiple levels of nesting
90
+ * - Arrays with elements in the same order
91
+ * - Mixed data structures combining objects and arrays
92
+ * - Special values like NaN, Infinity, and -0
93
+ *
94
+ * The deep comparison ensures that all nested properties and array elements are
95
+ * recursively compared, making it suitable for complex data structure validation
96
+ * in testing scenarios and runtime assertions.
97
+ *
98
+ * @template T - The type of values being compared (both value and expected must be of same type)
99
+ * @param value - The actual value to compare against the expected value
100
+ * @param expected - The expected value that the actual value should equal
101
+ * @param exception - Configuration object for custom error handling and messaging.
102
+ * Allows customization of error type, message, and additional metadata
103
+ * @throws {PropertyError} When values are not deeply equal, with descriptive error message
104
+ * @throws {TError} When custom exception type is specified and values don't match
105
+ *
106
+ * @example
107
+ * ```typescript
108
+ * // Primitive value comparisons
109
+ * AssertEquals(5, 5); // ✓ Valid (numbers)
110
+ * AssertEquals("hello", "hello"); // ✓ Valid (strings)
111
+ * AssertEquals(true, true); // ✓ Valid (booleans)
112
+ *
113
+ * // Array comparisons (order matters)
114
+ * AssertEquals([1, 2, 3], [1, 2, 3]); // ✓ Valid (same elements, same order)
115
+ * AssertEquals([1, 2], [2, 1]); // ✗ Throws (different order)
116
+ * AssertEquals([], []); // ✓ Valid (empty arrays)
117
+ *
118
+ * // Object comparisons (deep equality)
119
+ * AssertEquals({a: 1, b: 2}, {a: 1, b: 2}); // ✓ Valid (same properties)
120
+ * AssertEquals({a: {b: 1}}, {a: {b: 1}}); // ✓ Valid (nested objects)
121
+ * AssertEquals({}, {}); // ✓ Valid (empty objects)
122
+ *
123
+ * // Complex nested structures
124
+ * const obj1 = {users: [{id: 1, name: "John"}], count: 1};
125
+ * const obj2 = {users: [{id: 1, name: "John"}], count: 1};
126
+ * AssertEquals(obj1, obj2); // ✓ Valid (deeply equal)
127
+ *
128
+ * // Failure cases
129
+ * AssertEquals(5, 10); // ✗ Throws PropertyError
130
+ * AssertEquals({a: 1}, {a: 2}); // ✗ Throws PropertyError
131
+ * AssertEquals([1, 2], [1, 2, 3]); // ✗ Throws PropertyError
132
+ *
133
+ * // Custom exception handling
134
+ * AssertEquals(1, 2, {
135
+ * message: "Values should be equal"
136
+ * }); // ✗ Throws with custom message
137
+ * ```
138
+ */
139
+ export declare function AssertEquals<T>(value: T, expected: T, exception?: IAssertException): void;
140
+ /**
141
+ * Asserts that a value does not equal an expected value using deep equality comparison.
142
+ *
143
+ * This function performs a comprehensive deep equality check and ensures the values are NOT equal.
144
+ * It uses the same sophisticated comparison logic as AssertEquals but with inverted logic,
145
+ * making it perfect for validating that values have changed, are distinct from unwanted values,
146
+ * or ensuring that mutations have occurred successfully.
147
+ *
148
+ * The deep comparison algorithm checks:
149
+ * - All primitive values for strict inequality
150
+ * - Nested object properties at all levels
151
+ * - Array elements and their ordering
152
+ * - Mixed data structures with complex nesting
153
+ * - Special numeric values (NaN, Infinity, -0)
154
+ *
155
+ * This function is particularly useful in testing scenarios where you need to verify
156
+ * that data transformations, mutations, or state changes have actually occurred.
157
+ *
158
+ * @template T - The type of values being compared (both value and expected must be of same type)
159
+ * @param value - The actual value to compare against the unwanted value
160
+ * @param expected - The value that should NOT be equal to the actual value
161
+ * @param exception - Configuration object for custom error handling and messaging.
162
+ * Defaults to empty object if not provided, allowing for optional customization
163
+ * @throws {PropertyError} When values are deeply equal (and shouldn't be), with descriptive error message
164
+ * @throws {TError} When custom exception type is specified and values are unexpectedly equal
165
+ *
166
+ * @example
167
+ * ```typescript
168
+ * // Primitive value comparisons (should be different)
169
+ * AssertNotEquals(5, 10); // ✓ Valid (different numbers)
170
+ * AssertNotEquals("hello", "world"); // ✓ Valid (different strings)
171
+ * AssertNotEquals(true, false); // ✓ Valid (different booleans)
172
+ *
173
+ * // Array comparisons (should be different)
174
+ * AssertNotEquals([1, 2], [1, 3]); // ✓ Valid (different elements)
175
+ * AssertNotEquals([1, 2], [2, 1]); // ✓ Valid (different order)
176
+ * AssertNotEquals([1], [1, 2]); // ✓ Valid (different lengths)
177
+ *
178
+ * // Object comparisons (should be different)
179
+ * AssertNotEquals({a: 1}, {a: 2}); // ✓ Valid (different property values)
180
+ * AssertNotEquals({a: 1}, {b: 1}); // ✓ Valid (different property names)
181
+ * AssertNotEquals({a: {b: 1}}, {a: {b: 2}}); // ✓ Valid (different nested values)
182
+ *
183
+ * // Testing mutations and transformations
184
+ * const original = {users: [{id: 1, name: "John"}]};
185
+ * const modified = {users: [{id: 1, name: "Jane"}]};
186
+ * AssertNotEquals(original, modified); // ✓ Valid (data was modified)
187
+ *
188
+ * // Verifying state changes
189
+ * let counter = 0;
190
+ * const initialState = counter;
191
+ * counter++;
192
+ * AssertNotEquals(counter, initialState); // ✓ Valid (state changed)
193
+ *
194
+ * // Failure cases (when values are unexpectedly equal)
195
+ * AssertNotEquals(5, 5); // ✗ Throws PropertyError
196
+ * AssertNotEquals([1, 2], [1, 2]); // ✗ Throws PropertyError
197
+ * AssertNotEquals({a: 1}, {a: 1}); // ✗ Throws PropertyError
198
+ *
199
+ * // Custom exception handling
200
+ * AssertNotEquals(1, 1, {
201
+ * message: "Values should be different"
202
+ * }); // ✗ Throws with custom message
203
+ * ```
204
+ */
205
+ export declare function AssertNotEquals<T>(value: T, expected: T, exception?: IAssertException): void;
206
+ /**
207
+ * Asserts that a value is null or undefined (nullish assertion).
208
+ *
209
+ * This method validates that the provided value is either null or undefined,
210
+ * effectively performing a nullish assertion. This is useful for validating
211
+ * that optional values are properly unset, that cleanup operations succeeded,
212
+ * or that certain conditions result in null/undefined states.
213
+ *
214
+ * @template T - The type of the value being validated
215
+ * @param value - The value to validate as null or undefined
216
+ * @param exception - Optional exception configuration for custom error handling
217
+ * @throws {NullError} When value is not null or undefined
218
+ *
219
+ * @example
220
+ * ```typescript
221
+ * AssertNull(null); // ✓ Valid
222
+ * AssertNull(undefined); // ✓ Valid
223
+ * AssertNull("hello"); // ✗ Throws NullError
224
+ * AssertNull(0); // ✗ Throws NullError
225
+ * AssertNull(false); // ✗ Throws NullError
226
+ * AssertNull(""); // ✗ Throws NullError
227
+ *
228
+ * // Validation of cleanup operations
229
+ * function cleanup(resource: Resource | null) {
230
+ * resource?.dispose();
231
+ * resource = null;
232
+ * AssertNull(resource); // Verify cleanup succeeded
233
+ * }
234
+ * ```
235
+ */
236
+ export declare function AssertNull<T>(value: T, exception?: IAssertException): void;
237
+ /**
238
+ * Asserts that a value is not null or undefined (non-nullish assertion).
239
+ *
240
+ * This method validates that the provided value is neither null nor undefined,
241
+ * effectively performing a non-nullish assertion. This is particularly useful
242
+ * for validating function parameters, API responses, and optional values that
243
+ * should have been initialized. After this assertion, TypeScript will narrow
244
+ * the type to exclude null and undefined.
245
+ *
246
+ * @template T - The type of the value being validated
247
+ * @template TError - Custom error type to throw on failure
248
+ * @param value - The value to validate for non-null/undefined
249
+ * @param exception - Optional exception configuration for custom error handling
250
+ * @throws {NotNullError} When value is null or undefined
251
+ *
252
+ * @example
253
+ * ```typescript
254
+ * AssertNotNull("hello"); // ✓ Valid
255
+ * AssertNotNull(0); // ✓ Valid (0 is not null/undefined)
256
+ * AssertNotNull(false); // ✓ Valid (false is not null/undefined)
257
+ * AssertNotNull(""); // ✓ Valid (empty string is not null/undefined)
258
+ * AssertNotNull(null); // ✗ Throws NotNullError
259
+ * AssertNotNull(undefined); // ✗ Throws NotNullError
260
+ *
261
+ * // Type narrowing example
262
+ * function process(value: string | null | undefined) {
263
+ * AssertNotNull(value);
264
+ * // value is now typed as string (null/undefined excluded)
265
+ * return value.toUpperCase();
266
+ * }
267
+ * ```
268
+ */
269
+ export declare function AssertNotNull<T>(value: T, exception?: IAssertException): asserts value is T;
270
+ /**
271
+ * Generic assertion method that validates a value using a custom predicate function.
272
+ *
273
+ * This method provides a flexible way to perform custom validations using any
274
+ * predicate function that returns a boolean. It's the most generic assertion
275
+ * in the library and can be used to implement complex validation logic that
276
+ * doesn't fit into other specific assertion methods.
277
+ *
278
+ * @template T - The type of value being validated
279
+ * @template TError - Custom error type to throw on failure
280
+ * @param value - The value to validate
281
+ * @param predicate - A TValidationPredicate function that returns true if the value is valid
282
+ * @param exception - Optional exception configuration for custom error handling
283
+ * @throws {PredicateError} When predicate returns false
284
+ *
285
+ * @example
286
+ * ```typescript
287
+ * // Simple numeric validation
288
+ * AssertPredicate(42, (x) => x > 0 && x < 100); // ✓ Valid
289
+ *
290
+ * // String validation
291
+ * AssertPredicate("hello", (s) => s.length > 3); // ✓ Valid
292
+ * AssertPredicate("hi", (s) => s.length > 3); // ✗ Throws PredicateError
293
+ *
294
+ * // Complex object validation
295
+ * AssertPredicate(user, (u) =>
296
+ * typeof u.name === 'string' &&
297
+ * u.age >= 0 &&
298
+ * u.email.includes('@')
299
+ * );
300
+ *
301
+ * // Array validation
302
+ * AssertPredicate([1, 2, 3], (arr) =>
303
+ * arr.every(n => typeof n === 'number')
304
+ * );
305
+ * ```
306
+ */
307
+ export declare function AssertPredicate<T>(value: T, predicate: TValidationPredicate<T>, exception?: IAssertException): void;
308
+ /**
309
+ * Asserts that a value matches a specific type using a type guard function.
310
+ *
311
+ * This method validates that the provided value passes a custom type guard,
312
+ * enabling complex type validations beyond primitive type checks. Type guards
313
+ * are functions that return `value is T` and provide runtime type checking
314
+ * with TypeScript type narrowing. This is particularly useful for validating
315
+ * complex object structures and custom types.
316
+ *
317
+ * @template T - The target type to validate for
318
+ * @template TError - Custom error type to throw on failure
319
+ * @param value - The value to validate
320
+ * @param typeGuard - A TGuard function that returns `value is T`
321
+ * @param exception - Optional exception configuration for custom error handling
322
+ * @throws {TypeGuardError} When value does not pass the type guard
323
+ *
324
+ * @example
325
+ * ```typescript
326
+ * // Define interfaces and type guards
327
+ * interface User { name: string; age: number; }
328
+ * const isUser = (obj: unknown): obj is User =>
329
+ * typeof obj === 'object' && obj !== null &&
330
+ * 'name' in obj && typeof obj.name === 'string' &&
331
+ * 'age' in obj && typeof obj.age === 'number';
332
+ *
333
+ * // Usage
334
+ * AssertIsType(data, isUser);
335
+ * // data is now typed as User
336
+ *
337
+ * // Array of specific type
338
+ * const isStringArray = (arr: unknown): arr is string[] =>
339
+ * Array.isArray(arr) && arr.every(item => typeof item === 'string');
340
+ *
341
+ * AssertIsType(someArray, isStringArray);
342
+ * // someArray is now typed as string[]
343
+ * ```
344
+ */
345
+ export declare function AssertIsType<T>(value: unknown, typeGuard: TGuard<T>, exception?: IAssertException): asserts value is T;
346
+ /**
347
+ * Asserts that a value is an instance of a specific class or constructor function.
348
+ *
349
+ * This method validates that the provided value is an instance of the specified
350
+ * constructor function using the instanceof operator. This is useful for validating
351
+ * object instances, built-in types like Date and Error, and custom class instances.
352
+ * After this assertion, the value is properly typed as an instance of the constructor.
353
+ *
354
+ * @template T - The instance type to validate for
355
+ * @template TError - Custom error type to throw on failure
356
+ * @param value - The value to validate as an instance
357
+ * @param constructor - The constructor function to check against
358
+ * @param exception - Optional exception configuration for custom error handling
359
+ * @throws {InstanceOfError} When value is not an instance of the constructor
360
+ *
361
+ * @example
362
+ * ```typescript
363
+ * // Built-in types
364
+ * AssertInstanceOf(new Date(), Date); // ✓ Valid
365
+ * AssertInstanceOf(new Error(), Error); // ✓ Valid
366
+ * AssertInstanceOf([], Array); // ✓ Valid
367
+ * AssertInstanceOf(/regex/, RegExp); // ✓ Valid
368
+ *
369
+ * // Custom classes
370
+ * class Person { constructor(public name: string) {} }
371
+ * const person = new Person("John");
372
+ * AssertInstanceOf(person, Person); // ✓ Valid
373
+ *
374
+ * // Invalid cases
375
+ * AssertInstanceOf("string", Date); // ✗ Throws InstanceOfError
376
+ * AssertInstanceOf(123, Error); // ✗ Throws InstanceOfError
377
+ * AssertInstanceOf({}, Array); // ✗ Throws InstanceOfError
378
+ * ```
379
+ */
380
+ export declare function AssertInstanceOf<T>(value: unknown, constructor: TConstructorFunction<T>, exception?: IAssertException): asserts value is T;
381
+ /**
382
+ * Asserts that a value is a function.
383
+ *
384
+ * This method validates that the provided value is a function (typeof === 'function').
385
+ * Useful for runtime validation of callbacks, API hooks, and dynamic invocations.
386
+ * Throws FunctionError or custom error if assertion fails.
387
+ *
388
+ * @param value - The value to validate as a function
389
+ * @param exception - Optional exception configuration for custom error handling
390
+ * @throws {FunctionError} When value is not a function
391
+ *
392
+ * @example
393
+ * AssertFunction(() => {}); // ✓ Valid
394
+ * AssertFunction(function() {}); // ✓ Valid
395
+ * AssertFunction(123); // ✗ Throws FunctionError
396
+ * AssertFunction(null); // ✗ Throws FunctionError
397
+ */
398
+ export declare function AssertFunction(value: unknown, exception?: IAssertException): asserts value is (...args: any[]) => any;
399
+ /**
400
+ * Asserts that a value is a symbol.
401
+ *
402
+ * This method validates that the provided value is a symbol (typeof === 'symbol').
403
+ * Useful for runtime validation of unique keys, metadata, and advanced API contracts.
404
+ * Throws SymbolError or custom error if assertion fails.
405
+ *
406
+ * @param value - The value to validate as a symbol
407
+ * @param exception - Optional exception configuration for custom error handling
408
+ * @throws {SymbolError} When value is not a symbol
409
+ *
410
+ * @example
411
+ * AssertSymbol(Symbol('foo')); // ✓ Valid
412
+ * AssertSymbol(Symbol.iterator); // ✓ Valid
413
+ * AssertSymbol('not-a-symbol'); // ✗ Throws SymbolError
414
+ * AssertSymbol(123); // ✗ Throws SymbolError
415
+ */
416
+ export declare function AssertSymbol(value: unknown, exception?: IAssertException): asserts value is symbol;
417
+ /**
418
+ * Asserts that a class extends another class.
419
+ *
420
+ * This method validates that the provided derived class extends the specified base class.
421
+ * Useful for runtime validation of inheritance relationships in TypeScript and JavaScript.
422
+ * Throws ExtendsError or custom error if assertion fails.
423
+ *
424
+ * @param derived - The class to validate as extending base
425
+ * @param base - The base class to check against
426
+ * @param exception - Optional exception configuration for custom error handling
427
+ * @throws {ExtendsError} When derived does not extend base
428
+ *
429
+ * @example
430
+ * class Base {}
431
+ * class Derived extends Base {}
432
+ * AssertExtends(Derived, Base); // ✓ Valid
433
+ * AssertExtends(Base, Derived); // ✗ Throws ExtendsError
434
+ */
435
+ export declare function AssertExtends(derived: abstract new (...args: any[]) => any, base: abstract new (...args: any[]) => any, exception?: IAssertException): void;
436
+ //# sourceMappingURL=generic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generic.d.ts","sourceRoot":"","sources":["../../src/asserts/generic.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAMjF;;;GAGG;AACH,MAAM,MAAM,oBAAoB,CAAC,CAAC,GAAG,GAAG,IAAI,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;AAEtE;;;;;;;GAOG;AACH,qBAAa,SAAU,SAAQ,KAAK;gBACvB,OAAO,CAAC,EAAE,MAAM;CAK5B;AAED;;;;;;;GAOG;AACH,qBAAa,YAAa,SAAQ,KAAK;gBAC1B,OAAO,CAAC,EAAE,MAAM;CAK5B;AAED;;;;;GAKG;AACH,qBAAa,cAAe,S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