@develia/commons 0.4.14 → 0.4.16

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 (230) hide show
  1. package/dist/cjs/array.js +43 -1
  2. package/dist/cjs/array.js.map +1 -1
  3. package/dist/cjs/async-pool-executor.js +15 -0
  4. package/dist/cjs/async-pool-executor.js.map +1 -1
  5. package/dist/cjs/browser/form-utilities.js +26 -0
  6. package/dist/cjs/browser/form-utilities.js.map +1 -1
  7. package/dist/cjs/browser/geo-location.js +5 -0
  8. package/dist/cjs/browser/geo-location.js.map +1 -1
  9. package/dist/cjs/browser/index.js.map +1 -1
  10. package/dist/cjs/browser/native-bridge.js +9 -0
  11. package/dist/cjs/browser/native-bridge.js.map +1 -1
  12. package/dist/cjs/cancellable-promise.js.map +1 -1
  13. package/dist/cjs/clean-url-search-params.js +1 -0
  14. package/dist/cjs/clean-url-search-params.js.map +1 -1
  15. package/dist/cjs/collections/cache-dictionary.js +39 -0
  16. package/dist/cjs/collections/cache-dictionary.js.map +1 -1
  17. package/dist/cjs/collections/default-map.js +25 -1
  18. package/dist/cjs/collections/default-map.js.map +1 -1
  19. package/dist/cjs/collections/default-weak-map.js +23 -3
  20. package/dist/cjs/collections/default-weak-map.js.map +1 -1
  21. package/dist/cjs/{from.js → collections/from.js} +278 -4
  22. package/dist/cjs/collections/from.js.map +1 -0
  23. package/dist/cjs/collections/index.js +3 -1
  24. package/dist/cjs/collections/index.js.map +1 -1
  25. package/dist/cjs/draft.js +37 -0
  26. package/dist/cjs/draft.js.map +1 -1
  27. package/dist/cjs/event-bus.js +1 -0
  28. package/dist/cjs/event-bus.js.map +1 -1
  29. package/dist/cjs/index.js +16 -3
  30. package/dist/cjs/index.js.map +1 -1
  31. package/dist/cjs/key-value-pair.js +6 -0
  32. package/dist/cjs/key-value-pair.js.map +1 -1
  33. package/dist/cjs/lazy.js +4 -0
  34. package/dist/cjs/lazy.js.map +1 -1
  35. package/dist/cjs/math.js +19 -0
  36. package/dist/cjs/math.js.map +1 -1
  37. package/dist/cjs/order.js.map +1 -1
  38. package/dist/cjs/parse.js +96 -0
  39. package/dist/cjs/parse.js.map +1 -1
  40. package/dist/cjs/patch.js +10 -2
  41. package/dist/cjs/patch.js.map +1 -1
  42. package/dist/cjs/range.js +154 -0
  43. package/dist/cjs/range.js.map +1 -0
  44. package/dist/cjs/stopwatch.js +10 -0
  45. package/dist/cjs/stopwatch.js.map +1 -1
  46. package/dist/cjs/string.js +62 -0
  47. package/dist/cjs/string.js.map +1 -1
  48. package/dist/cjs/timer.js +7 -0
  49. package/dist/cjs/timer.js.map +1 -1
  50. package/dist/cjs/timespan.js +202 -0
  51. package/dist/cjs/timespan.js.map +1 -1
  52. package/dist/cjs/type-code.js.map +1 -1
  53. package/dist/cjs/type.js +80 -1
  54. package/dist/cjs/type.js.map +1 -1
  55. package/dist/cjs/types.js.map +1 -1
  56. package/dist/cjs/utilities.js +183 -0
  57. package/dist/cjs/utilities.js.map +1 -1
  58. package/dist/esm/array.js +42 -1
  59. package/dist/esm/array.js.map +1 -1
  60. package/dist/esm/async-pool-executor.js +15 -0
  61. package/dist/esm/async-pool-executor.js.map +1 -1
  62. package/dist/esm/browser/form-utilities.js +26 -0
  63. package/dist/esm/browser/form-utilities.js.map +1 -1
  64. package/dist/esm/browser/geo-location.js +5 -0
  65. package/dist/esm/browser/geo-location.js.map +1 -1
  66. package/dist/esm/browser/index.js.map +1 -1
  67. package/dist/esm/browser/native-bridge.js +9 -0
  68. package/dist/esm/browser/native-bridge.js.map +1 -1
  69. package/dist/esm/cancellable-promise.js.map +1 -1
  70. package/dist/esm/clean-url-search-params.js +1 -0
  71. package/dist/esm/clean-url-search-params.js.map +1 -1
  72. package/dist/esm/collections/cache-dictionary.js +39 -0
  73. package/dist/esm/collections/cache-dictionary.js.map +1 -1
  74. package/dist/esm/collections/default-map.js +25 -1
  75. package/dist/esm/collections/default-map.js.map +1 -1
  76. package/dist/esm/collections/default-weak-map.js +22 -2
  77. package/dist/esm/collections/default-weak-map.js.map +1 -1
  78. package/dist/esm/{from.js → collections/from.js} +278 -4
  79. package/dist/esm/collections/from.js.map +1 -0
  80. package/dist/esm/collections/index.js +1 -0
  81. package/dist/esm/collections/index.js.map +1 -1
  82. package/dist/esm/draft.js +37 -0
  83. package/dist/esm/draft.js.map +1 -1
  84. package/dist/esm/event-bus.js +1 -0
  85. package/dist/esm/event-bus.js.map +1 -1
  86. package/dist/esm/index.js +14 -1
  87. package/dist/esm/index.js.map +1 -1
  88. package/dist/esm/key-value-pair.js +6 -0
  89. package/dist/esm/key-value-pair.js.map +1 -1
  90. package/dist/esm/lazy.js +4 -0
  91. package/dist/esm/lazy.js.map +1 -1
  92. package/dist/esm/math.js +19 -0
  93. package/dist/esm/math.js.map +1 -1
  94. package/dist/esm/order.js.map +1 -1
  95. package/dist/esm/parse.js +96 -0
  96. package/dist/esm/parse.js.map +1 -1
  97. package/dist/esm/patch.js +10 -2
  98. package/dist/esm/patch.js.map +1 -1
  99. package/dist/esm/range.js +151 -0
  100. package/dist/esm/range.js.map +1 -0
  101. package/dist/esm/stopwatch.js +10 -0
  102. package/dist/esm/stopwatch.js.map +1 -1
  103. package/dist/esm/string.js +62 -0
  104. package/dist/esm/string.js.map +1 -1
  105. package/dist/esm/timer.js +7 -0
  106. package/dist/esm/timer.js.map +1 -1
  107. package/dist/esm/timespan.js +202 -0
  108. package/dist/esm/timespan.js.map +1 -1
  109. package/dist/esm/type-code.js.map +1 -1
  110. package/dist/esm/type.js +80 -1
  111. package/dist/esm/type.js.map +1 -1
  112. package/dist/esm/types.js.map +1 -1
  113. package/dist/esm/utilities.js +183 -0
  114. package/dist/esm/utilities.js.map +1 -1
  115. package/dist/types/array.d.ts +35 -0
  116. package/dist/types/array.d.ts.map +1 -1
  117. package/dist/types/async-pool-executor.d.ts +15 -0
  118. package/dist/types/async-pool-executor.d.ts.map +1 -1
  119. package/dist/types/browser/form-utilities.d.ts +13 -0
  120. package/dist/types/browser/form-utilities.d.ts.map +1 -1
  121. package/dist/types/browser/index.d.ts.map +1 -1
  122. package/dist/types/browser/native-bridge.d.ts +6 -0
  123. package/dist/types/browser/native-bridge.d.ts.map +1 -1
  124. package/dist/types/collections/cache-dictionary.d.ts +39 -0
  125. package/dist/types/collections/cache-dictionary.d.ts.map +1 -1
  126. package/dist/types/collections/default-map.d.ts +23 -0
  127. package/dist/types/collections/default-map.d.ts.map +1 -1
  128. package/dist/types/collections/default-weak-map.d.ts +20 -1
  129. package/dist/types/collections/default-weak-map.d.ts.map +1 -1
  130. package/dist/types/collections/from.d.ts +333 -0
  131. package/dist/types/collections/from.d.ts.map +1 -0
  132. package/dist/types/collections/index.d.ts +1 -0
  133. package/dist/types/collections/index.d.ts.map +1 -1
  134. package/dist/types/draft.d.ts +68 -0
  135. package/dist/types/draft.d.ts.map +1 -1
  136. package/dist/types/index.d.ts +5 -1
  137. package/dist/types/index.d.ts.map +1 -1
  138. package/dist/types/key-value-pair.d.ts +6 -0
  139. package/dist/types/key-value-pair.d.ts.map +1 -1
  140. package/dist/types/lazy.d.ts +4 -0
  141. package/dist/types/lazy.d.ts.map +1 -1
  142. package/dist/types/math.d.ts +19 -0
  143. package/dist/types/math.d.ts.map +1 -1
  144. package/dist/types/parse.d.ts +121 -0
  145. package/dist/types/parse.d.ts.map +1 -1
  146. package/dist/types/range.d.ts +72 -0
  147. package/dist/types/range.d.ts.map +1 -0
  148. package/dist/types/string.d.ts +51 -0
  149. package/dist/types/string.d.ts.map +1 -1
  150. package/dist/types/timer.d.ts +7 -0
  151. package/dist/types/timer.d.ts.map +1 -1
  152. package/dist/types/timespan.d.ts +202 -0
  153. package/dist/types/timespan.d.ts.map +1 -1
  154. package/dist/types/type.d.ts +40 -0
  155. package/dist/types/type.d.ts.map +1 -1
  156. package/dist/types/utilities.d.ts +171 -0
  157. package/dist/types/utilities.d.ts.map +1 -1
  158. package/dist/web/array.js +42 -1
  159. package/dist/web/array.js.map +1 -1
  160. package/dist/web/async-pool-executor.js +15 -0
  161. package/dist/web/async-pool-executor.js.map +1 -1
  162. package/dist/web/browser/form-utilities.js +26 -0
  163. package/dist/web/browser/form-utilities.js.map +1 -1
  164. package/dist/web/browser/geo-location.js +5 -0
  165. package/dist/web/browser/geo-location.js.map +1 -1
  166. package/dist/web/browser/index.js.map +1 -1
  167. package/dist/web/browser/native-bridge.js +9 -0
  168. package/dist/web/browser/native-bridge.js.map +1 -1
  169. package/dist/web/cancellable-promise.js.map +1 -1
  170. package/dist/web/clean-url-search-params.js +1 -0
  171. package/dist/web/clean-url-search-params.js.map +1 -1
  172. package/dist/web/collections/cache-dictionary.js +39 -0
  173. package/dist/web/collections/cache-dictionary.js.map +1 -1
  174. package/dist/web/collections/default-map.js +25 -1
  175. package/dist/web/collections/default-map.js.map +1 -1
  176. package/dist/web/collections/default-weak-map.js +22 -2
  177. package/dist/web/collections/default-weak-map.js.map +1 -1
  178. package/dist/web/{from.js → collections/from.js} +279 -5
  179. package/dist/web/collections/from.js.map +1 -0
  180. package/dist/web/collections/index.js +1 -0
  181. package/dist/web/collections/index.js.map +1 -1
  182. package/dist/web/draft.js +37 -0
  183. package/dist/web/draft.js.map +1 -1
  184. package/dist/web/event-bus.js +1 -0
  185. package/dist/web/event-bus.js.map +1 -1
  186. package/dist/web/index.js +14 -1
  187. package/dist/web/index.js.map +1 -1
  188. package/dist/web/key-value-pair.js +6 -0
  189. package/dist/web/key-value-pair.js.map +1 -1
  190. package/dist/web/lazy.js +4 -0
  191. package/dist/web/lazy.js.map +1 -1
  192. package/dist/web/math.js +19 -0
  193. package/dist/web/math.js.map +1 -1
  194. package/dist/web/order.js.map +1 -1
  195. package/dist/web/parse.js +96 -0
  196. package/dist/web/parse.js.map +1 -1
  197. package/dist/web/patch.js +10 -2
  198. package/dist/web/patch.js.map +1 -1
  199. package/dist/web/range.js +151 -0
  200. package/dist/web/range.js.map +1 -0
  201. package/dist/web/stopwatch.js +10 -0
  202. package/dist/web/stopwatch.js.map +1 -1
  203. package/dist/web/string.js +62 -0
  204. package/dist/web/string.js.map +1 -1
  205. package/dist/web/timer.js +7 -0
  206. package/dist/web/timer.js.map +1 -1
  207. package/dist/web/timespan.js +202 -0
  208. package/dist/web/timespan.js.map +1 -1
  209. package/dist/web/type-code.js.map +1 -1
  210. package/dist/web/type.js +80 -1
  211. package/dist/web/type.js.map +1 -1
  212. package/dist/web/types.js.map +1 -1
  213. package/dist/web/utilities.js +183 -0
  214. package/dist/web/utilities.js.map +1 -1
  215. package/package.json +1 -1
  216. package/src/array.ts +16 -0
  217. package/src/browser/index.ts +2 -2
  218. package/src/collections/cache-dictionary.ts +39 -1
  219. package/src/collections/default-map.ts +15 -9
  220. package/src/collections/default-weak-map.ts +14 -12
  221. package/src/{from.ts → collections/from.ts} +285 -15
  222. package/src/collections/index.ts +4 -3
  223. package/src/index.ts +43 -42
  224. package/src/range.ts +165 -0
  225. package/src/timespan.ts +199 -20
  226. package/dist/cjs/from.js.map +0 -1
  227. package/dist/esm/from.js.map +0 -1
  228. package/dist/types/from.d.ts +0 -59
  229. package/dist/types/from.d.ts.map +0 -1
  230. package/dist/web/from.js.map +0 -1
