@pawells/typescript-common 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (311) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +148 -0
  3. package/build/array/array-chunk.d.ts +10 -0
  4. package/build/array/array-chunk.d.ts.map +1 -0
  5. package/build/array/array-chunk.js +19 -0
  6. package/build/array/array-chunk.js.map +1 -0
  7. package/build/array/array-compact.d.ts +18 -0
  8. package/build/array/array-compact.d.ts.map +1 -0
  9. package/build/array/array-compact.js +22 -0
  10. package/build/array/array-compact.js.map +1 -0
  11. package/build/array/array-contains.d.ts +9 -0
  12. package/build/array/array-contains.d.ts.map +1 -0
  13. package/build/array/array-contains.js +13 -0
  14. package/build/array/array-contains.js.map +1 -0
  15. package/build/array/array-count-by.d.ts +21 -0
  16. package/build/array/array-count-by.d.ts.map +1 -0
  17. package/build/array/array-count-by.js +29 -0
  18. package/build/array/array-count-by.js.map +1 -0
  19. package/build/array/array-difference.d.ts +25 -0
  20. package/build/array/array-difference.d.ts.map +1 -0
  21. package/build/array/array-difference.js +34 -0
  22. package/build/array/array-difference.js.map +1 -0
  23. package/build/array/array-element.d.ts +7 -0
  24. package/build/array/array-element.d.ts.map +1 -0
  25. package/build/array/array-element.js +2 -0
  26. package/build/array/array-element.js.map +1 -0
  27. package/build/array/array-filter.d.ts +37 -0
  28. package/build/array/array-filter.d.ts.map +1 -0
  29. package/build/array/array-filter.js +78 -0
  30. package/build/array/array-filter.js.map +1 -0
  31. package/build/array/array-flatten.d.ts +16 -0
  32. package/build/array/array-flatten.d.ts.map +1 -0
  33. package/build/array/array-flatten.js +20 -0
  34. package/build/array/array-flatten.js.map +1 -0
  35. package/build/array/array-group-by.d.ts +13 -0
  36. package/build/array/array-group-by.d.ts.map +1 -0
  37. package/build/array/array-group-by.js +24 -0
  38. package/build/array/array-group-by.js.map +1 -0
  39. package/build/array/array-intersection.d.ts +25 -0
  40. package/build/array/array-intersection.d.ts.map +1 -0
  41. package/build/array/array-intersection.js +39 -0
  42. package/build/array/array-intersection.js.map +1 -0
  43. package/build/array/array-partition.d.ts +19 -0
  44. package/build/array/array-partition.d.ts.map +1 -0
  45. package/build/array/array-partition.js +32 -0
  46. package/build/array/array-partition.js.map +1 -0
  47. package/build/array/array-range.d.ts +18 -0
  48. package/build/array/array-range.d.ts.map +1 -0
  49. package/build/array/array-range.js +30 -0
  50. package/build/array/array-range.js.map +1 -0
  51. package/build/array/array-sample.d.ts +29 -0
  52. package/build/array/array-sample.d.ts.map +1 -0
  53. package/build/array/array-sample.js +19 -0
  54. package/build/array/array-sample.js.map +1 -0
  55. package/build/array/array-shuffle.d.ts +8 -0
  56. package/build/array/array-shuffle.d.ts.map +1 -0
  57. package/build/array/array-shuffle.js +19 -0
  58. package/build/array/array-shuffle.js.map +1 -0
  59. package/build/array/array-sort-by.d.ts +20 -0
  60. package/build/array/array-sort-by.d.ts.map +1 -0
  61. package/build/array/array-sort-by.js +31 -0
  62. package/build/array/array-sort-by.js.map +1 -0
  63. package/build/array/array-zip.d.ts +22 -0
  64. package/build/array/array-zip.d.ts.map +1 -0
  65. package/build/array/array-zip.js +25 -0
  66. package/build/array/array-zip.js.map +1 -0
  67. package/build/array/array.test.d.ts +2 -0
  68. package/build/array/array.test.d.ts.map +1 -0
  69. package/build/array/array.test.js +347 -0
  70. package/build/array/array.test.js.map +1 -0
  71. package/build/array/index.d.ts +27 -0
  72. package/build/array/index.d.ts.map +1 -0
  73. package/build/array/index.js +25 -0
  74. package/build/array/index.js.map +1 -0
  75. package/build/array/types.d.ts +32 -0
  76. package/build/array/types.d.ts.map +1 -0
  77. package/build/array/types.js +2 -0
  78. package/build/array/types.js.map +1 -0
  79. package/build/array/unique.d.ts +8 -0
  80. package/build/array/unique.d.ts.map +1 -0
  81. package/build/array/unique.js +13 -0
  82. package/build/array/unique.js.map +1 -0
  83. package/build/enum/enum-entries.d.ts +11 -0
  84. package/build/enum/enum-entries.d.ts.map +1 -0
  85. package/build/enum/enum-entries.js +14 -0
  86. package/build/enum/enum-entries.js.map +1 -0
  87. package/build/enum/enum-key-by-value.d.ts +13 -0
  88. package/build/enum/enum-key-by-value.d.ts.map +1 -0
  89. package/build/enum/enum-key-by-value.js +21 -0
  90. package/build/enum/enum-key-by-value.js.map +1 -0
  91. package/build/enum/enum-keys.d.ts +10 -0
  92. package/build/enum/enum-keys.d.ts.map +1 -0
  93. package/build/enum/enum-keys.js +14 -0
  94. package/build/enum/enum-keys.js.map +1 -0
  95. package/build/enum/enum-safe-value.d.ts +14 -0
  96. package/build/enum/enum-safe-value.d.ts.map +1 -0
  97. package/build/enum/enum-safe-value.js +16 -0
  98. package/build/enum/enum-safe-value.js.map +1 -0
  99. package/build/enum/enum-values.d.ts +19 -0
  100. package/build/enum/enum-values.d.ts.map +1 -0
  101. package/build/enum/enum-values.js +25 -0
  102. package/build/enum/enum-values.js.map +1 -0
  103. package/build/enum/enum.test.d.ts +2 -0
  104. package/build/enum/enum.test.d.ts.map +1 -0
  105. package/build/enum/enum.test.js +122 -0
  106. package/build/enum/enum.test.js.map +1 -0
  107. package/build/enum/index.d.ts +17 -0
  108. package/build/enum/index.d.ts.map +1 -0
  109. package/build/enum/index.js +17 -0
  110. package/build/enum/index.js.map +1 -0
  111. package/build/enum/types.d.ts +9 -0
  112. package/build/enum/types.d.ts.map +1 -0
  113. package/build/enum/types.js +2 -0
  114. package/build/enum/types.js.map +1 -0
  115. package/build/enum/validate-enum-value.d.ts +13 -0
  116. package/build/enum/validate-enum-value.d.ts.map +1 -0
  117. package/build/enum/validate-enum-value.js +18 -0
  118. package/build/enum/validate-enum-value.js.map +1 -0
  119. package/build/function/compose.d.ts +37 -0
  120. package/build/function/compose.d.ts.map +1 -0
  121. package/build/function/compose.js +7 -0
  122. package/build/function/compose.js.map +1 -0
  123. package/build/function/debounce.d.ts +25 -0
  124. package/build/function/debounce.d.ts.map +1 -0
  125. package/build/function/debounce.js +37 -0
  126. package/build/function/debounce.js.map +1 -0
  127. package/build/function/function.test.d.ts +2 -0
  128. package/build/function/function.test.d.ts.map +1 -0
  129. package/build/function/function.test.js +158 -0
  130. package/build/function/function.test.js.map +1 -0
  131. package/build/function/index.d.ts +17 -0
  132. package/build/function/index.d.ts.map +1 -0
  133. package/build/function/index.js +16 -0
  134. package/build/function/index.js.map +1 -0
  135. package/build/function/memoize.d.ts +23 -0
  136. package/build/function/memoize.d.ts.map +1 -0
  137. package/build/function/memoize.js +34 -0
  138. package/build/function/memoize.js.map +1 -0
  139. package/build/function/once.d.ts +17 -0
  140. package/build/function/once.d.ts.map +1 -0
  141. package/build/function/once.js +27 -0
  142. package/build/function/once.js.map +1 -0
  143. package/build/function/sleep.d.ts +20 -0
  144. package/build/function/sleep.d.ts.map +1 -0
  145. package/build/function/sleep.js +22 -0
  146. package/build/function/sleep.js.map +1 -0
  147. package/build/function/throttle.d.ts +17 -0
  148. package/build/function/throttle.d.ts.map +1 -0
  149. package/build/function/throttle.js +37 -0
  150. package/build/function/throttle.js.map +1 -0
  151. package/build/function/types.d.ts +5 -0
  152. package/build/function/types.d.ts.map +1 -0
  153. package/build/function/types.js +2 -0
  154. package/build/function/types.js.map +1 -0
  155. package/build/index.d.ts +32 -0
  156. package/build/index.d.ts.map +1 -0
  157. package/build/index.js +51 -0
  158. package/build/index.js.map +1 -0
  159. package/build/object/assert-object.d.ts +8 -0
  160. package/build/object/assert-object.d.ts.map +1 -0
  161. package/build/object/assert-object.js +10 -0
  162. package/build/object/assert-object.js.map +1 -0
  163. package/build/object/clone.d.ts +39 -0
  164. package/build/object/clone.d.ts.map +1 -0
  165. package/build/object/clone.js +85 -0
  166. package/build/object/clone.js.map +1 -0
  167. package/build/object/equals.d.ts +44 -0
  168. package/build/object/equals.d.ts.map +1 -0
  169. package/build/object/equals.js +104 -0
  170. package/build/object/equals.js.map +1 -0
  171. package/build/object/filter-cached.d.ts +9 -0
  172. package/build/object/filter-cached.d.ts.map +1 -0
  173. package/build/object/filter-cached.js +108 -0
  174. package/build/object/filter-cached.js.map +1 -0
  175. package/build/object/filter.d.ts +85 -0
  176. package/build/object/filter.d.ts.map +1 -0
  177. package/build/object/filter.js +248 -0
  178. package/build/object/filter.js.map +1 -0
  179. package/build/object/has-circular-reference.d.ts +8 -0
  180. package/build/object/has-circular-reference.d.ts.map +1 -0
  181. package/build/object/has-circular-reference.js +40 -0
  182. package/build/object/has-circular-reference.js.map +1 -0
  183. package/build/object/hash.d.ts +20 -0
  184. package/build/object/hash.d.ts.map +1 -0
  185. package/build/object/hash.js +39 -0
  186. package/build/object/hash.js.map +1 -0
  187. package/build/object/index.d.ts +32 -0
  188. package/build/object/index.d.ts.map +1 -0
  189. package/build/object/index.js +30 -0
  190. package/build/object/index.js.map +1 -0
  191. package/build/object/key-value-pairs.d.ts +21 -0
  192. package/build/object/key-value-pairs.d.ts.map +1 -0
  193. package/build/object/key-value-pairs.js +28 -0
  194. package/build/object/key-value-pairs.js.map +1 -0
  195. package/build/object/map-cached.d.ts +9 -0
  196. package/build/object/map-cached.d.ts.map +1 -0
  197. package/build/object/map-cached.js +97 -0
  198. package/build/object/map-cached.js.map +1 -0
  199. package/build/object/map.d.ts +29 -0
  200. package/build/object/map.d.ts.map +1 -0
  201. package/build/object/map.js +40 -0
  202. package/build/object/map.js.map +1 -0
  203. package/build/object/merge.d.ts +14 -0
  204. package/build/object/merge.d.ts.map +1 -0
  205. package/build/object/merge.js +41 -0
  206. package/build/object/merge.js.map +1 -0
  207. package/build/object/object-diff.d.ts +40 -0
  208. package/build/object/object-diff.d.ts.map +1 -0
  209. package/build/object/object-diff.js +45 -0
  210. package/build/object/object-diff.js.map +1 -0
  211. package/build/object/object-flatten.d.ts +22 -0
  212. package/build/object/object-flatten.d.ts.map +1 -0
  213. package/build/object/object-flatten.js +38 -0
  214. package/build/object/object-flatten.js.map +1 -0
  215. package/build/object/object-invert.d.ts +20 -0
  216. package/build/object/object-invert.d.ts.map +1 -0
  217. package/build/object/object-invert.js +26 -0
  218. package/build/object/object-invert.js.map +1 -0
  219. package/build/object/object.test.d.ts +2 -0
  220. package/build/object/object.test.d.ts.map +1 -0
  221. package/build/object/object.test.js +432 -0
  222. package/build/object/object.test.js.map +1 -0
  223. package/build/object/omit.d.ts +8 -0
  224. package/build/object/omit.d.ts.map +1 -0
  225. package/build/object/omit.js +17 -0
  226. package/build/object/omit.js.map +1 -0
  227. package/build/object/pick.d.ts +50 -0
  228. package/build/object/pick.d.ts.map +1 -0
  229. package/build/object/pick.js +60 -0
  230. package/build/object/pick.js.map +1 -0
  231. package/build/object/property-paths.d.ts +115 -0
  232. package/build/object/property-paths.d.ts.map +1 -0
  233. package/build/object/property-paths.js +170 -0
  234. package/build/object/property-paths.js.map +1 -0
  235. package/build/object/security-utils.d.ts +59 -0
  236. package/build/object/security-utils.d.ts.map +1 -0
  237. package/build/object/security-utils.js +165 -0
  238. package/build/object/security-utils.js.map +1 -0
  239. package/build/object/sort-keys.d.ts +26 -0
  240. package/build/object/sort-keys.d.ts.map +1 -0
  241. package/build/object/sort-keys.js +52 -0
  242. package/build/object/sort-keys.js.map +1 -0
  243. package/build/object/types.d.ts +152 -0
  244. package/build/object/types.d.ts.map +1 -0
  245. package/build/object/types.js +6 -0
  246. package/build/object/types.js.map +1 -0
  247. package/build/string/case-conversion.d.ts +50 -0
  248. package/build/string/case-conversion.d.ts.map +1 -0
  249. package/build/string/case-conversion.js +94 -0
  250. package/build/string/case-conversion.js.map +1 -0
  251. package/build/string/formatting.d.ts +108 -0
  252. package/build/string/formatting.d.ts.map +1 -0
  253. package/build/string/formatting.js +171 -0
  254. package/build/string/formatting.js.map +1 -0
  255. package/build/string/index.d.ts +15 -0
  256. package/build/string/index.d.ts.map +1 -0
  257. package/build/string/index.js +14 -0
  258. package/build/string/index.js.map +1 -0
  259. package/build/string/string.test.d.ts +2 -0
  260. package/build/string/string.test.d.ts.map +1 -0
  261. package/build/string/string.test.js +321 -0
  262. package/build/string/string.test.js.map +1 -0
  263. package/build/string/transformation.d.ts +18 -0
  264. package/build/string/transformation.d.ts.map +1 -0
  265. package/build/string/transformation.js +32 -0
  266. package/build/string/transformation.js.map +1 -0
  267. package/build/string/types.d.ts +44 -0
  268. package/build/string/types.d.ts.map +1 -0
  269. package/build/string/types.js +2 -0
  270. package/build/string/types.js.map +1 -0
  271. package/build/string/validation.d.ts +18 -0
  272. package/build/string/validation.d.ts.map +1 -0
  273. package/build/string/validation.js +26 -0
  274. package/build/string/validation.js.map +1 -0
  275. package/build/time/elapsed-time/constants.d.ts +10 -0
  276. package/build/time/elapsed-time/constants.d.ts.map +1 -0
  277. package/build/time/elapsed-time/constants.js +96 -0
  278. package/build/time/elapsed-time/constants.js.map +1 -0
  279. package/build/time/elapsed-time/elapsed-time.d.ts +412 -0
  280. package/build/time/elapsed-time/elapsed-time.d.ts.map +1 -0
  281. package/build/time/elapsed-time/elapsed-time.js +652 -0
  282. package/build/time/elapsed-time/elapsed-time.js.map +1 -0
  283. package/build/time/elapsed-time/types.d.ts +150 -0
  284. package/build/time/elapsed-time/types.d.ts.map +1 -0
  285. package/build/time/elapsed-time/types.js +2 -0
  286. package/build/time/elapsed-time/types.js.map +1 -0
  287. package/build/time/elapsed-time/utils.d.ts +18 -0
  288. package/build/time/elapsed-time/utils.d.ts.map +1 -0
  289. package/build/time/elapsed-time/utils.js +24 -0
  290. package/build/time/elapsed-time/utils.js.map +1 -0
  291. package/build/time/index.d.ts +18 -0
  292. package/build/time/index.d.ts.map +1 -0
  293. package/build/time/index.js +17 -0
  294. package/build/time/index.js.map +1 -0
  295. package/build/time/stopwatch/entry-types.d.ts +13 -0
  296. package/build/time/stopwatch/entry-types.d.ts.map +1 -0
  297. package/build/time/stopwatch/entry-types.js +2 -0
  298. package/build/time/stopwatch/entry-types.js.map +1 -0
  299. package/build/time/stopwatch/entry.d.ts +80 -0
  300. package/build/time/stopwatch/entry.d.ts.map +1 -0
  301. package/build/time/stopwatch/entry.js +105 -0
  302. package/build/time/stopwatch/entry.js.map +1 -0
  303. package/build/time/stopwatch/stopwatch.d.ts +232 -0
  304. package/build/time/stopwatch/stopwatch.d.ts.map +1 -0
  305. package/build/time/stopwatch/stopwatch.js +315 -0
  306. package/build/time/stopwatch/stopwatch.js.map +1 -0
  307. package/build/time/time.test.d.ts +2 -0
  308. package/build/time/time.test.d.ts.map +1 -0
  309. package/build/time/time.test.js +211 -0
  310. package/build/time/time.test.js.map +1 -0
  311. package/package.json +63 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sort-keys.js","sourceRoot":"","sources":["../../src/object/sort-keys.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,cAAc,CAAgC,MAAS;IACtE,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACpE,OAAO,MAAM,CAAC;IACf,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QAChD,IAAI,CAAC,GAAG,CAAC;YAAE,OAAO,CAAC,CAAC,CAAC;QACrB,IAAI,CAAC,GAAG,CAAC;YAAE,OAAO,CAAC,CAAC;QACpB,OAAO,CAAC,CAAC;IACV,CAAC,CAAC;SACA,MAAM,CACN,CAAC,KAAQ,EAAE,GAAW,EAAE,EAAE;QACzB,KAAK,CAAC,GAAc,CAAC,GAAG,MAAM,CAAC,GAAc,CAAC,CAAC;QAC/C,OAAO,KAAK,CAAC;IACd,CAAC,EACD,EAAO,CACP,CAAC;IAEH,qCAAqC;IACrC,MAAM,OAAO,GAAG,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAEnD,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;QAC3B,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;YACxD,MAAM,UAAU,GAAG,MAAM,CAAC,wBAAwB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;YAChE,IAAI,UAAU,EAAE,CAAC;gBAChB,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC;YAChD,CAAC;QACF,CAAC;IACF,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC"}
