indusagi-coding-agent 0.1.22 → 0.1.24

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 (222) hide show
  1. package/CHANGELOG.md +72 -11
  2. package/README.md +2 -36
  3. package/dist/cli/args.d.ts +117 -1
  4. package/dist/cli/args.d.ts.map +1 -1
  5. package/dist/cli/args.js +231 -64
  6. package/dist/cli/args.js.map +1 -1
  7. package/dist/cli/config-selector.d.ts +58 -2
  8. package/dist/cli/config-selector.d.ts.map +1 -1
  9. package/dist/cli/config-selector.js +130 -12
  10. package/dist/cli/config-selector.js.map +1 -1
  11. package/dist/cli/file-processor.d.ts +70 -2
  12. package/dist/cli/file-processor.d.ts.map +1 -1
  13. package/dist/cli/file-processor.js +240 -15
  14. package/dist/cli/file-processor.js.map +1 -1
  15. package/dist/cli/list-models.d.ts +63 -3
  16. package/dist/cli/list-models.d.ts.map +1 -1
  17. package/dist/cli/list-models.js +202 -27
  18. package/dist/cli/list-models.js.map +1 -1
  19. package/dist/cli/login-handler.d.ts +82 -8
  20. package/dist/cli/login-handler.d.ts.map +1 -1
  21. package/dist/cli/login-handler.js +410 -77
  22. package/dist/cli/login-handler.js.map +1 -1
  23. package/dist/cli/session-picker.d.ts +74 -2
  24. package/dist/cli/session-picker.d.ts.map +1 -1
  25. package/dist/cli/session-picker.js +236 -12
  26. package/dist/cli/session-picker.js.map +1 -1
  27. package/dist/core/agent-session.d.ts +214 -9
  28. package/dist/core/agent-session.d.ts.map +1 -1
  29. package/dist/core/agent-session.js +214 -9
  30. package/dist/core/agent-session.js.map +1 -1
  31. package/dist/core/bash-executor.d.ts +302 -12
  32. package/dist/core/bash-executor.d.ts.map +1 -1
  33. package/dist/core/bash-executor.js +302 -12
  34. package/dist/core/bash-executor.js.map +1 -1
  35. package/dist/core/diagnostics.d.ts +191 -0
  36. package/dist/core/diagnostics.d.ts.map +1 -1
  37. package/dist/core/diagnostics.js +142 -0
  38. package/dist/core/diagnostics.js.map +1 -1
  39. package/dist/core/event-bus.d.ts +146 -0
  40. package/dist/core/event-bus.d.ts.map +1 -1
  41. package/dist/core/event-bus.js +93 -0
  42. package/dist/core/event-bus.js.map +1 -1
  43. package/dist/core/export-html/ansi-to-html.d.ts +4 -0
  44. package/dist/core/export-html/ansi-to-html.d.ts.map +1 -1
  45. package/dist/core/export-html/ansi-to-html.js +4 -0
  46. package/dist/core/export-html/ansi-to-html.js.map +1 -1
  47. package/dist/core/export-html/index.d.ts +128 -0
  48. package/dist/core/export-html/index.d.ts.map +1 -1
  49. package/dist/core/export-html/index.js +128 -0
  50. package/dist/core/export-html/index.js.map +1 -1
  51. package/dist/core/export-html/tool-renderer.d.ts +4 -0
  52. package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
  53. package/dist/core/export-html/tool-renderer.js +4 -0
  54. package/dist/core/export-html/tool-renderer.js.map +1 -1
  55. package/dist/core/keybindings.d.ts +142 -0
  56. package/dist/core/keybindings.d.ts.map +1 -1
  57. package/dist/core/keybindings.js +142 -0
  58. package/dist/core/keybindings.js.map +1 -1
  59. package/dist/core/model-registry.d.ts +98 -1
  60. package/dist/core/model-registry.d.ts.map +1 -1
  61. package/dist/core/model-registry.js +98 -1
  62. package/dist/core/model-registry.js.map +1 -1
  63. package/dist/core/model-resolver.d.ts +99 -1
  64. package/dist/core/model-resolver.d.ts.map +1 -1
  65. package/dist/core/model-resolver.js +99 -1
  66. package/dist/core/model-resolver.js.map +1 -1
  67. package/dist/core/prompt-templates.js.map +1 -1
  68. package/dist/core/sdk.d.ts +1 -1
  69. package/dist/core/sdk.d.ts.map +1 -1
  70. package/dist/core/sdk.js +0 -2
  71. package/dist/core/sdk.js.map +1 -1
  72. package/dist/core/session-manager.d.ts +127 -0
  73. package/dist/core/session-manager.d.ts.map +1 -1
  74. package/dist/core/session-manager.js +125 -0
  75. package/dist/core/session-manager.js.map +1 -1
  76. package/dist/core/skills.js.map +1 -1
  77. package/dist/core/subagents.js.map +1 -1
  78. package/dist/core/tools/bash.d.ts +391 -11
  79. package/dist/core/tools/bash.d.ts.map +1 -1
  80. package/dist/core/tools/bash.js +269 -2
  81. package/dist/core/tools/bash.js.map +1 -1
  82. package/dist/core/tools/edit.d.ts +284 -6
  83. package/dist/core/tools/edit.d.ts.map +1 -1
  84. package/dist/core/tools/edit.js +238 -0
  85. package/dist/core/tools/edit.js.map +1 -1
  86. package/dist/core/tools/find.d.ts +169 -5
  87. package/dist/core/tools/find.d.ts.map +1 -1
  88. package/dist/core/tools/find.js +136 -0
  89. package/dist/core/tools/find.js.map +1 -1
  90. package/dist/core/tools/grep.d.ts +285 -5
  91. package/dist/core/tools/grep.d.ts.map +1 -1
  92. package/dist/core/tools/grep.js +247 -0
  93. package/dist/core/tools/grep.js.map +1 -1
  94. package/dist/core/tools/index.d.ts +0 -18
  95. package/dist/core/tools/index.d.ts.map +1 -1
  96. package/dist/core/tools/index.js +1 -23
  97. package/dist/core/tools/index.js.map +1 -1
  98. package/dist/core/tools/ls.d.ts +6 -0
  99. package/dist/core/tools/ls.d.ts.map +1 -1
  100. package/dist/core/tools/ls.js +6 -0
  101. package/dist/core/tools/ls.js.map +1 -1
  102. package/dist/core/tools/read.d.ts +308 -7
  103. package/dist/core/tools/read.d.ts.map +1 -1
  104. package/dist/core/tools/read.js +231 -0
  105. package/dist/core/tools/read.js.map +1 -1
  106. package/dist/core/tools/webfetch.d.ts +118 -3
  107. package/dist/core/tools/webfetch.d.ts.map +1 -1
  108. package/dist/core/tools/webfetch.js +118 -3
  109. package/dist/core/tools/webfetch.js.map +1 -1
  110. package/dist/core/tools/websearch.d.ts +130 -3
  111. package/dist/core/tools/websearch.d.ts.map +1 -1
  112. package/dist/core/tools/websearch.js +130 -3
  113. package/dist/core/tools/websearch.js.map +1 -1
  114. package/dist/core/tools/write.d.ts +251 -5
  115. package/dist/core/tools/write.d.ts.map +1 -1
  116. package/dist/core/tools/write.js +210 -0
  117. package/dist/core/tools/write.js.map +1 -1
  118. package/dist/modes/interactive/components/assistant-message.d.ts +164 -1
  119. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  120. package/dist/modes/interactive/components/assistant-message.js +164 -1
  121. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  122. package/dist/modes/interactive/components/bash-execution.d.ts +297 -1
  123. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
  124. package/dist/modes/interactive/components/bash-execution.js +297 -1
  125. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  126. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  127. package/dist/modes/interactive/components/tool-execution.js +251 -1
  128. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  129. package/dist/modes/interactive/components/user-message.d.ts +186 -1
  130. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  131. package/dist/modes/interactive/components/user-message.js +186 -1
  132. package/dist/modes/interactive/components/user-message.js.map +1 -1
  133. package/dist/modes/interactive/interactive-mode.d.ts +1567 -13
  134. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  135. package/dist/modes/interactive/interactive-mode.js +1567 -13
  136. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  137. package/dist/modes/interactive/theme/theme.d.ts +422 -0
  138. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  139. package/dist/modes/interactive/theme/theme.js +422 -0
  140. package/dist/modes/interactive/theme/theme.js.map +1 -1
  141. package/dist/modes/print-mode.d.ts +538 -5
  142. package/dist/modes/print-mode.d.ts.map +1 -1
  143. package/dist/modes/print-mode.js +538 -5
  144. package/dist/modes/print-mode.js.map +1 -1
  145. package/dist/modes/rpc/rpc-client.d.ts +921 -8
  146. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  147. package/dist/modes/rpc/rpc-client.js +921 -8
  148. package/dist/modes/rpc/rpc-client.js.map +1 -1
  149. package/dist/modes/rpc/rpc-mode.d.ts +802 -9
  150. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  151. package/dist/modes/rpc/rpc-mode.js +802 -9
  152. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  153. package/dist/modes/rpc/rpc-types.d.ts +356 -3
  154. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  155. package/dist/modes/rpc/rpc-types.js +356 -3
  156. package/dist/modes/rpc/rpc-types.js.map +1 -1
  157. package/dist/modes/shared.d.ts +386 -0
  158. package/dist/modes/shared.d.ts.map +1 -0
  159. package/dist/modes/shared.js +543 -0
  160. package/dist/modes/shared.js.map +1 -0
  161. package/dist/utils/array.d.ts +389 -0
  162. package/dist/utils/array.d.ts.map +1 -0
  163. package/dist/utils/array.js +585 -0
  164. package/dist/utils/array.js.map +1 -0
  165. package/dist/utils/color-formatter.d.ts +318 -0
  166. package/dist/utils/color-formatter.d.ts.map +1 -0
  167. package/dist/utils/color-formatter.js +442 -0
  168. package/dist/utils/color-formatter.js.map +1 -0
  169. package/dist/utils/data-transformer.d.ts +326 -0
  170. package/dist/utils/data-transformer.d.ts.map +1 -0
  171. package/dist/utils/data-transformer.js +512 -0
  172. package/dist/utils/data-transformer.js.map +1 -0
  173. package/dist/utils/date-formatter.d.ts +281 -0
  174. package/dist/utils/date-formatter.d.ts.map +1 -0
  175. package/dist/utils/date-formatter.js +503 -0
  176. package/dist/utils/date-formatter.js.map +1 -0
  177. package/dist/utils/error-handler.d.ts +541 -0
  178. package/dist/utils/error-handler.d.ts.map +1 -0
  179. package/dist/utils/error-handler.js +726 -0
  180. package/dist/utils/error-handler.js.map +1 -0
  181. package/dist/utils/file-operations.d.ts +297 -0
  182. package/dist/utils/file-operations.d.ts.map +1 -0
  183. package/dist/utils/file-operations.js +505 -0
  184. package/dist/utils/file-operations.js.map +1 -0
  185. package/dist/utils/frontmatter.d.ts +268 -6
  186. package/dist/utils/frontmatter.d.ts.map +1 -1
  187. package/dist/utils/frontmatter.js +500 -21
  188. package/dist/utils/frontmatter.js.map +1 -1
  189. package/dist/utils/json-formatter.d.ts +259 -0
  190. package/dist/utils/json-formatter.d.ts.map +1 -0
  191. package/dist/utils/json-formatter.js +517 -0
  192. package/dist/utils/json-formatter.js.map +1 -0
  193. package/dist/utils/logger.d.ts +176 -0
  194. package/dist/utils/logger.d.ts.map +1 -0
  195. package/dist/utils/logger.js +346 -0
  196. package/dist/utils/logger.js.map +1 -0
  197. package/dist/utils/markdown-formatter.d.ts +211 -0
  198. package/dist/utils/markdown-formatter.d.ts.map +1 -0
  199. package/dist/utils/markdown-formatter.js +482 -0
  200. package/dist/utils/markdown-formatter.js.map +1 -0
  201. package/dist/utils/path-validator.d.ts +603 -0
  202. package/dist/utils/path-validator.d.ts.map +1 -0
  203. package/dist/utils/path-validator.js +870 -0
  204. package/dist/utils/path-validator.js.map +1 -0
  205. package/dist/utils/string-formatter.d.ts +609 -0
  206. package/dist/utils/string-formatter.d.ts.map +1 -0
  207. package/dist/utils/string-formatter.js +806 -0
  208. package/dist/utils/string-formatter.js.map +1 -0
  209. package/dist/utils/type-guards.d.ts +629 -0
  210. package/dist/utils/type-guards.d.ts.map +1 -0
  211. package/dist/utils/type-guards.js +662 -0
  212. package/dist/utils/type-guards.js.map +1 -0
  213. package/docs/COMPLETE-GUIDE.md +300 -0
  214. package/docs/MODES-ARCHITECTURE.md +565 -0
  215. package/docs/PRINT-MODE-GUIDE.md +456 -0
  216. package/docs/README.md +1 -2
  217. package/docs/RPC-GUIDE.md +705 -0
  218. package/docs/UTILS-IMPLEMENTATION-SUMMARY.md +647 -0
  219. package/docs/UTILS-MODULE-OVERVIEW.md +1480 -0
  220. package/docs/UTILS-QA-CHECKLIST.md +1061 -0
  221. package/docs/UTILS-USAGE-GUIDE.md +1419 -0
  222. package/package.json +3 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string-formatter.js","sourceRoot":"","sources":["../../src/utils/string-formatter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,WA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