@@ -1,16 +1,137 @@
1
+ /**
2
+ * Options for {@link parseBoolean}.
3
+ */
1
4
  export interface ParseBooleanOptions {
5
+ /**
6
+ * Additional strings to consider as `true`.
7
+ * These are matched case-insensitively.
8
+ * @example ["oui", "ja"]
9
+ */
2
10
  extraTruthy?: string[];
11
+ /**
12
+ * Additional strings to consider as `false`.
13
+ * These are matched case-insensitively.
14
+ * @example ["non", "nein"]
15
+ */
3
16
  extraFalsy?: string[];
4
17
  }
18
+ /**
19
+ * Options for {@link parseInteger}.
20
+ */
5
21
  export interface ParseIntegerOptions {
22
+ /**
23
+ * Numeric base for conversion.
24
+ * @default 10
25
+ */
6
26
  radix?: number;
27
+ /**
28
+ * Thousands separator to strip before parsing.
29
+ * @example "." for "1.234.567" → 1234567
30
+ * @example "," for "1,234,567" → 1234567
31
+ */
7
32
  thousandsSeparator?: string;
8
33
  }
34
+ /**
35
+ * Options for {@link parseDecimal}.
36
+ */
9
37
  export interface ParseDecimalOptions {
38
+ /**
39
+ * Character used as decimal point.
40
+ * @default "."
41
+ */
10
42
  decimalSeparator?: "." | ",";
43
+ /**
44
+ * Thousands separator to strip before parsing.
45
+ * @example "." for "1.234,56" (EU format)
46
+ * @example "," for "1,234.56" (US format)
47
+ */
11
48
  thousandsSeparator?: string;
12
49
  }
