@gzl10/ts-helpers 4.2.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 (240) hide show
  1. package/CHANGELOG.md +320 -0
  2. package/README.md +233 -0
  3. package/USAGE-GUIDE.md +800 -0
  4. package/dist/browser/async.js +15 -0
  5. package/dist/browser/async.js.map +1 -0
  6. package/dist/browser/chunk-4O7ZPIJN.js +383 -0
  7. package/dist/browser/chunk-4O7ZPIJN.js.map +1 -0
  8. package/dist/browser/chunk-75XNTC34.js +60 -0
  9. package/dist/browser/chunk-75XNTC34.js.map +1 -0
  10. package/dist/browser/chunk-C3D7YZVE.js +299 -0
  11. package/dist/browser/chunk-C3D7YZVE.js.map +1 -0
  12. package/dist/browser/chunk-CZL6C2EI.js +452 -0
  13. package/dist/browser/chunk-CZL6C2EI.js.map +1 -0
  14. package/dist/browser/chunk-D4FZFIVA.js +240 -0
  15. package/dist/browser/chunk-D4FZFIVA.js.map +1 -0
  16. package/dist/browser/chunk-IL7NG7IC.js +72 -0
  17. package/dist/browser/chunk-IL7NG7IC.js.map +1 -0
  18. package/dist/browser/chunk-NSBPE2FW.js +17 -0
  19. package/dist/browser/chunk-NSBPE2FW.js.map +1 -0
  20. package/dist/browser/chunk-SLQVNPTH.js +27 -0
  21. package/dist/browser/chunk-SLQVNPTH.js.map +1 -0
  22. package/dist/browser/chunk-WG7ILCUB.js +195 -0
  23. package/dist/browser/chunk-WG7ILCUB.js.map +1 -0
  24. package/dist/browser/chunk-WJA4JDMZ.js +278 -0
  25. package/dist/browser/chunk-WJA4JDMZ.js.map +1 -0
  26. package/dist/browser/chunk-ZFVYLUTT.js +65 -0
  27. package/dist/browser/chunk-ZFVYLUTT.js.map +1 -0
  28. package/dist/browser/chunk-ZYTSVMTI.js +263 -0
  29. package/dist/browser/chunk-ZYTSVMTI.js.map +1 -0
  30. package/dist/browser/dates.js +78 -0
  31. package/dist/browser/dates.js.map +1 -0
  32. package/dist/browser/environment-detection.js +21 -0
  33. package/dist/browser/environment-detection.js.map +1 -0
  34. package/dist/browser/environment.js +34 -0
  35. package/dist/browser/environment.js.map +1 -0
  36. package/dist/browser/errors.js +18 -0
  37. package/dist/browser/errors.js.map +1 -0
  38. package/dist/browser/index.js +412 -0
  39. package/dist/browser/index.js.map +1 -0
  40. package/dist/browser/math.js +51 -0
  41. package/dist/browser/math.js.map +1 -0
  42. package/dist/browser/number.js +10 -0
  43. package/dist/browser/number.js.map +1 -0
  44. package/dist/browser/objects.js +31 -0
  45. package/dist/browser/objects.js.map +1 -0
  46. package/dist/browser/strings.js +80 -0
  47. package/dist/browser/strings.js.map +1 -0
  48. package/dist/browser/validation-core.js +54 -0
  49. package/dist/browser/validation-core.js.map +1 -0
  50. package/dist/browser/validation-crypto.js +28 -0
  51. package/dist/browser/validation-crypto.js.map +1 -0
  52. package/dist/browser/validators.js +98 -0
  53. package/dist/browser/validators.js.map +1 -0
  54. package/dist/cjs/async.js +86 -0
  55. package/dist/cjs/async.js.map +1 -0
  56. package/dist/cjs/dates.js +285 -0
  57. package/dist/cjs/dates.js.map +1 -0
  58. package/dist/cjs/environment-detection.js +84 -0
  59. package/dist/cjs/environment-detection.js.map +1 -0
  60. package/dist/cjs/environment.js +261 -0
  61. package/dist/cjs/environment.js.map +1 -0
  62. package/dist/cjs/errors.js +80 -0
  63. package/dist/cjs/errors.js.map +1 -0
  64. package/dist/cjs/index.js +2035 -0
  65. package/dist/cjs/index.js.map +1 -0
  66. package/dist/cjs/math.js +388 -0
  67. package/dist/cjs/math.js.map +1 -0
  68. package/dist/cjs/number.js +37 -0
  69. package/dist/cjs/number.js.map +1 -0
  70. package/dist/cjs/objects.js +249 -0
  71. package/dist/cjs/objects.js.map +1 -0
  72. package/dist/cjs/strings.js +253 -0
  73. package/dist/cjs/strings.js.map +1 -0
  74. package/dist/cjs/validation.js +450 -0
  75. package/dist/cjs/validation.js.map +1 -0
  76. package/dist/esm/async.js +15 -0
  77. package/dist/esm/async.js.map +1 -0
  78. package/dist/esm/chunk-4O7ZPIJN.js +383 -0
  79. package/dist/esm/chunk-4O7ZPIJN.js.map +1 -0
  80. package/dist/esm/chunk-75XNTC34.js +60 -0
  81. package/dist/esm/chunk-75XNTC34.js.map +1 -0
  82. package/dist/esm/chunk-BDOBKBKA.js +72 -0
  83. package/dist/esm/chunk-BDOBKBKA.js.map +1 -0
  84. package/dist/esm/chunk-C3D7YZVE.js +299 -0
  85. package/dist/esm/chunk-C3D7YZVE.js.map +1 -0
  86. package/dist/esm/chunk-CZL6C2EI.js +452 -0
  87. package/dist/esm/chunk-CZL6C2EI.js.map +1 -0
  88. package/dist/esm/chunk-EBLSTOEC.js +263 -0
  89. package/dist/esm/chunk-EBLSTOEC.js.map +1 -0
  90. package/dist/esm/chunk-NSBPE2FW.js +17 -0
  91. package/dist/esm/chunk-NSBPE2FW.js.map +1 -0
  92. package/dist/esm/chunk-SLQVNPTH.js +27 -0
  93. package/dist/esm/chunk-SLQVNPTH.js.map +1 -0
  94. package/dist/esm/chunk-WG7ILCUB.js +195 -0
  95. package/dist/esm/chunk-WG7ILCUB.js.map +1 -0
  96. package/dist/esm/chunk-WJA4JDMZ.js +278 -0
  97. package/dist/esm/chunk-WJA4JDMZ.js.map +1 -0
  98. package/dist/esm/chunk-ZFVYLUTT.js +65 -0
  99. package/dist/esm/chunk-ZFVYLUTT.js.map +1 -0
  100. package/dist/esm/dates.js +78 -0
  101. package/dist/esm/dates.js.map +1 -0
  102. package/dist/esm/environment-detection.js +21 -0
  103. package/dist/esm/environment-detection.js.map +1 -0
  104. package/dist/esm/environment.js +34 -0
  105. package/dist/esm/environment.js.map +1 -0
  106. package/dist/esm/errors.js +18 -0
  107. package/dist/esm/errors.js.map +1 -0
  108. package/dist/esm/index.js +380 -0
  109. package/dist/esm/index.js.map +1 -0
  110. package/dist/esm/math.js +51 -0
  111. package/dist/esm/math.js.map +1 -0
  112. package/dist/esm/number.js +10 -0
  113. package/dist/esm/number.js.map +1 -0
  114. package/dist/esm/objects.js +31 -0
  115. package/dist/esm/objects.js.map +1 -0
  116. package/dist/esm/strings.js +80 -0
  117. package/dist/esm/strings.js.map +1 -0
  118. package/dist/esm/validation.js +54 -0
  119. package/dist/esm/validation.js.map +1 -0
  120. package/dist/node/async.js +93 -0
  121. package/dist/node/async.js.map +1 -0
  122. package/dist/node/csv.js +102 -0
  123. package/dist/node/csv.js.map +1 -0
  124. package/dist/node/data.js +880 -0
  125. package/dist/node/data.js.map +1 -0
  126. package/dist/node/dates.js +324 -0
  127. package/dist/node/dates.js.map +1 -0
  128. package/dist/node/environment.js +278 -0
  129. package/dist/node/environment.js.map +1 -0
  130. package/dist/node/errors.js +89 -0
  131. package/dist/node/errors.js.map +1 -0
  132. package/dist/node/index.js +3151 -0
  133. package/dist/node/index.js.map +1 -0
  134. package/dist/node/json.js +107 -0
  135. package/dist/node/json.js.map +1 -0
  136. package/dist/node/math.js +413 -0
  137. package/dist/node/math.js.map +1 -0
  138. package/dist/node/number.js +42 -0
  139. package/dist/node/number.js.map +1 -0
  140. package/dist/node/objects.js +264 -0
  141. package/dist/node/objects.js.map +1 -0
  142. package/dist/node/strings.js +293 -0
  143. package/dist/node/strings.js.map +1 -0
  144. package/dist/node/tree.js +89 -0
  145. package/dist/node/tree.js.map +1 -0
  146. package/dist/node/validation-core.js +477 -0
  147. package/dist/node/validation-core.js.map +1 -0
  148. package/dist/node/validation-crypto.js +179 -0
  149. package/dist/node/validation-crypto.js.map +1 -0
  150. package/dist/node/validation.js +677 -0
  151. package/dist/node/validation.js.map +1 -0
  152. package/dist/node/validators.js +123 -0
  153. package/dist/node/validators.js.map +1 -0
  154. package/dist/node-esm/async.js +15 -0
  155. package/dist/node-esm/async.js.map +1 -0
  156. package/dist/node-esm/chunk-3YOF7NPT.js +299 -0
  157. package/dist/node-esm/chunk-3YOF7NPT.js.map +1 -0
  158. package/dist/node-esm/chunk-64TBXJQS.js +263 -0
  159. package/dist/node-esm/chunk-64TBXJQS.js.map +1 -0
  160. package/dist/node-esm/chunk-75XNTC34.js +60 -0
  161. package/dist/node-esm/chunk-75XNTC34.js.map +1 -0
  162. package/dist/node-esm/chunk-C4PKXIPB.js +278 -0
  163. package/dist/node-esm/chunk-C4PKXIPB.js.map +1 -0
  164. package/dist/node-esm/chunk-CMDFZME3.js +452 -0
  165. package/dist/node-esm/chunk-CMDFZME3.js.map +1 -0
  166. package/dist/node-esm/chunk-DZZPUYMP.js +74 -0
  167. package/dist/node-esm/chunk-DZZPUYMP.js.map +1 -0
  168. package/dist/node-esm/chunk-HTSEHRHI.js +195 -0
  169. package/dist/node-esm/chunk-HTSEHRHI.js.map +1 -0
  170. package/dist/node-esm/chunk-JCAUVOPH.js +27 -0
  171. package/dist/node-esm/chunk-JCAUVOPH.js.map +1 -0
  172. package/dist/node-esm/chunk-KBHE3K2F.js +505 -0
  173. package/dist/node-esm/chunk-KBHE3K2F.js.map +1 -0
  174. package/dist/node-esm/chunk-LYTET5NX.js +65 -0
  175. package/dist/node-esm/chunk-LYTET5NX.js.map +1 -0
  176. package/dist/node-esm/chunk-PZ5AY32C.js +10 -0
  177. package/dist/node-esm/chunk-PZ5AY32C.js.map +1 -0
  178. package/dist/node-esm/chunk-UKGXL2QO.js +383 -0
  179. package/dist/node-esm/chunk-UKGXL2QO.js.map +1 -0
  180. package/dist/node-esm/chunk-XAEYT23H.js +164 -0
  181. package/dist/node-esm/chunk-XAEYT23H.js.map +1 -0
  182. package/dist/node-esm/csv.js +63 -0
  183. package/dist/node-esm/csv.js.map +1 -0
  184. package/dist/node-esm/data.js +32 -0
  185. package/dist/node-esm/data.js.map +1 -0
  186. package/dist/node-esm/dates.js +78 -0
  187. package/dist/node-esm/dates.js.map +1 -0
  188. package/dist/node-esm/environment.js +34 -0
  189. package/dist/node-esm/environment.js.map +1 -0
  190. package/dist/node-esm/errors.js +18 -0
  191. package/dist/node-esm/errors.js.map +1 -0
  192. package/dist/node-esm/index.js +426 -0
  193. package/dist/node-esm/index.js.map +1 -0
  194. package/dist/node-esm/json.js +68 -0
  195. package/dist/node-esm/json.js.map +1 -0
  196. package/dist/node-esm/math.js +51 -0
  197. package/dist/node-esm/math.js.map +1 -0
  198. package/dist/node-esm/number.js +10 -0
  199. package/dist/node-esm/number.js.map +1 -0
  200. package/dist/node-esm/objects.js +31 -0
  201. package/dist/node-esm/objects.js.map +1 -0
  202. package/dist/node-esm/strings.js +80 -0
  203. package/dist/node-esm/strings.js.map +1 -0
  204. package/dist/node-esm/tree.js +8 -0
  205. package/dist/node-esm/tree.js.map +1 -0
  206. package/dist/node-esm/validation-core.js +54 -0
  207. package/dist/node-esm/validation-core.js.map +1 -0
  208. package/dist/node-esm/validation-crypto.js +26 -0
  209. package/dist/node-esm/validation-crypto.js.map +1 -0
  210. package/dist/node-esm/validation.js +606 -0
  211. package/dist/node-esm/validation.js.map +1 -0
  212. package/dist/node-esm/validators.js +98 -0
  213. package/dist/node-esm/validators.js.map +1 -0
  214. package/dist/types/async-C8gvbSG-.d.ts +453 -0
  215. package/dist/types/async.d.ts +1 -0
  216. package/dist/types/csv.d.ts +226 -0
  217. package/dist/types/data.d.ts +1561 -0
  218. package/dist/types/dates-hTiE0Z11.d.ts +298 -0
  219. package/dist/types/dates.d.ts +1 -0
  220. package/dist/types/environment-B8eLS7KT.d.ts +420 -0
  221. package/dist/types/environment-detection.d.ts +102 -0
  222. package/dist/types/environment.d.ts +1 -0
  223. package/dist/types/errors.d.ts +147 -0
  224. package/dist/types/index.d.ts +211 -0
  225. package/dist/types/json.d.ts +284 -0
  226. package/dist/types/math-BQ9Lwdp7.d.ts +2060 -0
  227. package/dist/types/math.d.ts +1 -0
  228. package/dist/types/number-CYnQfLWj.d.ts +44 -0
  229. package/dist/types/number.d.ts +1 -0
  230. package/dist/types/objects-BohS8GCS.d.ts +1185 -0
  231. package/dist/types/objects.d.ts +1 -0
  232. package/dist/types/strings-CiqRPYLL.d.ts +1349 -0
  233. package/dist/types/strings.d.ts +1 -0
  234. package/dist/types/tree.d.ts +284 -0
  235. package/dist/types/validation-core-DfHF8rCG.d.ts +238 -0
  236. package/dist/types/validation-crypto-browser.d.ts +56 -0
  237. package/dist/types/validation-crypto-node.d.ts +31 -0
  238. package/dist/types/validation.d.ts +1 -0
  239. package/dist/types/validators.d.ts +216 -0
  240. package/package.json +253 -0