@@ -0,0 +1,152 @@
1
+ /**
2
+ * A constructor function type for creating objects of type O.
3
+ * @template O The object type to construct.
4
+ */
5
+ export type TConstructableObject<O extends object = object> = new (...args: any[]) => O;
6
+ /**
7
+ * Omits properties from B that are not in A.
8
+ * @template A Base type.
9
+ * @template B Type to filter.
10
+ */
11
+ export type TObjectOmitExtraProperties<A, B> = {
12
+ [K in keyof B]: K extends A ? B[K] : never;
13
+ };
14
+ /**
15
+ * Extracts the property keys of an object type.
16
+ * @template O The object type.
17
+ */
18
+ export type TObjectProperties<O extends object> = keyof O;
19
+ /**
20
+ * Extracts property keys of a specific type from an object.
21
+ * @template O Object type.
22
+ * @template PropertyType The type to match.
23
+ */
24
+ export type TObjectPropertiesOfType<O extends object, PropertyType> = keyof {
25
+ [K in keyof O as O[K] extends PropertyType ? K : never]: any;
26
+ };
27
+ /**
28
+ * Omits properties of a specific type from an object.
29
+ * @template O Object type.
30
+ * @template PropertyType The type to omit.
31
+ */
32
+ export type TObjectOmitPropertiesOfType<O extends object, PropertyType> = {
33
+ [K in keyof O as O[K] extends PropertyType ? never : K]: O[K];
34
+ };
35
+ /**
36
+ * Represents the union of all property values in an object.
37
+ * @template T Object type.
38
+ */
39
+ export type TObjectPropertyType<T extends object> = T[keyof T];
40
+ /**
41
+ * Extracts properties shared between two object types.
42
+ * @template A First object type.
43
+ * @template B Second object type.
44
+ */
45
+ export type TObjectSharedProperties<A extends object, B extends object> = {
46
+ [K in keyof A & keyof B]: K extends keyof A ? A[K] : never;
47
+ };
48
+ /**
49
+ * Extracts keys of array properties from an object type.
50
+ * @template T Object type.
51
+ */
52
+ export type TObjectArrayProperties<T extends object> = {
53
+ [K in keyof T]: T[K] extends Array<any> ? K : never;
54
+ }[keyof T];
55
+ /**
56
+ * Generates nested dot-notation keys for an object type.
57
+ * @template ObjectType The object type.
58
+ */
59
+ export type TObjectNestedKeyOf<ObjectType extends object> = {
60
+ [Key in keyof ObjectType & (string | number)]: ObjectType[Key] extends object ? `${Key}` | `${Key}.${TObjectNestedKeyOf<ObjectType[Key]>}` : `${Key}`;
61
+ }[keyof ObjectType & (string | number)];
62
+ /**
63
+ * Options for object filtering behavior.
64
+ */
65
+ export interface IObjectFilterOptions {
66
+ /** When `true`, uses deep equality for nested object comparisons instead of strict reference equality. Default: `false`. */
67
+ useDeepEqual?: boolean | undefined;
68
+ /** When `true`, string comparisons are case-insensitive. Default: `false`. */
69
+ caseInsensitiveStrings?: boolean | undefined;
70
+ /** When `true`, validates dot-notation property paths against prototype-pollution patterns. Default: `false`. */
71
+ validatePaths?: boolean | undefined;
72
+ }
73
+ /**
74
+ * Options for cached object filtering behavior.
75
+ */
76
+ export interface ICachedObjectFilterOptions {
77
+ /** Maximum number of unique (filter, object) result pairs to store in the cache. Default: `1000`. */
78
+ maxCacheSize?: number | undefined;
79
+ /** When `true`, uses deep equality for nested object comparisons instead of strict reference equality. Default: `false`. */
80
+ useDeepEqual?: boolean | undefined;
81
+ /** When `true`, string comparisons are case-insensitive. Default: `false`. */
82
+ caseInsensitiveStrings?: boolean | undefined;
83
+ /** When `true`, validates dot-notation property paths against prototype-pollution patterns. Default: `false`. */
84
+ validatePaths?: boolean | undefined;
85
+ }
86
+ /**
87
+ * Options for cached object mapping behavior.
88
+ */
89
+ export interface ICachedObjectMapOptions {
90
+ /** Maximum number of cached mapping results to retain per mapper key. Default: `1000`. */
91
+ maxCacheSize?: number | undefined;
92
+ }
93
+ /**
94
+ * Type for cached object filter functions.
95
+ * @template T The object type being filtered.
96
+ */
97
+ export type TCachedObjectFilterFunction<T extends object> = (cursor: T, filter: Partial<Record<string, any>>) => Promise<boolean>;
98
+ /**
99
+ * Type for cached object map functions.
100
+ * @template T The object type being mapped.
101
+ */
102
+ export type TCachedObjectMapperFunction<T extends object> = (cursor: T, mapper: TPropertyMapper<T>, mapperKey?: string) => Promise<Record<keyof T, unknown>>;
103
+ /**
104
+ * Object predicate function type for filtering and validation
105
+ * @template T - The type of object being tested
106
+ * @param obj - The object to test
107
+ * @returns true if the object passes the predicate, false otherwise
108
+ */
109
+ export type TObjectPredicate<T extends object = object> = (obj: T) => boolean;
110
+ /**
111
+ * Object transformer function type for mapping operations
112
+ * @template TInput - The input object type
113
+ * @template TOutput - The output object type
114
+ * @param input - The object to transform
115
+ * @returns The transformed object
116
+ */
117
+ export type TObjectTransformer<TInput extends object = object, TOutput extends object = object> = (input: TInput) => TOutput;
118
+ /**
119
+ * Object comparator function type for sorting and comparison
120
+ * @template T - The type of objects being compared
121
+ * @param a - First object
122
+ * @param b - Second object
123
+ * @returns Negative if a < b, zero if a === b, positive if a > b
124
+ */
125
+ export type TObjectComparator<T extends object = object> = (a: T, b: T) => number;
126
+ /**
127
+ * Object equality comparator function type
128
+ * @template T - The type of objects being compared
129
+ * @param a - First object
130
+ * @param b - Second object
131
+ * @returns true if objects are equal, false otherwise
132
+ */
133
+ export type TObjectEqualityComparator<T extends object = object> = (a: T, b: T) => boolean;
134
+ /**
135
+ * Property mapper function type
136
+ * @template T - The object type
137
+ * @template K - The property key type
138
+ * @param key - The property key
139
+ * @param value - The property value
140
+ * @returns The mapped value
141
+ */
142
+ export type TPropertyMapper<T extends object = object, K extends keyof T = keyof T> = (key: K, value: T[K]) => unknown;
143
+ /**
144
+ * Property filter predicate type
145
+ * @template T - The object type
146
+ * @template K - The property key type
147
+ * @param key - The property key
148
+ * @param value - The property value
149
+ * @returns true to include the property, false to exclude
150
+ */
151
+ export type TPropertyFilter<T extends object = object, K extends keyof T = keyof T> = (key: K, value: T[K]) => boolean;
152
+ //# sour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,EAAE,CAAC,EACN,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,KACP,OAAO,CAAC;AAEb;;;;;;;GAOG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,CAAC,SAAS,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,CACrF,GAAG,EAAE,CAAC,EACN,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,KACP,OAAO,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * A constructor function type for creating objects of type O.
3
+ * @template O The object type to construct.
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/object/types.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
@@ -0,0 +1,50 @@
1
+ import type { TCaseConverter } from './types';
2
+ /**
3
+ * Converts a string to camelCase.
4
+ *
5
+ * @param value The input string.
6
+ * @returns The camelCased string.
7
+ * @see {@link TCaseConverter}
8
+ */
9
+ export declare function CamelCase(value: string): string;
10
+ /**
11
+ * Capitalizes the first letter of a string.
12
+ *
13
+ * @param value The input string.
14
+ * @returns The capitalized string.
15
+ * @see {@link TCaseConverter}
16
+ */
17
+ export declare const CAPITALIZE: TCaseConverter;
18
+ /**
19
+ * Converts a string to kebab-case.
20
+ *
21
+ * @param value The input string.
22
+ * @returns The kebab-cased string.
23
+ * @see {@link TCaseConverter}
24
+ */
25
+ export declare const KEBAB_CASE: TCaseConverter;
26
+ /**
27
+ * Converts a string to PascalCase.
28
+ *
29
+ * @param value The input string.
30
+ * @returns The PascalCased string.
31
+ * @see {@link TCaseConverter}
32
+ */
33
+ export declare const PASCAL_CASE: TCaseConverter;
34
+ /**
35
+ * Converts a string to snake_case.
36
+ *
37
+ * @param value The input string.
38
+ * @returns The snake_cased string.
39
+ * @see {@link TCaseConverter}
40
+ */
41
+ export declare const SNAKE_CASE: TCaseConverter;
42
+ /**
43
+ * Converts a string to SCREAMING_SNAKE_CASE.
44
+ *
45
+ * @param value The input string.
46
+ * @returns The SCREAMING_SNAKE_CASED string.
47
+ * @see {@link TCaseConverter}
48
+ */
49
+ export declare const SCREAMING_SNAKE_CASE: TCaseConverter;
50
+ //# sourceMappingURL=case-conversion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"case-conversion.d.ts","sourceRoot":"","sources":["../../src/string/case-conversion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAY/C;AAED;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,EAAE,cAMxB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,EAAE,cASxB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,EAAE,cAYzB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,EAAE,cASxB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,EAAE,cAElC,CAAC"}
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Converts a string to camelCase.
3
+ *
4
+ * @param value The input string.
5
+ * @returns The camelCased string.
6
+ * @see {@link TCaseConverter}
7
+ */
8
+ export function CamelCase(value) {
9
+ if (value && typeof value === 'string') {
10
+ return value
11
+ .replace(/(?:^\w|[A-Z]|\b\w)/gu, (word, index) => {
12
+ return index === 0 ? word.toLowerCase() : word.toUpperCase();
13
+ })
14
+ .replace(/[-_\s]+(?<char>.)?/gu, (_, c) => {
15
+ return c ? c.toUpperCase() : '';
16
+ });
17
+ }
18
+ return '';
19
+ }
20
+ /**
21
+ * Capitalizes the first letter of a string.
22
+ *
23
+ * @param value The input string.
24
+ * @returns The capitalized string.
25
+ * @see {@link TCaseConverter}
26
+ */
27
+ export const CAPITALIZE = (value) => {
28
+ if (value && typeof value === 'string') {
29
+ return value.charAt(0).toUpperCase() + value.slice(1);
30
+ }
31
+ return '';
32
+ };
33
+ /**
34
+ * Converts a string to kebab-case.
35
+ *
36
+ * @param value The input string.
37
+ * @returns The kebab-cased string.
38
+ * @see {@link TCaseConverter}
39
+ */
40
+ export const KEBAB_CASE = (value) => {
41
+ if (value && typeof value === 'string') {
42
+ return value
43
+ .replace(/(?<lower>[a-z])(?<upper>[A-Z])/gu, '$1-$2')
44
+ .replace(/[\s_]+/gu, '-')
45
+ .toLowerCase();
46
+ }
47
+ return '';
48
+ };
49
+ /**
50
+ * Converts a string to PascalCase.
51
+ *
52
+ * @param value The input string.
53
+ * @returns The PascalCased string.
54
+ * @see {@link TCaseConverter}
55
+ */
56
+ export const PASCAL_CASE = (value) => {
57
+ if (value && typeof value === 'string') {
58
+ return value
59
+ .replace(/(?:^\w|[A-Z]|\b\w)/gu, (word) => {
60
+ return word.toUpperCase();
61
+ })
62
+ .replace(/[-_\s]+(?<char>.)?/gu, (_, c) => {
63
+ return c ? c.toUpperCase() : '';
64
+ });
65
+ }
66
+ return '';
67
+ };
68
+ /**
69
+ * Converts a string to snake_case.
70
+ *
71
+ * @param value The input string.
72
+ * @returns The snake_cased string.
73
+ * @see {@link TCaseConverter}
74
+ */
75
+ export const SNAKE_CASE = (value) => {
76
+ if (value && typeof value === 'string') {
77
+ return value
78
+ .replace(/(?<lower>[a-z])(?<upper>[A-Z])/gu, '$1_$2')
79
+ .replace(/[\s-]+/gu, '_')
80
+ .toLowerCase();
81
+ }
82
+ return '';
83
+ };
84
+ /**
85
+ * Converts a string to SCREAMING_SNAKE_CASE.
86
+ *
87
+ * @param value The input string.
88
+ * @returns The SCREAMING_SNAKE_CASED string.
89
+ * @see {@link TCaseConverter}
90
+ */
91
+ export const SCREAMING_SNAKE_CASE = (value) => {
92
+ return SNAKE_CASE(value).toUpperCase();
93
+ };
94
+ //# sourceMappingURL=case-conversion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"case-conversion.js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CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,WAAW,GAAmB,CAAC,KAAa,EAAU,EAAE;IACpE,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACxC,OAAO,KAAK;aACV,OAAO,CAAC,sBAAsB,EAAE,CAAC,IAAI,EAAE,EAAE;YACzC,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;QAC3B,CAAC,CAAC;aACD,OAAO,CAAC,sBAAsB,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YACzC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACjC,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,EAAE,CAAC;AACX,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,UAAU,GAAmB,CAAC,KAAa,EAAU,EAAE;IACnE,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACxC,OAAO,KAAK;aACV,OAAO,CAAC,kCAAkC,EAAE,OAAO,CAAC;aACpD,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC;aACxB,WAAW,EAAE,CAAC;IACjB,CAAC;IAED,OAAO,EAAE,CAAC;AACX,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAmB,CAAC,KAAa,EAAU,EAAE;IAC7E,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;AACxC,CAAC,CAAC"}
@@ -0,0 +1,108 @@
1
+ import type { TFormatParams, TFormatArgs } from './types';
2
+ /**
3
+ * Escapes a string for safe use in HTML.
4
+ *
5
+ * @param str The input string.
6
+ * @returns The HTML-escaped string.
7
+ */
8
+ export declare function EscapeHTML(str: string): string;
9
+ /**
10
+ * Formats a string by replacing placeholders with values
11
+ * Supports both named placeholders {name} and positional {0}, {1}
12
+ *
13
+ * @param template - The template string with placeholders
14
+ * @param params - Either an object with named parameters or array of positional parameters
15
+ * @returns The formatted string
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * // Named parameters
20
+ * FormatString('Hello {name}!', { name: 'World' }); // 'Hello World!'
21
+ *
22
+ * // Positional parameters
23
+ * FormatString('Hello {0}!', ['World']); // 'Hello World!'
24
+ *
25
+ * // Mixed types
26
+ * FormatString('Count: {count}, Active: {active}', {
27
+ * count: 42,
28
+ * active: true
29
+ * }); // 'Count: 42, Active: true'
30
+ * ```
31
+ */
32
+ export declare function FormatString(template: string, params: TFormatParams | TFormatArgs): string;
33
+ /**
34
+ * Truncates a string to a specified length, appending an ellipsis if truncated.
35
+ *
36
+ * @param str The string to truncate.
37
+ * @param maxLength The maximum length before truncation.
38
+ * @param ellipsis The string to append when truncated (default: '...').
39
+ * @returns The truncated string.
40
+ */
41
+ export declare function TruncateString(str: string, maxLength: number, ellipsis?: string): string;
42
+ /**
43
+ * Pads a string to a specified length.
44
+ *
45
+ * @param str The input string.
46
+ * @param length The target length.
47
+ * @param char The character to pad with (default: ' ').
48
+ * @param padEnd If true, pads the end; otherwise, pads the start (default: true).
49
+ * @returns The padded string.
50
+ */
51
+ export declare function PadString(str: string, length: number, char?: string, padEnd?: boolean): string;
52
+ /**
53
+ * Removes all HTML tags from a string.
54
+ *
55
+ * @param str The input string.
56
+ * @returns The string with all HTML tags stripped.
57
+ *
58
+ * @example
59
+ * ```typescript
60
+ * StripHTML('<p>Hello <strong>World</strong></p>'); // 'Hello World'
61
+ * ```
62
+ */
63
+ export declare function StripHTML(str: string): string;
64
+ /**
65
+ * Returns the plural form of a word based on a count.
66
+ *
67
+ * @param word The singular word.
68
+ * @param count The count to test against.
69
+ * @param plural Optional custom plural form (defaults to `word + 's'`).
70
+ * @returns The singular word when `count === 1`, otherwise the plural.
71
+ *
72
+ * @example
73
+ * ```typescript
74
+ * Pluralize('cat', 1); // 'cat'
75
+ * Pluralize('cat', 3); // 'cats'
76
+ * Pluralize('child', 2, 'children'); // 'children'
77
+ * ```
78
+ */
79
+ export declare function Pluralize(word: string, count: number, plural?: string): string;
80
+ /**
81
+ * Counts the number of words in a string.
82
+ * Words are separated by one or more whitespace characters.
83
+ *
84
+ * @param str The input string.
85
+ * @returns The number of words.
86
+ *
87
+ * @example
88
+ * ```typescript
89
+ * WordCount('hello world'); // 2
90
+ * WordCount(' foo bar baz '); // 3
91
+ * ```
92
+ */
93
+ export declare function WordCount(str: string): number;
94
+ /**
95
+ * Counts the number of non-overlapping occurrences of `substr` in `str`.
96
+ *
97
+ * @param str The string to search in.
98
+ * @param substr The substring to count.
99
+ * @returns The number of occurrences.
100
+ *
101
+ * @example
102
+ * ```typescript
103
+ * CountOccurrences('hello world hello', 'hello'); // 2
104
+ * CountOccurrences('aaa', 'aa'); // 1 (non-overlapping)
105
+ * ```
106
+ */
107
+ export declare function CountOccurrences(str: string, substr: string): number;
108
+ //# sourceMappingURL=formatting.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatting.d.ts","sourceRoot":"","sources":["../../src/string/formatting.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE1D;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAW9C;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,YAAY,CAC3B,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,aAAa,GAAG,WAAW,GACjC,MAAM,CAoBR;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,SAAQ,GAAG,MAAM,CAUvF;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,SAAM,EAAE,MAAM,UAAO,GAAG,MAAM,CASxF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAG7C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAG9E;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAG7C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CASpE"}
@@ -0,0 +1,171 @@
1
+ /**
2
+ * Escapes a string for safe use in HTML.
3
+ *
4
+ * @param str The input string.
5
+ * @returns The HTML-escaped string.
6
+ */
7
+ export function EscapeHTML(str) {
8
+ if (str && typeof str === 'string') {
9
+ return str
10
+ .replace(/&/gu, '&amp;')
11
+ .replace(/</gu, '&lt;')
12
+ .replace(/>/gu, '&gt;')
13
+ .replace(/"/gu, '&quot;')
14
+ .replace(/'/gu, '&#039;');
15
+ }
16
+ return '';
17
+ }
18
+ /**
19
+ * Formats a string by replacing placeholders with values
20
+ * Supports both named placeholders {name} and positional {0}, {1}
21
+ *
22
+ * @param template - The template string with placeholders
23
+ * @param params - Either an object with named parameters or array of positional parameters
24
+ * @returns The formatted string
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * // Named parameters
29
+ * FormatString('Hello {name}!', { name: 'World' }); // 'Hello World!'
30
+ *
31
+ * // Positional parameters
32
+ * FormatString('Hello {0}!', ['World']); // 'Hello World!'
33
+ *
34
+ * // Mixed types
35
+ * FormatString('Count: {count}, Active: {active}', {
36
+ * count: 42,
37
+ * active: true
38
+ * }); // 'Count: 42, Active: true'
39
+ * ```
40
+ */
41
+ export function FormatString(template, params) {
42
+ if (template && typeof template === 'string') {
43
+ if (params && (Array.isArray(params) || typeof params === 'object')) {
44
+ if (Array.isArray(params)) {
45
+ return template.replace(/{(\d+)}/g, (match, index) => {
46
+ const value = params[parseInt(index, 10)];
47
+ return value !== undefined && value !== null ? String(value) : match;
48
+ });
49
+ }
50
+ return template.replace(/{(\w+)}/g, (match, key) => {
51
+ const value = params[key];
52
+ return value !== undefined && value !== null ? String(value) : match;
53
+ });
54
+ }
55
+ return template;
56
+ }
57
+ return '';
58
+ }
59
+ /**
60
+ * Truncates a string to a specified length, appending an ellipsis if truncated.
61
+ *
62
+ * @param str The string to truncate.
63
+ * @param maxLength The maximum length before truncation.
64
+ * @param ellipsis The string to append when truncated (default: '...').
65
+ * @returns The truncated string.
66
+ */
67
+ export function TruncateString(str, maxLength, ellipsis = '...') {
68
+ if (str && typeof str === 'string' && maxLength > 0) {
69
+ if (str.length <= maxLength) {
70
+ return str;
71
+ }
72
+ return str.slice(0, maxLength) + ellipsis;
73
+ }
74
+ return '';
75
+ }
76
+ /**
77
+ * Pads a string to a specified length.
78
+ *
79
+ * @param str The input string.
80
+ * @param length The target length.
81
+ * @param char The character to pad with (default: ' ').
82
+ * @param padEnd If true, pads the end; otherwise, pads the start (default: true).
83
+ * @returns The padded string.
84
+ */
85
+ export function PadString(str, length, char = ' ', padEnd = true) {
86
+ if (str && typeof str === 'string' && length > str.length) {
87
+ const paddingLength = length - str.length;
88
+ const padding = char.repeat(paddingLength);
89
+ return padEnd ? str + padding : padding + str;
90
+ }
91
+ return str || '';
92
+ }
93
+ /**
94
+ * Removes all HTML tags from a string.
95
+ *
96
+ * @param str The input string.
97
+ * @returns The string with all HTML tags stripped.
98
+ *
99
+ * @example
100
+ * ```typescript
101
+ * StripHTML('<p>Hello <strong>World</strong></p>'); // 'Hello World'
102
+ * ```
103
+ */
104
+ export function StripHTML(str) {
105
+ if (!str || typeof str !== 'string')
106
+ return '';
107
+ return str.replace(/<[^>]*>/gu, '');
108
+ }
109
+ /**
110
+ * Returns the plural form of a word based on a count.
111
+ *
112
+ * @param word The singular word.
113
+ * @param count The count to test against.
114
+ * @param plural Optional custom plural form (defaults to `word + 's'`).
115
+ * @returns The singular word when `count === 1`, otherwise the plural.
116
+ *
117
+ * @example
118
+ * ```typescript
119
+ * Pluralize('cat', 1); // 'cat'
120
+ * Pluralize('cat', 3); // 'cats'
121
+ * Pluralize('child', 2, 'children'); // 'children'
122
+ * ```
123
+ */
124
+ export function Pluralize(word, count, plural) {
125
+ if (!word || typeof word !== 'string')
126
+ return '';
127
+ return count === 1 ? word : (plural ?? `${word}s`);
128
+ }
129
+ /**
130
+ * Counts the number of words in a string.
131
+ * Words are separated by one or more whitespace characters.
132
+ *
133
+ * @param str The input string.
134
+ * @returns The number of words.
135
+ *
136
+ * @example
137
+ * ```typescript
138
+ * WordCount('hello world'); // 2
139
+ * WordCount(' foo bar baz '); // 3
140
+ * ```
141
+ */
142
+ export function WordCount(str) {
143
+ if (!str || typeof str !== 'string')
144
+ return 0;
145
+ return str.trim().split(/\s+/u).filter(Boolean).length;
146
+ }
147
+ /**
148
+ * Counts the number of non-overlapping occurrences of `substr` in `str`.
149
+ *
150
+ * @param str The string to search in.
151
+ * @param substr The substring to count.
152
+ * @returns The number of occurrences.
153
+ *
154
+ * @example
155
+ * ```typescript
156
+ * CountOccurrences('hello world hello', 'hello'); // 2
157
+ * CountOccurrences('aaa', 'aa'); // 1 (non-overlapping)
158
+ * ```
159
+ */
160
+ export function CountOccurrences(str, substr) {
161
+ if (!str || !substr)
162
+ return 0;
163
+ let count = 0;
164
+ let pos = 0;
165
+ while ((pos = str.indexOf(substr, pos)) !== -1) {
166
+ count++;
167
+ pos += substr.length;
168
+ }
169
+ return count;
170
+ }
171
+ //# sourceMappingURL=formatting.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatting.js","sourceRoot":"","sources":["../../src/string/formatting.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,GAAW;IACrC,IAAI,GAAG,IAAI,OAAO,GAAG,KAA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;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,SAAS,CAAC,IAAY,EAAE,KAAa,EAAE,MAAe;IACrE,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,EAAE,CAAC;IACjD,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,CAAC;AACpD,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,SAAS,CAAC,GAAW;IACpC,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,CAAC,CAAC;IAC9C,OAAO,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC;AACxD,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,gBAAgB,CAAC,GAAW,EAAE,MAAc;IAC3D,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM;QAAE,OAAO,CAAC,CAAC;IAC9B,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,OAAO,CAAC,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QAChD,KAAK,EAAE,CAAC;QACR,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC;IACtB,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * String utility functions and types.
3
+ *
4
+ * Provides helpers for case conversion (camelCase, PascalCase, kebab-case),
5
+ * HTML escaping, template formatting, truncation, padding, slugification,
6
+ * string reversal, and common validation predicates.
7
+ *
8
+ * @module string
9
+ */
10
+ export * from './case-conversion.js';
11
+ export * from './validation.js';
12
+ export * from './formatting.js';
13
+ export * from './transformation.js';
14
+ export type { TStringValidator, TStringFormatter, TStringTransformer, TCaseConverter, TStringPredicate, TFormatValue, TFormatParams, TFormatArgs } from './types.js';
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/string/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AAEpC,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,cAAc,EAAE,gBAAgB,EAAE,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * String utility functions and types.
3
+ *
4
+ * Provides helpers for case conversion (camelCase, PascalCase, kebab-case),
5
+ * HTML escaping, template formatting, truncation, padding, slugification,
6
+ * string reversal, and common validation predicates.
7
+ *
8
+ * @module string
9
+ */
10
+ export * from './case-conversion.js';
11
+ export * from './validation.js';
12
+ export * from './formatting.js';
13
+ export * from './transformation.js';
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/string/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=string.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string.test.d.ts","sourceRoot":"","sources":["../../src/string/string.test.ts"],"names":[],"mappings":""}