50
+ /**
51
+ * Safely parses a value into an integer.
52
+ * Returns `null` if the value cannot be parsed.
53
+ *
54
+ * - `null` or `undefined` → `null`
55
+ * - `number` → returned as-is (floats are truncated)
56
+ * - `string` → parsed with the given options
57
+ *
58
+ * @param value - The value to parse.
59
+ * @param options - Optional parsing configuration.
60
+ * @returns The parsed integer, or `null` on failure.
61
+ *
62
+ * @example
63
+ * ```ts
64
+ * parseInteger(42) // 42
65
+ * parseInteger(3.7) // 3
66
+ * parseInteger(null) // null
67
+ * parseInteger(undefined) // null
68
+ * parseInteger("42") // 42
69
+ * parseInteger("1.234.567", { thousandsSeparator: "." }) // 1234567
70
+ * parseInteger("FF", { radix: 16 }) // 255
71
+ * parseInteger("abc") // null
72
+ * ```
73
+ */
13
74
  export declare function parseInteger(value: string | number | null | undefined, options?: ParseIntegerOptions): number | null;
75
+ /**
76
+ * Safely parses a value into a floating-point number.
77
+ * Returns `null` if the value cannot be parsed.
78
+ *
79
+ * - `null` or `undefined` → `null`
80
+ * - `number` → returned as-is (if finite)
81
+ * - `string` → parsed with the given options
82
+ *
83
+ * Supports custom decimal and thousands separators, making it suitable
84
+ * for both US (`1,234.56`) and EU (`1.234,56`) number formats.
85
+ *
86
+ * @param value - The value to parse.
87
+ * @param options - Optional parsing configuration.
88
+ * @returns The parsed float, or `null` on failure.
89
+ *
90
+ * @example
91
+ * ```ts
92
+ * parseDecimal(3.14) // 3.14
93
+ * parseDecimal(null) // null
94
+ * parseDecimal(undefined) // null
95
+ * parseDecimal("3.14") // 3.14
96
+ * parseDecimal("3,14", { decimalSeparator: "," }) // 3.14
97
+ * parseDecimal("1.234,56", { decimalSeparator: ",", thousandsSeparator: "." }) // 1234.56
98
+ * parseDecimal("abc") // null
99
+ * ```
100
+ */
14
101
  export declare function parseDecimal(value: string | number | null | undefined, options?: ParseDecimalOptions): number | null;