+ * @fileoverview Type Guards and Type Narrowing Utilities
3
+ *
4
+ * This module provides comprehensive runtime type checking functions that serve as
5
+ * TypeScript type predicates. Type guards enable type narrowing in TypeScript, allowing
6
+ * the compiler to automatically refine types based on runtime checks. This is essential
7
+ * for:
8
+ *
9
+ * 1. **Runtime Type Safety**: Validate data at runtime before it's processed
10
+ * 2. **Type Narrowing**: Automatically narrow union types based on guard results
11
+ * 3. **Discriminated Unions**: Pattern match on type characteristics
12
+ * 4. **API Response Validation**: Verify external data conforms to expected types
13
+ * 5. **Error Handling**: Safely handle different error types
14
+ *
15
+ * ## Type Narrowing in TypeScript
16
+ *
17
+ * Type guards allow TypeScript to narrow types within conditional blocks:
18
+ *
19
+ * ```typescript
20
+ * const value: string | number = getValue();
21
+ *
22
+ * if (isString(value)) {
23
+ * // TypeScript now knows value is string
24
+ * value.toUpperCase(); // ✓ Allowed
25
+ * } else if (isNumber(value)) {
26
+ * // TypeScript now knows value is number
27
+ * value.toFixed(2); // ✓ Allowed
28
+ * }
29
+ * ```
30
+ *
31
+ * ## When to Use Type Guards
32
+ *
33
+ * - Validating external data (API responses, user input, config files)
34
+ * - Handling union types safely
35
+ * - Implementing discriminated unions
36
+ * - Working with `any` or `unknown` types
37
+ * - Defensive programming at module boundaries
38
+ *
39
+ * @author Coding Agent
40
+ * @version 1.0.0
41
+ */
42
+ /**
43
+ * Checks if a value is a primitive type (string, number, boolean, null, undefined, symbol, bigint).
44
+ *
45
+ * Primitive types in JavaScript are immutable and passed by value. This is useful for
46
+ * quick type categorization and distinguishing primitives from objects.
47
+ *
48
+ * @param value - The value to check
49
+ * @returns true if value is a primitive type
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * isPrimitive(42) // true
54
+ * isPrimitive("hello") // true
55
+ * isPrimitive(true) // true
56
+ * isPrimitive(null) // true
57
+ * isPrimitive(undefined) // true
58
+ * isPrimitive({}) // false
59
+ * isPrimitive([]) // false
60
+ * isPrimitive(() => {}) // false
61
+ * ```
62
+ *
63
+ * @usage
64
+ * ```typescript
65
+ * function processValue(value: unknown) {
66
+ * if (isPrimitive(value)) {
67
+ * // Safely stringify or log primitive
68
+ * console.log(String(value));
69
+ * } else {
70
+ * // Handle complex object
71
+ * processObject(value as object);
72
+ * }
73
+ * }
74
+ * ```
75
+ */
76
+ export declare function isPrimitive(value: unknown): value is string | number | boolean | null | undefined | symbol | bigint;
77
+ /**
78
+ * Checks if a value is a plain JavaScript object (not null, array, function, or built-in object).
79
+ *
80
+ * This guard specifically identifies plain objects created with `{}` or `Object.create(null)`,
81
+ * excluding arrays, dates, regex, errors, and other special object types. Useful for
82
+ * differentiating data objects from other object types.
83
+ *
84
+ * @param value - The value to check
85
+ * @returns true if value is a plain object
86
+ *
87
+ * @example
88
+ * ```typescript
89
+ * isObject({}) // true
90
+ * isObject({ name: 'John' }) // true
91
+ * isObject(Object.create(null)) // true
92
+ * isObject([]) // false (array)
93
+ * isObject(new Date()) // false (built-in object)
94
+ * isObject(new Map()) // false (built-in object)
95
+ * isObject(null) // false
96
+ * isObject("string") // false
97
+ * ```
98
+ *
99
+ * @usage
100
+ * ```typescript
101
+ * // Merge configuration objects safely
102
+ * function mergeConfig(target: Record<string, any>, source: unknown) {
103
+ * if (isObject(source)) {
104
+ * Object.assign(target, source);
105
+ * } else {
106
+ * throw new Error('Configuration must be a plain object');
107
+ * }
108
+ * }
109
+ * ```
110
+ */
111
+ export declare function isObject(value: unknown): value is Record<string, unknown>;
112
+ /**
113
+ * Checks if a value is an array.
114
+ *
115
+ * Type narrows to Array<unknown>. Use type parameters for more specific array types
116
+ * in combination with element validation.
117
+ *
118
+ * @param value - The value to check
119
+ * @returns true if value is an array
120
+ *
121
+ * @example
122
+ * ```typescript
123
+ * isArray([]) // true
124
+ * isArray([1, 2, 3]) // true
125
+ * isArray(['a', 'b']) // true
126
+ * isArray(new Array()) // true
127
+ * isArray({}) // false
128
+ * isArray("string") // false
129
+ * isArray(null) // false
130
+ * ```
131
+ *
132
+ * @usage
133
+ * ```typescript
134
+ * // Type-safe array processing
135
+ * function processItems(items: unknown): number {
136
+ * if (isArray(items)) {
137
+ * return items.reduce((sum, item) => {
138
+ * return sum + (isNumber(item) ? item : 0);
139
+ * }, 0);
140
+ * }
141
+ * return 0;
142
+ * }
143
+ *
144
+ * // Iterate safely with type narrowing
145
+ * if (isArray(data)) {
146
+ * data.forEach(item => {
147
+ * console.log(item);
148
+ * });
149
+ * }
150
+ * ```
151
+ */
152
+ export declare function isArray(value: unknown): value is unknown[];
153
+ /**
154
+ * Checks if a value is a string.
155
+ *
156
+ * Useful for string validation, form input verification, and discriminating
157
+ * between string and number types.
158
+ *
159
+ * @param value - The value to check
160
+ * @returns true if value is a string
161
+ *
162
+ * @example
163
+ * ```typescript
164
+ * isString("hello") // true
165
+ * isString("") // true
166
+ * isString(new String("text")) // false (object wrapper)
167
+ * isString(123) // false
168
+ * isString(null) // false
169
+ * ```
170
+ *
171
+ * @usage
172
+ * ```typescript
173
+ * // Validate user input
174
+ * function processUserInput(input: unknown): void {
175
+ * if (!isString(input)) {
176
+ * throw new TypeError('Input must be a string');
177
+ * }
178
+ *
179
+ * const trimmed = input.trim();
180
+ * if (trimmed.length === 0) {
181
+ * throw new Error('Input cannot be empty');
182
+ * }
183
+ * }
184
+ *
185
+ * // Parse environment variables safely
186
+ * function getEnvString(key: string, defaultValue: string = ''): string {
187
+ * const value = process.env[key];
188
+ * return isString(value) ? value : defaultValue;
189
+ * }
190
+ * ```
191
+ */
192
+ export declare function isString(value: unknown): value is string;
193
+ /**
194
+ * Checks if a value is a number (excluding NaN and Infinity).
195
+ *
196
+ * This strict guard rejects NaN and Infinity, which are valid JavaScript numbers
197
+ * but often represent error states. Use with caution when you specifically need
198
+ * to accept these special values.
199
+ *
200
+ * @param value - The value to check
201
+ * @returns true if value is a valid finite number
202
+ *
203
+ * @example
204
+ * ```typescript
205
+ * isNumber(42) // true
206
+ * isNumber(3.14) // true
207
+ * isNumber(-5) // true
208
+ * isNumber(0) // true
209
+ * isNumber(Infinity) // false (rejected for safety)
210
+ * isNumber(-Infinity) // false
211
+ * isNumber(NaN) // false
212
+ * isNumber("123") // false
213
+ * isNumber(new Number(42)) // false (wrapper object)
214
+ * ```
215
+ *
216
+ * @usage
217
+ * ```typescript
218
+ * // Calculate average safely
219
+ * function calculateAverage(values: unknown[]): number | null {
220
+ * const numbers = values.filter(isNumber);
221
+ * if (numbers.length === 0) return null;
222
+ * return numbers.reduce((a, b) => a + b, 0) / numbers.length;
223
+ * }
224
+ *
225
+ * // Validate port numbers
226
+ * function isValidPort(port: unknown): boolean {
227
+ * return isNumber(port) && port >= 0 && port <= 65535;
228
+ * }
229
+ * ```
230
+ */
231
+ export declare function isNumber(value: unknown): value is number;
232
+ /**
233
+ * Checks if a value is a boolean (true or false).
234
+ *
235
+ * @param value - The value to check
236
+ * @returns true if value is a boolean
237
+ *
238
+ * @example
239
+ * ```typescript
240
+ * isBoolean(true) // true
241
+ * isBoolean(false) // true
242
+ * isBoolean(1) // false
243
+ * isBoolean("true") // false
244
+ * isBoolean(new Boolean(true)) // false (wrapper object)
245
+ * ```
246
+ *
247
+ * @usage
248
+ * ```typescript
249
+ * // Type-safe configuration
250
+ * interface Config {
251
+ * debug?: boolean;
252
+ * }
253
+ *
254
+ * function parseConfig(input: unknown): Config {
255
+ * if (!isObject(input)) throw new Error('Config must be an object');
256
+ *
257
+ * const debug = (input as any).debug;
258
+ * return {
259
+ * debug: isBoolean(debug) ? debug : false
260
+ * };
261
+ * }
262
+ * ```
263
+ */
264
+ export declare function isBoolean(value: unknown): value is boolean;
265
+ /**
266
+ * Checks if a value is a function.
267
+ *
268
+ * Distinguishes callable functions from other object types. Useful for
269
+ * callback validation and dynamic function calling.
270
+ *
271
+ * @param value - The value to check
272
+ * @returns true if value is a function
273
+ *
274
+ * @example
275
+ * ```typescript
276
+ * isFunction(() => {}) // true
277
+ * isFunction(function() {}) // true
278
+ * isFunction(async () => {}) // true
279
+ * isFunction(class MyClass {}) // true
280
+ * isFunction(Promise.resolve) // true
281
+ * isFunction(Math.max) // true
282
+ * isFunction({}) // false
283
+ * isFunction("function") // false
284
+ * ```
285
+ *
286
+ * @usage
287
+ * ```typescript
288
+ * // Callback validation and execution
289
+ * function processWithCallback(
290
+ * data: unknown,
291
+ * callback: unknown
292
+ * ): unknown {
293
+ * if (!isFunction(callback)) {
294
+ * throw new TypeError('Callback must be a function');
295
+ * }
296
+ * return callback(data);
297
+ * }
298
+ *
299
+ * // Build event emitter safely
300
+ * const listeners: Map<string, Function[]> = new Map();
301
+ *
302
+ * function on(event: string, listener: unknown) {
303
+ * if (!isFunction(listener)) {
304
+ * throw new TypeError('Listener must be a function');
305
+ * }
306
+ * if (!listeners.has(event)) {
307
+ * listeners.set(event, []);
308
+ * }
309
+ * listeners.get(event)!.push(listener);
310
+ * }
311
+ * ```
312
+ */
313
+ export declare function isFunction(value: unknown): value is (...args: unknown[]) => unknown;
314
+ /**
315
+ * Checks if a value is an Error instance.
316
+ *
317
+ * Identifies instances of Error and its subclasses (TypeError, ReferenceError, etc.).
318
+ * Essential for error handling and recovery strategies.
319
+ *
320
+ * @param value - The value to check
321
+ * @returns true if value is an Error instance
322
+ *
323
+ * @example
324
+ * ```typescript
325
+ * isError(new Error("message")) // true
326
+ * isError(new TypeError("message")) // true
327
+ * isError(new ReferenceError("message")) // true
328
+ * isError(new Error()) // true
329
+ * isError(new CustomError()) // true (if extends Error)
330
+ * isError({ message: "error" }) // false
331
+ * isError("error string") // false
332
+ * isError(null) // false
333
+ * ```
334
+ *
335
+ * @usage
336
+ * ```typescript
337
+ * // Safe error handling
338
+ * async function executeWithFallback(fn: () => Promise<void>) {
339
+ * try {
340
+ * await fn();
341
+ * } catch (error) {
342
+ * if (isError(error)) {
343
+ * console.error('Caught error:', error.message);
344
+ * console.error('Stack:', error.stack);
345
+ * } else {
346
+ * console.error('Unknown error type:', error);
347
+ * }
348
+ * }
349
+ * }
350
+ *
351
+ * // Error type discrimination
352
+ * function handleError(error: unknown): string {
353
+ * if (!isError(error)) {
354
+ * return 'Unknown error';
355
+ * }
356
+ *
357
+ * if (error instanceof TypeError) {
358
+ * return 'Type error: ' + error.message;
359
+ * } else if (error instanceof RangeError) {
360
+ * return 'Range error: ' + error.message;
361
+ * } else {
362
+ * return 'Error: ' + error.message;
363
+ * }
364
+ * }
365
+ * ```
366
+ */
367
+ export declare function isError(value: unknown): value is Error;
368
+ /**
369
+ * Checks if a value is a Date instance.
370
+ *
371
+ * Useful for temporal data validation and date handling workflows.
372
+ *
373
+ * @param value - The value to check
374
+ * @returns true if value is a Date instance
375
+ *
376
+ * @example
377
+ * ```typescript
378
+ * isDate(new Date()) // true
379
+ * isDate(new Date('2024-01-01')) // true
380
+ * isDate(Date.now()) // false (returns number)
381
+ * isDate("2024-01-01") // false
382
+ * isDate({ toISOString: () => {} }) // false (duck typing doesn't work)
383
+ * isDate(null) // false
384
+ * ```
385
+ *
386
+ * @usage
387
+ * ```typescript
388
+ * // Validate API response dates
389
+ * function parseResponse(data: unknown): { timestamp: Date } | null {
390
+ * if (!isObject(data)) return null;
391
+ *
392
+ * const timestamp = (data as any).timestamp;
393
+ * if (isDate(timestamp)) {
394
+ * return { timestamp };
395
+ * }
396
+ *
397
+ * // Try parsing string dates
398
+ * if (isString(timestamp)) {
399
+ * const parsed = new Date(timestamp);
400
+ * return isValidDate(parsed) ? { timestamp: parsed } : null;
401
+ * }
402
+ *
403
+ * return null;
404
+ * }
405
+ *
406
+ * // Helper to validate Date is not invalid (NaN)
407
+ * function isValidDate(date: Date): boolean {
408
+ * return isDate(date) && !isNaN(date.getTime());
409
+ * }
410
+ * ```
411
+ */
412
+ export declare function isDate(value: unknown): value is Date;
413
+ /**
414
+ * Checks if a value is a RegExp instance.
415
+ *
416
+ * Useful for pattern validation, regex-based routing, and configuration parsing.
417
+ *
418
+ * @param value - The value to check
419
+ * @returns true if value is a RegExp instance
420
+ *
421
+ * @example
422
+ * ```typescript
423
+ * isRegExp(/test/) // true
424
+ * isRegExp(new RegExp('test')) // true
425
+ * isRegExp(/test/gi) // true
426
+ * isRegExp("/test/") // false (string)
427
+ * isRegExp({ test: () => {} }) // false
428
+ * isRegExp(null) // false
429
+ * ```
430
+ *
431
+ * @usage
432
+ * ```typescript
433
+ * // Validate pattern matchers
434
+ * function buildMatcher(pattern: unknown): (str: string) => boolean {
435
+ * if (isRegExp(pattern)) {
436
+ * return (str: string) => pattern.test(str);
437
+ * } else if (isString(pattern)) {
438
+ * const regex = new RegExp(pattern);
439
+ * return (str: string) => regex.test(str);
440
+ * } else {
441
+ * throw new TypeError('Pattern must be RegExp or string');
442
+ * }
443
+ * }
444
+ *
445
+ * // Route matching with regex validation
446
+ * interface Route {
447
+ * pattern: unknown;
448
+ * handler: (match: string) => void;
449
+ * }
450
+ *
451
+ * function createRouter(routes: Route[]) {
452
+ * return {
453
+ * match(path: string) {
454
+ * for (const route of routes) {
455
+ * if (isRegExp(route.pattern)) {
456
+ * const matches = path.match(route.pattern);
457
+ * if (matches) {
458
+ * route.handler(path);
459
+ * return true;
460
+ * }
461
+ * }
462
+ * }
463
+ * return false;
464
+ * }
465
+ * };
466
+ * }
467
+ * ```
468
+ */
469
+ export declare function isRegExp(value: unknown): value is RegExp;
470
+ /**
471
+ * Checks if a value is null or undefined.
472
+ *
473
+ * Handy shortcut for checking nullish values. Use together with other guards
474
+ * for optional property validation.
475
+ *
476
+ * @param value - The value to check
477
+ * @returns true if value is null or undefined
478
+ *
479
+ * @example
480
+ * ```typescript
481
+ * isNullOrUndefined(null) // true
482
+ * isNullOrUndefined(undefined) // true
483
+ * isNullOrUndefined(0) // false
484
+ * isNullOrUndefined("") // false
485
+ * isNullOrUndefined(false) // false
486
+ * ```
487
+ *
488
+ * @usage
489
+ * ```typescript
490
+ * // Optional property validation
491
+ * interface User {
492
+ * id: number;
493
+ * email?: string;
494
+ * }
495
+ *
496
+ * function validateUser(data: unknown): User | null {
497
+ * if (!isObject(data)) return null;
498
+ *
499
+ * const { id, email } = data as any;
500
+ *
501
+ * if (!isNumber(id)) return null;
502
+ * if (!isNullOrUndefined(email) && !isString(email)) {
503
+ * return null;
504
+ * }
505
+ *
506
+ * return { id, email };
507
+ * }
508
+ *
509
+ * // Provide defaults for undefined
510
+ * function getWithDefault<T>(value: T | null | undefined, defaultValue: T): T {
511
+ * return isNullOrUndefined(value) ? defaultValue : value;
512
+ * }
513
+ * ```
514
+ */
515
+ export declare function isNullOrUndefined(value: unknown): value is null | undefined;
516
+ /**
517
+ * Checks if a value is not null or undefined (type guard for non-nullish).
518
+ *
519
+ * Useful in filter operations and optional chaining scenarios.
520
+ *
521
+ * @param value - The value to check
522
+ * @returns true if value is not null or undefined
523
+ *
524
+ * @example
525
+ * ```typescript
526
+ * isDefined("text") // true
527
+ * isDefined(0) // true
528
+ * isDefined(false) // true
529
+ * isDefined([]) // true
530
+ * isDefined(null) // false
531
+ * isDefined(undefined) // false
532
+ * ```
533
+ *
534
+ * @usage
535
+ * ```typescript
536
+ * // Filter nullish values from arrays
537
+ * const values = [1, null, 2, undefined, 3];
538
+ * const filtered = values.filter(isDefined);
539
+ * // Result: [1, 2, 3]
540
+ *
541
+ * // Type narrowing in conditional
542
+ * function process(value: string | null) {
543
+ * if (isDefined(value)) {
544
+ * // TypeScript knows value is string (never null)
545
+ * console.log(value.toUpperCase());
546
+ * }
547
+ * }
548
+ * ```
549
+ */
550
+ export declare function isDefined<T>(value: T | null | undefined): value is T;
551
+ /**
552
+ * Checks if an object has a specific property (type guard for discriminated unions).
553
+ *
554
+ * Enables property-based type narrowing for discriminated unions and polymorphic types.
555
+ *
556
+ * @param obj - The object to check
557
+ * @param prop - The property name to look for
558
+ * @returns true if object has the property
559
+ *
560
+ * @example
561
+ * ```typescript
562
+ * interface Success { success: true; data: string }
563
+ * interface Error { error: true; message: string }
564
+ * type Result = Success | Error;
565
+ *
566
+ * const result: Result = { success: true, data: "ok" };
567
+ *
568
+ * if (hasProperty(result, 'success')) {
569
+ * // TypeScript narrows to Success
570
+ * console.log(result.data);
571
+ * }
572
+ * ```
573
+ *
574
+ * @usage
575
+ * ```typescript
576
+ * // Discriminate union types
577
+ * function handleResult(result: unknown) {
578
+ * if (isObject(result)) {
579
+ * if (hasProperty(result, 'error')) {
580
+ * console.error(result.error);
581
+ * } else if (hasProperty(result, 'data')) {
582
+ * console.log(result.data);
583
+ * }
584
+ * }
585
+ * }
586
+ * ```
587
+ */
588
+ export declare function hasProperty<T extends object, K extends PropertyKey>(obj: T, prop: K): obj is T & Record<K, unknown>;
589
+ /**
590
+ * Type guard for array elements of a specific type.
591
+ *
592
+ * Validates all array elements match a predicate function.
593
+ *
594
+ * @param arr - The array to check
595
+ * @param guard - The type guard function for elements
596
+ * @returns true if all elements pass the guard
597
+ *
598
+ * @example
599
+ * ```typescript
600
+ * const data = [1, 2, 3];
601
+ * if (isArrayOf(data, isNumber)) {
602
+ * // TypeScript knows data is number[]
603
+ * const sum = data.reduce((a, b) => a + b, 0);
604
+ * }
605
+ * ```
606
+ *
607
+ * @usage
608
+ * ```typescript
609
+ * // Validate API response array
610
+ * interface User { id: number; name: string }
611
+ *
612
+ * function isUser(obj: unknown): obj is User {
613
+ * return isObject(obj) &&
614
+ * isNumber((obj as any).id) &&
615
+ * isString((obj as any).name);
616
+ * }
617
+ *
618
+ * function processUsers(data: unknown) {
619
+ * if (isArray(data) && isArrayOf(data, isUser)) {
620
+ * // TypeScript knows data is User[]
621
+ * data.forEach(user => {
622
+ * console.log(user.name);
623
+ * });
624
+ * }
625
+ * }
626
+ * ```
627
+ */
628
+ export declare function isArrayOf<T>(arr: unknown, guard: (value: unknown) => value is T): arr is T[];
629
+ //# sourceMappingURL=type-guards.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-guards.d.ts","sourceRoot":"","sources":["../../src/utils/type-guards.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,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