@@ -0,0 +1 @@
1
+ export { j as capitalizeEachWord, i as capitalizeFirst, c as cleanJsonChars, o as contains, C as countOccurrences, q as endsWith, e as ensureEndsWith, d as ensureStartsWith, K as envKeyToPath, H as escapeHtmlChars, E as isEmail, D as isEmpty, J as matchPathPattern, v as padEnd, r as padStart, L as pathToEnvKey, G as removeAccents, A as repeatString, B as replaceAllOccurrences, z as reverseString, a as sanitizeString, p as startsWith, b as stripFromEnd, f as stripFromStart, k as toCamelCase, m as toKebabCase, g as toLowerCase, n as toPascalCase, l as toSnakeCase, h as toUpperCase, F as toUrlSlug, w as trim, y as trimEnd, x as trimStart, t as truncateString, I as unescapeHtmlChars, u as unescapeUnicode } from './strings-CiqRPYLL.js';
@@ -0,0 +1,284 @@
1
+ /**
2
+ * Tree Structure Rendering Utilities
3
+ *
4
+ * Provides ASCII/Unicode tree visualization for hierarchical data structures.
5
+ * Features:
6
+ * - Customizable box-drawing characters (Unicode or ASCII)
7
+ * - Flexible label extraction (field name or custom function)
8
+ * - Recursive rendering with proper indentation
9
+ * - Multiple root support
10
+ * - Zero dependencies
11
+ *
12
+ * @module tree
13
+ */
14
+ /**
15
+ * Configuration options for tree rendering
16
+ *
17
+ * Controls the visual appearance and label extraction strategy for ASCII/Unicode tree output.
18
+ * All options have sensible defaults for immediate use with Unicode box-drawing characters.
19
+ *
20
+ * @property labelField - Object property name to use as node label (default: 'name')
21
+ * @property verticalLine - Character sequence for vertical continuation (default: '│ ')
22
+ * @property middleBranch - Character sequence for non-last child branch (default: '├── ')
23
+ * @property lastBranch - Character sequence for last child branch (default: '└── ')
24
+ * @property emptySpace - Character sequence for empty space after last branch (default: ' ')
25
+ * @property labelFunction - Custom function to extract/format node labels (overrides labelField)
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * // Unicode box-drawing (default)
30
+ * const unicodeOptions: TreeExportOptions = {
31
+ * labelField: 'name',
32
+ * verticalLine: '│ ',
33
+ * middleBranch: '├── ',
34
+ * lastBranch: '└── ',
35
+ * emptySpace: ' '
36
+ * }
37
+ *
38
+ * // ASCII alternative (better compatibility)
39
+ * const asciiOptions: TreeExportOptions = {
40
+ * verticalLine: '| ',
41
+ * middleBranch: '+-- ',
42
+ * lastBranch: '`-- ',
43
+ * emptySpace: ' '
44
+ * }
45
+ *
46
+ * // Custom label function
47
+ * const customOptions: TreeExportOptions = {
48
+ * labelFunction: (node) => `${node.type}: ${node.name} (${node.size})`
49
+ * }
50
+ * ```
51
+ */
52
+ interface TreeExportOptions {
53
+ labelField?: string;
54
+ verticalLine?: string;
55
+ middleBranch?: string;
56
+ lastBranch?: string;
57
+ emptySpace?: string;
58
+ labelFunction?: (node: any) => string;
59
+ }
60
+ /**
61
+ * Renders hierarchical data as ASCII/Unicode tree visualization
62
+ *
63
+ * Converts nested object structures (with `children` arrays) into human-readable tree diagrams.
64
+ * Supports multiple root nodes and customizable rendering styles.
65
+ *
66
+ * Features:
67
+ * - **Recursive rendering**: Handles arbitrary depth
68
+ * - **Unicode box-drawing**: Beautiful output by default (│ ├ └)
69
+ * - **ASCII fallback**: Use simpler characters for compatibility
70
+ * - **Flexible labels**: Extract from field name or custom function
71
+ * - **Multiple roots**: Render forests (arrays of trees)
72
+ *
73
+ * Node Structure Requirements:
74
+ * - Each node must have a label (via `labelField` property or `labelFunction`)
75
+ * - Child nodes stored in `children` array property
76
+ * - No `children` property = leaf node
77
+ *
78
+ * @param data - Array of root nodes (each with optional `children` property)
79
+ * @param options - Rendering options (characters, label extraction)
80
+ * @returns String containing the complete tree visualization with newlines
81
+ *
82
+ * @example
83
+ * ```typescript
84
+ * // Basic usage - Simple file tree
85
+ * const fileTree = [
86
+ * {
87
+ * name: 'src',
88
+ * children: [
89
+ * { name: 'index.ts' },
90
+ * { name: 'utils.ts' },
91
+ * {
92
+ * name: 'components',
93
+ * children: [
94
+ * { name: 'Button.tsx' },
95
+ * { name: 'Input.tsx' }
96
+ * ]
97
+ * }
98
+ * ]
99
+ * }
100
+ * ]
101
+ *
102
+ * console.log(renderTreeAsText(fileTree))
103
+ * // Output:
104
+ * // └── src
105
+ * // ├── index.ts
106
+ * // ├── utils.ts
107
+ * // └── components
108
+ * // ├── Button.tsx
109
+ * // └── Input.tsx
110
+ * ```
111
+ *
112
+ * @example
113
+ * ```typescript
114
+ * // Multiple roots - Project structure
115
+ * const projectTree = [
116
+ * {
117
+ * name: 'packages',
118
+ * children: [
119
+ * { name: 'core' },
120
+ * { name: 'ui' }
121
+ * ]
122
+ * },
123
+ * {
124
+ * name: 'apps',
125
+ * children: [
126
+ * { name: 'web' },
127
+ * { name: 'mobile' }
128
+ * ]
129
+ * }
130
+ * ]
131
+ *
132
+ * console.log(renderTreeAsText(projectTree))
133
+ * // Output:
134
+ * // ├── packages
135
+ * // │ ├── core
136
+ * // │ └── ui
137
+ * // └── apps
138
+ * // ├── web
139
+ * // └── mobile
140
+ * ```
141
+ *
142
+ * @example
143
+ * ```typescript
144
+ * // Custom label field - Organization chart
145
+ * const orgChart = [
146
+ * {
147
+ * title: 'CEO',
148
+ * children: [
149
+ * {
150
+ * title: 'CTO',
151
+ * children: [
152
+ * { title: 'Dev Lead' },
153
+ * { title: 'QA Lead' }
154
+ * ]
155
+ * },
156
+ * { title: 'CFO' }
157
+ * ]
158
+ * }
159
+ * ]
160
+ *
161
+ * console.log(renderTreeAsText(orgChart, { labelField: 'title' }))
162
+ * // Output:
163
+ * // └── CEO
164
+ * // ├── CTO
165
+ * // │ ├── Dev Lead
166
+ * // │ └── QA Lead
167
+ * // └── CFO
168
+ * ```
169
+ *
170
+ * @example
171
+ * ```typescript
172
+ * // Custom label function - Rich formatting
173
+ * const tasks = [
174
+ * {
175
+ * name: 'Backend',
176
+ * status: 'in-progress',
177
+ * assignee: 'Alice',
178
+ * children: [
179
+ * { name: 'API', status: 'done', assignee: 'Bob' },
180
+ * { name: 'Database', status: 'pending', assignee: 'Charlie' }
181
+ * ]
182
+ * }
183
+ * ]
184
+ *
185
+ * const rendered = renderTreeAsText(tasks, {
186
+ * labelFunction: (node) => `[${node.status}] ${node.name} (@${node.assignee})`
187
+ * })
188
+ *
189
+ * console.log(rendered)
190
+ * // Output:
191
+ * // └── [in-progress] Backend (@Alice)
192
+ * // ├── [done] API (@Bob)
193
+ * // └── [pending] Database (@Charlie)
194
+ * ```
195
+ *
196
+ * @example
197
+ * ```typescript
198
+ * // ASCII characters - Better terminal compatibility
199
+ * const tree = [
200
+ * {
201
+ * name: 'root',
202
+ * children: [
203
+ * { name: 'child1' },
204
+ * { name: 'child2' }
205
+ * ]
206
+ * }
207
+ * ]
208
+ *
209
+ * console.log(renderTreeAsText(tree, {
210
+ * verticalLine: '| ',
211
+ * middleBranch: '+-- ',
212
+ * lastBranch: '`-- ',
213
+ * emptySpace: ' '
214
+ * }))
215
+ * // Output:
216
+ * // `-- root
217
+ * // +-- child1
218
+ * // `-- child2
219
+ * ```
220
+ *
221
+ * @example
222
+ * ```typescript
223
+ * // Real-world: File system visualization
224
+ * async function visualizeDirectory(dirPath: string) {
225
+ * const tree = await buildDirectoryTree(dirPath)
226
+ *
227
+ * console.log(`Directory structure of ${dirPath}:`)
228
+ * console.log(renderTreeAsText(tree, {
229
+ * labelFunction: (node) => {
230
+ * const icon = node.type === 'dir' ? '📁' : '📄'
231
+ * return `${icon} ${node.name}`
232
+ * }
233
+ * }))
234
+ * }
235
+ * ```
236
+ *
237
+ * @example
238
+ * ```typescript
239
+ * // Real-world: Dependency tree analysis
240
+ * function visualizeDependencies(packageName: string) {
241
+ * const deps = analyzeDependencies(packageName)
242
+ *
243
+ * console.log(`Dependencies of ${packageName}:`)
244
+ * console.log(renderTreeAsText(deps, {
245
+ * labelFunction: (node) => `${node.name}@${node.version} (${node.size})`
246
+ * }))
247
+ * }
248
+ * ```
249
+ *
250
+ * @example
251
+ * ```typescript
252
+ * // Edge case: Empty tree
253
+ * console.log(renderTreeAsText([])) // Returns empty string
254
+ *
255
+ * // Edge case: Leaf nodes only
256
+ * const leaves = [{ name: 'item1' }, { name: 'item2' }]
257
+ * console.log(renderTreeAsText(leaves))
258
+ * // Output:
259
+ * // ├── item1
260
+ * // └── item2
261
+ *
262
+ * // Edge case: Deep nesting
263
+ * const deep = [
264
+ * {
265
+ * name: 'level1',
266
+ * children: [
267
+ * {
268
+ * name: 'level2',
269
+ * children: [
270
+ * { name: 'level3' }
271
+ * ]
272
+ * }
273
+ * ]
274
+ * }
275
+ * ]
276
+ * console.log(renderTreeAsText(deep))
277
+ * // Handles arbitrary depth correctly
278
+ * ```
279
+ *
280
+ * @see {@link TreeExportOptions} for configuration details
281
+ */
282
+ declare function renderTreeAsText(data: any[], options?: TreeExportOptions): string;
283
+
284
+ export { type TreeExportOptions, renderTreeAsText };
@@ -0,0 +1,238 @@
1
+ /**
2
+ * Core validation utilities - Universal (Browser + Node.js compatible)
3
+ * NO crypto dependencies - safe for all environments
4
+ */
5
+ /**
6
+ * Generates a random integer between min and max (inclusive)
7
+ * @param min - Minimum value (default: 0)
8
+ * @param max - Maximum value (default: 100)
9
+ * @returns Random integer between min and max
10
+ * @example
11
+ * ```ts
12
+ * const dice = generateRandomInteger(1, 6) // 1, 2, 3, 4, 5, or 6
13
+ * const percent = generateRandomInteger(0, 100) // 0 to 100
14
+ * const id = generateRandomInteger(1000, 9999) // 4-digit ID
15
+ * ```
16
+ */
17
+ declare const generateRandomInteger: (min?: number, max?: number) => number;
18
+ /**
19
+ * Generates a random alphabetic string (letters only)
20
+ * @param options - Configuration object
21
+ * @param options.length - Length of the string (default: 10)
22
+ * @param options.casing - Case transformation: 'upper', 'lower', or undefined
23
+ * @returns Random alphabetic string
24
+ * @example
25
+ * ```ts
26
+ * const name = generateAlphaString({ length: 8 }) // "AbCdEfGh"
27
+ * const upper = generateAlphaString({ length: 5, casing: 'upper' }) // "ABCDE"
28
+ * const lower = generateAlphaString({ length: 3, casing: 'lower' }) // "abc"
29
+ * ```
30
+ */
31
+ declare const generateAlphaString: (options?: {
32
+ length?: number;
33
+ casing?: "upper" | "lower" | undefined;
34
+ }) => string;
35
+ /**
36
+ * Generates a random alphanumeric string (letters and numbers)
37
+ * @param options - Configuration object
38
+ * @param options.length - Length of the string (default: 10)
39
+ * @param options.casing - Case transformation: 'upper', 'lower', or undefined
40
+ * @returns Random alphanumeric string
41
+ * @example
42
+ * ```ts
43
+ * const token = generateAlphaNumericString({ length: 12 }) // "aB3cD4eF5gH6"
44
+ * const code = generateAlphaNumericString({ length: 6, casing: 'upper' }) // "A1B2C3"
45
+ * const key = generateAlphaNumericString({ length: 8, casing: 'lower' }) // "a1b2c3d4"
46
+ * ```
47
+ */
48
+ declare const generateAlphaNumericString: (options?: {
49
+ length?: number;
50
+ casing?: "upper" | "lower" | undefined;
51
+ }) => string;
52
+ /**
53
+ * Generates a random complex string with all characters (letters, numbers, symbols)
54
+ * @param options - Configuration object
55
+ * @param options.length - Length of the string (default: 10)
56
+ * @param options.casing - Case transformation (currently not applied to symbols)
57
+ * @returns Random complex string
58
+ * @example
59
+ * ```ts
60
+ * const password = generateComplexString({ length: 16 }) // "aB3#cD4$eF5%gH6"
61
+ * const secret = generateComplexString({ length: 32 }) // Complex 32-char string
62
+ * const temp = generateComplexString() // 10 characters by default
63
+ * ```
64
+ */
65
+ declare const generateComplexString: (options?: {
66
+ length?: number;
67
+ casing?: "upper" | "lower" | undefined;
68
+ }) => string;
69
+ /**
70
+ * Generates a username from an email address
71
+ * @param email - Email address to extract username from
72
+ * @param randomDigits - Number of random digits to append (default: 1)
73
+ * @returns Username derived from email with random suffix
74
+ * @example
75
+ * ```ts
76
+ * const user1 = generateUsernameFromEmail('john.doe@example.com', 2) // "johndoe47"
77
+ * const user2 = generateUsernameFromEmail('maria-garcia@test.org', 3) // "mariagarcia823"
78
+ * const fallback = generateUsernameFromEmail('invalid-email', 2) // "user42"
79
+ * ```
80
+ */
81
+ declare const generateUsernameFromEmail: (email: string, randomDigits?: number) => string;
82
+ /**
83
+ * Generates a random username with adjective + noun pattern
84
+ * @param separator - Character to separate adjective and noun (default: '')
85
+ * @param randomDigits - Number of random digits to append (default: 1)
86
+ * @param length - Maximum length of username (default: 8)
87
+ * @returns Random username like "coolcat5" or "brave_wolf3"
88
+ * @example
89
+ * ```ts
90
+ * const user1 = generateUsername() // "coolcat5"
91
+ * const user2 = generateUsername('_', 2) // "brave_wolf83"
92
+ * const user3 = generateUsername('-', 3, 15) // "smart-eagle247"
93
+ * ```
94
+ */
95
+ declare const generateUsername: (separator?: string, randomDigits?: number, length?: number) => string;
96
+ /**
97
+ * Generates a valid Spanish NIF (Número de Identificación Fiscal)
98
+ * @returns A valid NIF string in format '12345678Z'
99
+ * @example
100
+ * ```ts
101
+ * const nif1 = generateSpanishNIF() // "87654321T"
102
+ * const nif2 = generateSpanishNIF() // "12345678Z"
103
+ *
104
+ * // Verify it's valid
105
+ * const nif = generateSpanishNIF()
106
+ * console.log(validateNIF(nif)) // true
107
+ * ```
108
+ */
109
+ declare const generateSpanishNIF: () => string;
110
+ /**
111
+ * Generates a valid Spanish NIE (Número de Identidad de Extranjero)
112
+ * @returns A valid NIE string in format 'X1234567L'
113
+ * @example
114
+ * ```ts
115
+ * const nie1 = generateSpanishNIE() // "X1234567L"
116
+ * const nie2 = generateSpanishNIE() // "Y9876543R"
117
+ * const nie3 = generateSpanishNIE() // "Z2468135T"
118
+ *
119
+ * // Verify it's valid
120
+ * const nie = generateSpanishNIE()
121
+ * console.log(isValidNIE(nie)) // true
122
+ * ```
123
+ */
124
+ declare const generateSpanishNIE: () => string;
125
+ /**
126
+ * Generates a valid Spanish CIF (Código de Identificación Fiscal)
127
+ * @returns A valid CIF string in format 'A12345674' or 'B87654321'
128
+ * @example
129
+ * ```ts
130
+ * const cif1 = generateSpanishCIF() // "A12345674"
131
+ * const cif2 = generateSpanishCIF() // "B87654321"
132
+ * const cif3 = generateSpanishCIF() // "G28456789"
133
+ *
134
+ * // Verify it's valid
135
+ * const cif = generateSpanishCIF()
136
+ * console.log(isValidCIF(cif)) // true
137
+ *
138
+ * // Different organization types
139
+ * // A,B,E,H = Sociedades Anónimas/Limitadas
140
+ * // G,U = Fundaciones, asociaciones
141
+ * // N,P,Q,R,S,W = Organismos públicos
142
+ * ```
143
+ */
144
+ declare const generateSpanishCIF: () => string;
145
+ declare const generateSpanishPostalCode: () => string;
146
+ declare const generateSpanishIBAN: () => string;
147
+ declare const generateEmail: (domain?: string) => string;
148
+ declare const generatePassword: (options?: {
149
+ length?: number;
150
+ includeUppercase?: boolean;
151
+ includeLowercase?: boolean;
152
+ includeNumbers?: boolean;
153
+ includeSymbols?: boolean;
154
+ }) => string;
155
+ declare const generateHexColor: (shortFormat?: boolean) => string;
156
+ /**
157
+ * Validates a Spanish NIF (Número de Identificación Fiscal)
158
+ * @param nif - The NIF string to validate
159
+ * @returns true if the NIF is valid, false otherwise
160
+ * @example
161
+ * ```ts
162
+ * console.log(isValidNIF('12345678Z')) // true
163
+ * console.log(isValidNIF('87654321T')) // true
164
+ * console.log(isValidNIF('12345678A')) // false (wrong letter)
165
+ * console.log(isValidNIF('1234567Z')) // false (wrong length)
166
+ * console.log(isValidNIF('')) // false (empty)
167
+ *
168
+ * // Case insensitive and handles whitespace
169
+ * console.log(isValidNIF(' 12345678z ')) // true
170
+ * ```
171
+ */
172
+ declare const isValidNIF: (nif: string) => boolean;
173
+ /**
174
+ * Alias for isValidNIF - validates a Spanish NIF
175
+ * @param nif - The NIF string to validate
176
+ * @returns true if the NIF is valid, false otherwise
177
+ * @example
178
+ * ```ts
179
+ * console.log(validateNIF('12345678Z')) // true
180
+ * // Same functionality as isValidNIF
181
+ * ```
182
+ */
183
+ declare const validateNIF: (nif: string) => boolean;
184
+ /**
185
+ * Validates a Spanish NIE (Número de Identidad de Extranjero)
186
+ * @param nie - The NIE string to validate
187
+ * @returns true if the NIE is valid, false otherwise
188
+ * @example
189
+ * ```ts
190
+ * console.log(isValidNIE('X1234567L')) // true
191
+ * console.log(isValidNIE('Y9876543R')) // true
192
+ * console.log(isValidNIE('Z2468135T')) // true
193
+ * console.log(isValidNIE('X1234567A')) // false (wrong letter)
194
+ * console.log(isValidNIE('W1234567L')) // false (invalid prefix)
195
+ * console.log(isValidNIE('X123456L')) // false (wrong length)
196
+ *
197
+ * // Case insensitive and handles whitespace
198
+ * console.log(isValidNIE(' x1234567l ')) // true
199
+ * ```
200
+ */
201
+ declare const isValidNIE: (nie: string) => boolean;
202
+ declare const isValidCIF: (cif: string) => boolean;
203
+ declare const isValidSpanishPostalCode: (postalCode: string) => boolean;
204
+ declare const isValidSpanishPhone: (phone: string) => boolean;
205
+ declare const isValidEmail: (email: string) => boolean;
206
+ declare const isValidURL: (url: string) => boolean;
207
+ declare const isValidJSON: (str: string) => boolean;
208
+ declare const isValidSpanishIBAN: (iban: string) => boolean;
209
+
210
+ declare const validationCore_generateAlphaNumericString: typeof generateAlphaNumericString;
211
+ declare const validationCore_generateAlphaString: typeof generateAlphaString;
212
+ declare const validationCore_generateComplexString: typeof generateComplexString;
213
+ declare const validationCore_generateEmail: typeof generateEmail;
214
+ declare const validationCore_generateHexColor: typeof generateHexColor;
215
+ declare const validationCore_generatePassword: typeof generatePassword;
216
+ declare const validationCore_generateRandomInteger: typeof generateRandomInteger;
217
+ declare const validationCore_generateSpanishCIF: typeof generateSpanishCIF;
218
+ declare const validationCore_generateSpanishIBAN: typeof generateSpanishIBAN;
219
+ declare const validationCore_generateSpanishNIE: typeof generateSpanishNIE;
220
+ declare const validationCore_generateSpanishNIF: typeof generateSpanishNIF;
221
+ declare const validationCore_generateSpanishPostalCode: typeof generateSpanishPostalCode;
222
+ declare const validationCore_generateUsername: typeof generateUsername;
223
+ declare const validationCore_generateUsernameFromEmail: typeof generateUsernameFromEmail;
224
+ declare const validationCore_isValidCIF: typeof isValidCIF;
225
+ declare const validationCore_isValidEmail: typeof isValidEmail;
226
+ declare const validationCore_isValidJSON: typeof isValidJSON;
227
+ declare const validationCore_isValidNIE: typeof isValidNIE;
228
+ declare const validationCore_isValidNIF: typeof isValidNIF;
229
+ declare const validationCore_isValidSpanishIBAN: typeof isValidSpanishIBAN;
230
+ declare const validationCore_isValidSpanishPhone: typeof isValidSpanishPhone;
231
+ declare const validationCore_isValidSpanishPostalCode: typeof isValidSpanishPostalCode;
232
+ declare const validationCore_isValidURL: typeof isValidURL;
233
+ declare const validationCore_validateNIF: typeof validateNIF;
234
+ declare namespace validationCore {
235
+ export { validationCore_generateAlphaNumericString as generateAlphaNumericString, validationCore_generateAlphaString as generateAlphaString, validationCore_generateComplexString as generateComplexString, validationCore_generateEmail as generateEmail, validationCore_generateHexColor as generateHexColor, validationCore_generatePassword as generatePassword, validationCore_generateRandomInteger as generateRandomInteger, validationCore_generateSpanishCIF as generateSpanishCIF, validationCore_generateSpanishIBAN as generateSpanishIBAN, validationCore_generateSpanishNIE as generateSpanishNIE, validationCore_generateSpanishNIF as generateSpanishNIF, validationCore_generateSpanishPostalCode as generateSpanishPostalCode, validationCore_generateUsername as generateUsername, validationCore_generateUsernameFromEmail as generateUsernameFromEmail, validationCore_isValidCIF as isValidCIF, validationCore_isValidEmail as isValidEmail, validationCore_isValidJSON as isValidJSON, validationCore_isValidNIE as isValidNIE, validationCore_isValidNIF as isValidNIF, validationCore_isValidSpanishIBAN as isValidSpanishIBAN, validationCore_isValidSpanishPhone as isValidSpanishPhone, validationCore_isValidSpanishPostalCode as isValidSpanishPostalCode, validationCore_isValidURL as isValidURL, validationCore_validateNIF as validateNIF };
236
+ }
237
+
238
+ export { generateAlphaString as a, generateAlphaNumericString as b, generateComplexString as c, generateUsernameFromEmail as d, generateUsername as e, generateSpanishNIF as f, generateRandomInteger as g, generateSpanishNIE as h, generateSpanishCIF as i, generateSpanishPostalCode as j, generateSpanishIBAN as k, generateEmail as l, generatePassword as m, generateHexColor as n, isValidNIF as o, validateNIF as p, isValidNIE as q, isValidCIF as r, isValidSpanishPostalCode as s, isValidSpanishPhone as t, isValidEmail as u, validationCore as v, isValidURL as w, isValidJSON as x, isValidSpanishIBAN as y };
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Browser-specific validation utilities with Web Crypto API support
3
+ * Safe for browser environments - uses crypto.getRandomValues() and SubtleCrypto
4
+ */
5
+ interface PasswordCriteria {
6
+ minLength?: number;
7
+ requireUppercase?: boolean;
8
+ requireLowercase?: boolean;
9
+ requireNumbers?: boolean;
10
+ requireSpecialChars?: boolean;
11
+ maxLength?: number;
12
+ forbiddenPatterns?: string[];
13
+ }
14
+ interface PasswordValidationResult {
15
+ isValid: boolean;
16
+ errors: string[];
17
+ strength: 'weak' | 'fair' | 'good' | 'strong';
18
+ score: number;
19
+ }
20
+ declare const validatePassword: (password: string, criteria?: PasswordCriteria) => PasswordValidationResult;
21
+ declare const sanitizeHtml: (html: string) => string;
22
+ declare const isValidJWTFormat: (token: string) => boolean;
23
+ /**
24
+ * Browser-safe hash function with environment detection
25
+ * Attempts Web Crypto API first, falls back to simple hash
26
+ */
27
+ declare const hashString: (input: string, salt?: string) => Promise<string>;
28
+ /**
29
+ * Synchronous version of hashString for backward compatibility
30
+ */
31
+ declare const hashStringSync: (input: string, salt?: string) => string;
32
+ /**
33
+ * Browser-safe secure token generation with comprehensive environment checks
34
+ * Uses Web Crypto API when available, falls back to Node.js crypto, then Math.random
35
+ * @param length - Length of the token in characters (default: 32)
36
+ * @returns A secure hexadecimal token string
37
+ * @example
38
+ * ```ts
39
+ * const token = generateSecureToken(16)
40
+ * console.log(token) // "a1b2c3d4e5f67890"
41
+ *
42
+ * const shortToken = generateSecureToken(8)
43
+ * console.log(shortToken) // "a1b2c3d4"
44
+ * ```
45
+ */
46
+ declare const generateSecureToken: (length?: number) => string;
47
+ declare const isValidBase64: (input: string) => boolean;
48
+ declare const escapeShellCommand: (input: string) => string;
49
+ declare const isSecureUrl: (url: string) => boolean;
50
+ declare const removeDangerousChars: (input: string, replacement?: string) => string;
51
+ /**
52
+ * Browser-safe nonce generation with comprehensive environment detection
53
+ */
54
+ declare const generateNonce: (length?: number) => string;
55
+
56
+ export { type PasswordCriteria, type PasswordValidationResult, escapeShellCommand, generateNonce, generateSecureToken, hashString, hashStringSync, isSecureUrl, isValidBase64, isValidJWTFormat, removeDangerousChars, sanitizeHtml, validatePassword };
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Node.js-specific validation utilities with crypto support
3
+ * Uses Node.js crypto module for secure operations
4
+ */
5
+ interface PasswordCriteria {
6
+ minLength?: number;
7
+ requireUppercase?: boolean;
8
+ requireLowercase?: boolean;
9
+ requireNumbers?: boolean;
10
+ requireSpecialChars?: boolean;
11
+ maxLength?: number;
12
+ forbiddenPatterns?: string[];
13
+ }
14
+ interface PasswordValidationResult {
15
+ isValid: boolean;
16
+ errors: string[];
17
+ strength: 'weak' | 'fair' | 'good' | 'strong';
18
+ score: number;
19
+ }
20
+ declare const validatePassword: (password: string, criteria?: PasswordCriteria) => PasswordValidationResult;
21
+ declare const sanitizeHtml: (html: string) => string;
22
+ declare const isValidJWTFormat: (token: string) => boolean;
23
+ declare const hashString: (input: string, salt?: string) => string;
24
+ declare const generateSecureToken: (length?: number) => string;
25
+ declare const isValidBase64: (input: string) => boolean;
26
+ declare const escapeShellCommand: (input: string) => string;
27
+ declare const isSecureUrl: (url: string) => boolean;
28
+ declare const removeDangerousChars: (input: string, replacement?: string) => string;
29
+ declare const generateNonce: (length?: number) => string;
30
+
31
+ export { type PasswordCriteria, type PasswordValidationResult, escapeShellCommand, generateNonce, generateSecureToken, hashString, isSecureUrl, isValidBase64, isValidJWTFormat, removeDangerousChars, sanitizeHtml, validatePassword };
@@ -0,0 +1 @@
1
+ export { b as generateAlphaNumericString, a as generateAlphaString, c as generateComplexString, l as generateEmail, n as generateHexColor, m as generatePassword, g as generateRandomInteger, i as generateSpanishCIF, k as generateSpanishIBAN, h as generateSpanishNIE, f as generateSpanishNIF, j as generateSpanishPostalCode, e as generateUsername, d as generateUsernameFromEmail, r as isValidCIF, u as isValidEmail, x as isValidJSON, q as isValidNIE, o as isValidNIF, y as isValidSpanishIBAN, t as isValidSpanishPhone, s as isValidSpanishPostalCode, w as isValidURL, p as validateNIF } from './validation-core-DfHF8rCG.js';