102
+ /**
103
+ * Safely parses a value into a boolean.
104
+ * Returns `null` if the value cannot be interpreted as boolean.
105
+ *
106
+ * - `null` or `undefined` → `null`
107
+ * - `boolean` → returned as-is
108
+ * - `number` → `0` is `false`, any other finite number is `true`
109
+ * - `string` → matched case-insensitively against known truthy/falsy values
110
+ *
111
+ * Default truthy: `"true"`, `"1"`, `"yes"`, `"si"`, `"sí"`, `"on"`
112
+ * Default falsy: `"false"`, `"0"`, `"no"`, `"off"`
113
+ *
114
+ * @param value - The value to parse.
115
+ * @param options - Optional parsing configuration.
116
+ * @returns The parsed boolean, or `null` on failure.
117
+ *
118
+ * @example
119
+ * ```ts
120
+ * parseBoolean(true) // true
121
+ * parseBoolean(false) // false
122
+ * parseBoolean(1) // true
123
+ * parseBoolean(0) // false
124
+ * parseBoolean(null) // null
125
+ * parseBoolean(undefined) // null
126
+ * parseBoolean("yes") // true
127
+ * parseBoolean("no") // false
128
+ * parseBoolean("sí") // true
129
+ * parseBoolean("TRUE") // true
130
+ * parseBoolean("oui") // null
131
+ * parseBoolean("oui", { extraTruthy: ["oui"] }) // true
132
+ * parseBoolean("nein", { extraFalsy: ["nein"] }) // false
133
+ * parseBoolean("whatever") // null
134
+ * ```
135
+ */
15
136
  export declare function parseBoolean(value: string | number | boolean | null | undefined, options?: ParseBooleanOptions): boolean | null;
16
137
  //# sourceMappingURL=parse.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/parse.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,mBAAmB;IAMhC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IAOvB,UAAU,CAAC,EAAE,MAAM,EAAE,C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;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,YAAY,CACxB,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,EACzC,OAAO,GAAE,mBAAwB,GAClC,MAAM,GAAG,IAAI,CAiBf;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,YAAY,CACxB,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,EACzC,OAAO,GAAE,mBAAwB,GAClC,MAAM,GAAG,IAAI,CAwBf;AASD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,YAAY,CACxB,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,EACnD,OAAO,GAAE,mBAAwB,GAClC,OAAO,GAAG,IAAI,CAsBhB"}
@@ -0,0 +1,72 @@
1
+ export default class Range<T> {
2
+ private readonly start;
3
+ private readonly end;
4
+ /**
5
+ * Range constructor.
6
+ * @param start
7
+ * @param end
8
+ */
9
+ constructor(start: T, end: T);
10
+ /**
11
+ * Finds the intersection between two ranges.
12
+ *
13
+ * @param other The Range object to intersect with.
14
+ * @returns The intersected Range object, or null if there is no intersection.
15
+ */
16
+ intersect(other: Range<T>): Range<T> | null;
17
+ /**
18
+ * Subtract the given range from this range.
19
+ *
20
+ * @param other The range to subtract from this range.
21
+ * @returns An array of Range objects representing the result of the subtraction.
22
+ */
23
+ subtract(other: Range<T>): Range<T>[];
24
+ /**
25
+ * Determines if the given range overlaps with the current range.
26
+ *
27
+ * @param other The range to be checked for overlap.
28
+ * @returns Returns true if there is an overlap between the ranges, false otherwise.
29
+ */
30
+ overlaps(other: Range<T>): boolean;
31
+ /**
32
+ * Determines whether the specified value is within the range defined by the start and end values.
33
+ *
34
+ * @param obj The value to check if it is within the range.
35
+ * @param inclusive Optional. If set to true, the range boundaries are considered inclusive.
36
+ * @returns Returns true if the specified value is within the range, false otherwise.
37
+ */
38
+ contains(obj: T, inclusive?: boolean): boolean;
39
+ /**
40
+ * @returns T
41
+ */
42
+ getStart(): T;
43
+ /**
44
+ * @returns T
45
+ */
46
+ getEnd(): T;
47
+ /**
48
+ * Finds the intersection between two sets of ranges.
49
+ *
50
+ * @param ranges1
51
+ * @param ranges2
52
+ * @returns
53
+ */
54
+ static intersectRanges<T>(ranges1: Range<T>[], ranges2: Range<T>[]): Range<T>[];
55
+ /**
56
+ * Determines if any range in the first set overlaps with any range in the second set.
57
+ *
58
+ * @param ranges1
59
+ * @param ranges2
60
+ * @returns
61
+ */
62
+ static overlapsAny<T>(ranges1: Range<T>[], ranges2: Range<T>[]): boolean;
63
+ /**
64
+ * Subtracts the second set of ranges from the first set of ranges.
65
+ *
66
+ * @param ranges1
67
+ * @param ranges2
68
+ * @returns
69
+ */
70
+ static subtractRanges<T>(ranges1: Range<T>[], ranges2: Range<T>[]): Range<T>[];
71
+ }
72
+ //# sourceMappingURL=range.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"range.d.ts","sourceRoot":"","sources":["../../src/range.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,KAAK,CAAC,CAAC;IAExB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAI;IAC1B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAI;IAExB;;;;OAIG;gBACS,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC;IAK5B;;;;;OAKG;IACI,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI;IAWlD;;;;;OAKG;IACI,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE;IAoB5C;;;;;OAKG;IACI,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,OAAO;IAWzC;;;;;;OAMG;IACI,QAAQ,CAAC,GAAG,EAAE,CAAC,EAAE,SAAS,GAAE,OAAc,GAAG,OAAO;IAM3D;;OAEG;IACI,QAAQ,IAAI,CAAC;IAIpB;;OAEG;IACI,MAAM,IAAI,CAAC;IAIlB;;;;;;OAMG;WACW,eAAe,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE;IAatF;;;;;;OAMG;WACW,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO;IAW/E;;;;;;OAMG;WACW,cAAc,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE;CAiBxF"}
@@ -1,9 +1,60 @@
1
+ /**
2
+ * Ensures that a given string has a specific prefix.
3
+ *
4
+ * @param {string} str - The string to ensure the prefix on.
5
+ * @param {string} prefix - The prefix to ensure on the string.
6
+ * @return {string} - The resulting string with the ensured prefix.
7
+ */
1
8
  export declare function ensurePrefix(str: string, prefix: string): string;
9
+ /**
10
+ * Ensures that a string ends with a specified suffix.
11
+ *
12
+ * @param {string} str - The original string.
13
+ * @param {string} suffix - The suffix to ensure.
14
+ * @return {string} - The modified string with the suffix added if it was not already present.
15
+ */
2
16
  export declare function ensureSuffix(str: string, suffix: string): string;
17
+ /**
18
+ * Formats a string using a template and provided arguments.
19
+ *
20
+ * @param {string} template - The template string containing placeholders.
21
+ * @param {any[]} args - Optional arguments to replace the placeholders in the template.
22
+ * @return {string} The formatted string.
23
+ */
3
24
  export declare function format(template: string, ...args: any[]): string;
25
+ /**
26
+ * Converts a string to snake_case.
27
+ *
28
+ * @param {string} str - The string to convert.
29
+ * @return {string} - The string converted to snake_case.
30
+ */
4
31
  export declare function toSnakeCase(str: string): string;
32
+ /**
33
+ * Converts a string to kebab-case.
34
+ *
35
+ * @param {string} str - The string to convert.
36
+ * @return {string} - The string converted to kebab-case.
37
+ */
5
38
  export declare function toKebabCase(str: string): string;
39
+ /**
40
+ * Converts a string to camelCase.
41
+ *
42
+ * @param {string} str - The string to convert.
43
+ * @return {string} - The string converted to camelCase.
44
+ */
6
45
  export declare function toCamelCase(str: string): string;
46
+ /**
47
+ * Converts a string to PascalCase.
48
+ *
49
+ * @param {string} str - The string to convert.
50
+ * @return {string} - The string converted to PascalCase.
51
+ */
7
52
  export declare function toPascalCase(str: string): string;
53
+ /**
54
+ * Converts a string to CONSTANT_CASE (a.k.a. SCREAMING_SNAKE_CASE).
55
+ *
56
+ * @param {string} str - The string to convert.
57
+ * @return {string} - The string converted to CONSTANT_CASE.
58
+ */
8
59
  export declare function toConstantCase(str: string): string;
9
60
  //# sourceMappingURL=string.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../src/string.ts"],"names":[],"mappings":"AAQA,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAIhE;AAUD,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAIhE;AASD,wBAAgB,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,MAAM,CAa/D;AAgCD,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE/C;AAQD,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE/C;AAQD,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAM/C;AAQD,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAIhD;AAQD,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAElD"}
1
+ {"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../src/string.ts"],"names":[],"mappings":"AACA;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAIhE;AAGD;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAIhE;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,MAAM,CAa/D;AA0BD;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAM/C;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAIhD;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAElD"}
@@ -1,7 +1,14 @@
1
+ /**
2
+ * A class representing a timer that executes a callback function at a specified interval.
3
+ */
1
4
  export default class Timer {
2
5
  private _callback;
3
6
  private _interval;
4
7
  private _intervalId;
8
+ /**
9
+ * @param callback Callback
10
+ * @param interval Seconds between calls
11
+ */
5
12
  constructor(callback: () => void, interval: number);
6
13
  get running(): boolean;
7
14
  get interval(): number;
@@ -1 +1 @@
1
- {"version":3,"file":"timer.d.ts","sourceRoot":"","sources":["../../src/timer.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,OAAO,OAAO,KAAK;IAEtB,OAAO,CAAC,SAAS,CAAa;IAC9B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,WAAW,CAAa;gBAMpB,QAAQ,EAAE,MAAM,IAAI,EAAE,QAAQ,EAAE,MAAM;IAOlD,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED,IAAI,QAAQ,CAAC,KAAK,EAAE,MAAM,EAMzB;IAED,IAAI,QAAQ,IAAI,MAAM,IAAI,CAEzB;IAED,IAAI,QAAQ,CAAC,KAAK,EAAE,MAAM,IAAI,EAI7B;IAGD,KAAK,IAAI,IAAI;IASb,IAAI,IAAI,IAAI;IAOZ,OAAO,IAAI,IAAI;CAIlB"}
1
+ {"version":3,"file":"timer.d.ts","sourceRoot":"","sources":["../../src/timer.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,KAAK;IAEtB,OAAO,CAAC,SAAS,CAAa;IAC9B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,WAAW,CAAa;IAEhC;;;OAGG;gBACS,QAAQ,EAAE,MAAM,IAAI,EAAE,QAAQ,EAAE,MAAM;IAOlD,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED,IAAI,QAAQ,CAAC,KAAK,EAAE,MAAM,EAMzB;IAED,IAAI,QAAQ,IAAI,MAAM,IAAI,CAEzB;IAED,IAAI,QAAQ,CAAC,KAAK,EAAE,MAAM,IAAI,EAI7B;IAGD,KAAK,IAAI,IAAI;IASb,IAAI,IAAI,IAAI;IAOZ,OAAO,IAAI,IAAI;CAIlB"}
@@ -1,47 +1,249 @@
1
+ /**
2
+ * Represents a duration of time in milliseconds.
3
+ */
1
4
  export default class TimeSpan {
2
5
  milliseconds: number;
3
6
  private constructor();
7
+ /**
8
+ * Gets the time interval in seconds.
9
+ * @returns {number} The duration in seconds.
10
+ */
4
11
  seconds(): number;
12
+ /**
13
+ * Gets the time interval in minutes.
14
+ * @returns {number} The duration in minutes.
15
+ */
5
16
  minutes(): number;
17
+ /**
18
+ * Gets the time interval in hours.
19
+ * @returns {number} The duration in hours.
20
+ */
6
21
  hours(): number;
22
+ /**
23
+ * Gets the time interval in days.
24
+ * @returns {number} The duration in days.
25
+ */
7
26
  days(): number;
27
+ /**
28
+ * Gets the time interval in weeks.
29
+ * @returns {number} The duration in weeks.
30
+ */
8
31
  weeks(): number;
32
+ /**
33
+ * Creates a TimeSpan from a specified number of milliseconds.
34
+ * @param {number} milliseconds - The number of milliseconds.
35
+ * @returns {TimeSpan} A new TimeSpan instance.
36
+ */
9
37
  static fromMilliseconds(milliseconds: number): TimeSpan;
38
+ /**
39
+ * Creates a TimeSpan from a specified number of seconds.
40
+ * @param {number} seconds - The number of seconds.
41
+ * @returns {TimeSpan} A new TimeSpan instance.
42
+ */
10
43
  static fromSeconds(seconds: number): TimeSpan;
44
+ /**
45
+ * Creates a TimeSpan from a specified number of minutes.
46
+ * @param {number} minutes - The number of minutes.
47
+ * @returns {TimeSpan} A new TimeSpan instance.
48
+ */
11
49
  static fromMinutes(minutes: number): TimeSpan;
50
+ /**
51
+ * Creates a TimeSpan from a specified number of hours.
52
+ * @param {number} hours - The number of hours.
53
+ * @returns {TimeSpan} A new TimeSpan instance.
54
+ */
12
55
  static fromHours(hours: number): TimeSpan;
56
+ /**
57
+ * Creates a TimeSpan from a specified number of days.
58
+ * @param {number} days - The number of days.
59
+ * @returns {TimeSpan} A new TimeSpan instance.
60
+ */
13
61
  static fromDays(days: number): TimeSpan;
62
+ /**
63
+ * Creates a TimeSpan from a specified number of weeks.
64
+ * @param {number} weeks - The number of weeks.
65
+ * @returns {TimeSpan} A new TimeSpan instance.
66
+ */
14
67
  static fromWeeks(weeks: number): TimeSpan;
68
+ /**
69
+ * Returns a new TimeSpan that adds the specified number of milliseconds to this instance.
70
+ * @param {number} milliseconds - The milliseconds to add.
71
+ * @returns {TimeSpan} A new TimeSpan instance.
72
+ */
15
73
  addMilliseconds(milliseconds: number): TimeSpan;
74
+ /**
75
+ * Returns a new TimeSpan that adds the specified number of seconds to this instance.
76
+ * @param {number} seconds - The seconds to add.
77
+ * @returns {TimeSpan} A new TimeSpan instance.
78
+ */
16
79
  addSeconds(seconds: number): TimeSpan;
80
+ /**
81
+ * Returns a new TimeSpan that adds the specified number of minutes to this instance.
82
+ * @param {number} minutes - The minutes to add.
83
+ * @returns {TimeSpan} A new TimeSpan instance.
84
+ */
17
85
  addMinutes(minutes: number): TimeSpan;
86
+ /**
87
+ * Returns a new TimeSpan that adds the specified number of hours to this instance.
88
+ * @param {number} hours - The hours to add.
89
+ * @returns {TimeSpan} A new TimeSpan instance.
90
+ */
18
91
  addHours(hours: number): TimeSpan;
92
+ /**
93
+ * Returns a new TimeSpan that adds the specified number of days to this instance.
94
+ * @param {number} days - The days to add.
95
+ * @returns {TimeSpan} A new TimeSpan instance.
96
+ */
19
97
  addDays(days: number): TimeSpan;
98
+ /**
99
+ * Returns a new TimeSpan that adds the specified number of weeks to this instance.
100
+ * @param {number} weeks - The weeks to add.
101
+ * @returns {TimeSpan} A new TimeSpan instance.
102
+ */
20
103
  addWeeks(weeks: number): TimeSpan;
104
+ /**
105
+ * Returns a new TimeSpan that subtracts the specified number of milliseconds from this instance.
106
+ * @param {number} milliseconds - The milliseconds to subtract.
107
+ * @returns {TimeSpan} A new TimeSpan instance.
108
+ */
21
109
  subtractMilliseconds(milliseconds: number): TimeSpan;
110
+ /**
111
+ * Returns a new TimeSpan that subtracts the specified number of seconds from this instance.
112
+ * @param {number} seconds - The seconds to subtract.
113
+ * @returns {TimeSpan} A new TimeSpan instance.
114
+ */
22
115
  subtractSeconds(seconds: number): TimeSpan;
116
+ /**
117
+ * Returns a new TimeSpan that subtracts the specified number of minutes from this instance.
118
+ * @param {number} minutes - The minutes to subtract.
119
+ * @returns {TimeSpan} A new TimeSpan instance.
120
+ */
23
121
  subtractMinutes(minutes: number): TimeSpan;
122
+ /**
123
+ * Returns a new TimeSpan that subtracts the specified number of hours from this instance.
124
+ * @param {number} hours - The hours to subtract.
125
+ * @returns {TimeSpan} A new TimeSpan instance.
126
+ */
24
127
  subtractHours(hours: number): TimeSpan;
128
+ /**
129
+ * Returns a new TimeSpan that subtracts the specified number of days from this instance.
130
+ * @param {number} days - The days to subtract.
131
+ * @returns {TimeSpan} A new TimeSpan instance.
132
+ */
25
133
  subtractDays(days: number): TimeSpan;
134
+ /**
135
+ * Returns a new TimeSpan that subtracts the specified number of weeks from this instance.
136
+ * @param {number} weeks - The weeks to subtract.
137
+ * @returns {TimeSpan} A new TimeSpan instance.
138
+ */
26
139
  subtractWeeks(weeks: number): TimeSpan;
140
+ /**
141
+ * Returns a new TimeSpan that adds the specified TimeSpan to this instance.
142
+ * @param {TimeSpan} other - The TimeSpan to add.
143
+ * @returns {TimeSpan} A new TimeSpan instance.
144
+ */
27
145
  add(other: TimeSpan): TimeSpan;
146
+ /**
147
+ * Returns a new TimeSpan that subtracts the specified TimeSpan from this instance.
148
+ * @param {TimeSpan} other - The TimeSpan to subtract.
149
+ * @returns {TimeSpan} A new TimeSpan instance.
150
+ */
28
151
  subtract(other: TimeSpan): TimeSpan;
152
+ /**
153
+ * Adds this TimeSpan to a specified Date.
154
+ * @param {Date} date - The date to add to.
155
+ * @returns {Date} A new Date instance.
156
+ */
29
157
  addTo(date: Date): Date;
158
+ /**
159
+ * Subtracts this TimeSpan from a specified Date.
160
+ * @param {Date} date - The date to subtract from.
161
+ * @returns {Date} A new Date instance.
162
+ */
30
163
  subtractFrom(date: Date): Date;
164
+ /**
165
+ * Creates a TimeSpan from the difference between two dates.
166
+ * @param {Date} earlierDate - The earlier date.
167
+ * @param {Date} laterDate - The later date.
168
+ * @returns {TimeSpan} A new TimeSpan instance representing the difference.
169
+ */
31
170
  static fromDifference(earlierDate: Date, laterDate: Date): TimeSpan;
171
+ /**
172
+ * Formats the TimeSpan as a string.
173
+ * Supported tokens: hh, h, mm, m, ss, s.
174
+ * @param {string} format - The format string (default: 'hh:mm:ss').
175
+ * @returns {string} The formatted string.
176
+ */
32
177
  format(format?: string): string;
178
+ /**
179
+ * Checks if this TimeSpan is equal to another.
180
+ * @param {TimeSpan} other - The other TimeSpan.
181
+ * @returns {boolean} True if equal.
182
+ */
33
183
  eq(other: TimeSpan): boolean;
184
+ /**
185
+ * Checks if this TimeSpan is less than or equal to another.
186
+ * @param {TimeSpan} other - The other TimeSpan.
187
+ * @returns {boolean} True if less than or equal.
188
+ */
34
189
  le(other: TimeSpan): boolean;
190
+ /**
191
+ * Checks if this TimeSpan is less than another.
192
+ * @param {TimeSpan} other - The other TimeSpan.
193
+ * @returns {boolean} True if less than.
194
+ */
35
195
  lt(other: TimeSpan): boolean;
196
+ /**
197
+ * Checks if this TimeSpan is greater than or equal to another.
198
+ * @param {TimeSpan} other - The other TimeSpan.
199
+ * @returns {boolean} True if greater than or equal.
200
+ */
36
201
  ge(other: TimeSpan): boolean;
202
+ /**
203
+ * Checks if this TimeSpan is greater than another.
204
+ * @param {TimeSpan} other - The other TimeSpan.
205
+ * @returns {boolean} True if greater than.
206
+ */
37
207
  gt(other: TimeSpan): boolean;
208
+ /**
209
+ * Multiplies the TimeSpan by a number.
210
+ * @param {number} number - The multiplier.
211
+ * @returns {TimeSpan} A new TimeSpan instance.
212
+ */
38
213
  multiply(number: number): TimeSpan;
214
+ /**
215
+ * Divides the TimeSpan by a number.
216
+ * @param {number} number - The divisor.
217
+ * @returns {TimeSpan} A new TimeSpan instance.
218
+ */
39
219
  divide(number: number): TimeSpan;
220
+ /**
221
+ * Returns the absolute value of the TimeSpan.
222
+ * @returns {TimeSpan} A new TimeSpan instance.
223
+ */
40
224
  abs(): TimeSpan;
225
+ /**
226
+ * Infinite duration.
227
+ */
41
228
  static readonly INFINITE: TimeSpan;
229
+ /**
230
+ * Negative infinite duration.
231
+ */
42
232
  static readonly NEGATIVE_INFINITE: TimeSpan;
233
+ /**
234
+ * Checks if the TimeSpan is infinite.
235
+ * @returns {boolean} True if infinite.
236
+ */
43
237
  isInfinite(): boolean;
238
+ /**
239
+ * Checks if the TimeSpan is positive infinite.
240
+ * @returns {boolean} True if positive infinite.
241
+ */
44
242
  isPositiveInfinite(): boolean;
243
+ /**
244
+ * Checks if the TimeSpan is negative infinite.
245
+ * @returns {boolean} True if negative infinite.
246
+ */
45
247
  isNegativeInfinite(): boolean;
46
248
  }
47
249
  //# sourceMappingURL=timespan.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"timespan.d.ts","sourceRoot":"","sources":["../../src/timespan.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,OAAO,OAAO,QAAQ;IAClB,YAAY,EAAE,MAAM,CAAC;IAE5B,OAAO;IAMP,OAAO,IAAI,MAAM;IAKjB,OAAO,IAAI,MAAM;IAKjB,KAAK,IAAI,MAAM;IAKf,IAAI,IAAI,MAAM;IAKd,KAAK,IAAI,MAAM;IAKf,MAAM,CAAC,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,QAAQ;IAKvD,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ;IAK7C,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ;IAK7C,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ;IAKzC,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ;IAKvC,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ;IAKzC,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,QAAQ;IAI/C,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ;IAIrC,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ;IAIrC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ;IAIjC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ;IAI/B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ;IA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GAAG,IAAI,QAAQ;IAIf;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,QAAQ,WAA0C;IAElE;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,iBAAiB,WAA0C;IAE3E;;;OAGG;IACH,UAAU;IAIV;;;OAGG;IACH,kBAAkB,IAAI,OAAO;IAI7B;;;OAGG;IACH,kBAAkB,IAAI,OAAO;CAGhC"}
@@ -16,9 +16,49 @@ export default class Type<T = unknown> {
16
16
  readonly constructorRef: Constructor<T> | undefined;
17
17
  readonly typeCode: TypeCode;
18
18
  private constructor();
19
+ /**
20
+ * Obtiene el `Type` de cualquier valor, constructor o primitivo.
21
+ *
22
+ * Unifica `typeof()` y `.GetType()` de C# en un solo método.
23
+ *
24
+ * **Reglas de resolución:**
25
+ * 1. `null` / `undefined` → tipo nullish correspondiente
26
+ * 2. Primitivo (`number`, `string`, etc.) → tipo primitivo
27
+ * 3. Array → `Type.Array`
28
+ * 4. Función/Constructor → tipo del constructor (no "Function")
29
+ * 5. Objeto → tipo basado en su constructor
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * Type.of(42) // Type<number> — primitivo
34
+ * Type.of('hello') // Type<string> — primitivo
35
+ * Type.of(new Date()) // Type<Date> — desde instancia
36
+ * Type.of(Date) // Type<Date> — desde constructor
37
+ * Type.of(null) // Type<null>
38
+ * Type.of([1, 2, 3]) // Type<Array>
39
+ * ```
40
+ */
19
41
  static of<U>(target: U | Constructor<U>): Type<U>;
42
+ /**
43
+ * Resuelve funciones y constructores.
44
+ *
45
+ * Decisión clave: si la función tiene un `prototype` con
46
+ * miembros propios o empieza con `class`, es un constructor
47
+ * y devolvemos el tipo que construye. Si no, es una función.
48
+ */
20
49
  private static _resolveFunction;
50
+ /**
51
+ * Resuelve objetos por su cadena de prototipos.
52
+ */
21
53
  private static _resolveObject;
54
+ /**
55
+ * Heurística para distinguir constructores de funciones planas.
56
+ *
57
+ * Un "constructor" cumple al menos una de:
58
+ * - Su `toString()` empieza con "class "
59
+ * - Tiene propiedades propias en su prototype (más allá de constructor)
60
+ * - Es un built-in conocido (Date, Map, Set, etc.)
61
+ */
22
62
  private static _isConstructorLike;
23
63
  get isPrimitive(): boolean;
24
64
  get isNullish(): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../src/type.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAC,KAAK,WAAW,EAAC,MAAM,YAAY,CAAC;AAE5C,MAAM,CAAC,OAAO,OAAO,IAAI,CAAC,CAAC,GAAG,OAAO;IAMjC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAA4B;IAM1D,gBAAuB,MAAM,eAA6E;IAC1G,gBAAuB,MAAM,eAA6E;IAC1G,gBAAuB,OAAO,gBAAiF;IAC/G,gBAAuB,MAAM,eAA6E;IAC1G,gBAAuB,MAAM,eAA6E;IAC1G,gBAAuB,IAAI,aAAqE;IAChG,gBAAuB,SAAS,kBAAyF;IACzH,gBAAuB,MAAM,eAAwE;IACrG,gBAAuB,QAAQ,iBAAkF;IACjH,gBAAuB,KAAK,kBAAuE;IAMnG,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,cAAc,EAC1B,WAAW,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;IAC/B,SAAgB,QAAQ,EAAE,QAAQ,CAAC;IAEnC,OAAO;WAoCO,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IAqCxD,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAoB/B,OAAO,CAAC,MAAM,CAAC,cAAc;IAoB7B,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAuBjC,IAAW,WAAW,IAAI,OAAO,CAQhC;IAED,IAAW,SAAS,IAAI,OAAO,CAE9B;IAED,IAAW,eAAe,IAAI,OAAO,CAEpC;I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