toolbox-x 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 (190) hide show
  1. package/LICENSE +201 -0
  2. package/dist/Color-B3mgF9Dh.d.cts +486 -0
  3. package/dist/Color-D38Xrw65.d.mts +486 -0
  4. package/dist/Stylog-Df7eq3-j.d.cts +519 -0
  5. package/dist/Stylog-jvlLcMQq.d.mts +519 -0
  6. package/dist/array-DvW0zIu6.d.mts +130 -0
  7. package/dist/array-rUnEVisO.d.cts +130 -0
  8. package/dist/basics-D_eSv0cu.cjs +132 -0
  9. package/dist/basics-Dp_aEK81.mjs +115 -0
  10. package/dist/basics-WEYWlnRO.d.cts +95 -0
  11. package/dist/basics-uBSfkBEI.d.mts +95 -0
  12. package/dist/case-BWIt8Ash.mjs +449 -0
  13. package/dist/case-C-S-b5YP.d.cts +327 -0
  14. package/dist/case-CS8Ii3A7.cjs +526 -0
  15. package/dist/case-CybASFPD.d.mts +327 -0
  16. package/dist/change-case.cjs +32 -0
  17. package/dist/change-case.d.cts +18 -0
  18. package/dist/change-case.d.mts +18 -0
  19. package/dist/change-case.mjs +19 -0
  20. package/dist/colors.cjs +574 -0
  21. package/dist/colors.d.cts +355 -0
  22. package/dist/colors.d.mts +355 -0
  23. package/dist/colors.mjs +547 -0
  24. package/dist/constants-2gAw23_7.mjs +144 -0
  25. package/dist/constants-B34K0QPi.d.cts +21 -0
  26. package/dist/constants-BIBDKY1u.cjs +924 -0
  27. package/dist/constants-BWT-810U.cjs +158 -0
  28. package/dist/constants-BwbHnXlM.mjs +662 -0
  29. package/dist/constants-BxN9l5el.cjs +74 -0
  30. package/dist/constants-CLS_bgKD.d.mts +847 -0
  31. package/dist/constants-D73iFu8g.mjs +171 -0
  32. package/dist/constants-DAfRxaa8.mjs +62 -0
  33. package/dist/constants-DQYeCjlx.cjs +207 -0
  34. package/dist/constants-Deeie-iH.d.mts +21 -0
  35. package/dist/constants-DpTG9RP6.d.mts +29 -0
  36. package/dist/constants-DqwnkJ_d.cjs +740 -0
  37. package/dist/constants-DvRUY_FY.cjs +150 -0
  38. package/dist/constants-VcRtQu0K.d.cts +29 -0
  39. package/dist/constants-X5hm1UtB.mjs +912 -0
  40. package/dist/constants-eNd-iYsV.mjs +134 -0
  41. package/dist/constants-qm8FafmD.d.cts +847 -0
  42. package/dist/constants.cjs +415 -0
  43. package/dist/constants.d.cts +184 -0
  44. package/dist/constants.d.mts +184 -0
  45. package/dist/constants.mjs +378 -0
  46. package/dist/convert-BOCgUv2D.cjs +252 -0
  47. package/dist/convert-Bn4jFomQ.mjs +169 -0
  48. package/dist/convert-BrzlG-m_.cjs +475 -0
  49. package/dist/convert-DhaUoPVU.mjs +368 -0
  50. package/dist/converter-1P90_RcP.d.mts +402 -0
  51. package/dist/converter-CmkcAppi.d.cts +402 -0
  52. package/dist/converter.cjs +780 -0
  53. package/dist/converter.d.cts +29 -0
  54. package/dist/converter.d.mts +29 -0
  55. package/dist/converter.mjs +771 -0
  56. package/dist/countries-CIpmtEzV.cjs +1469 -0
  57. package/dist/countries-Cy0xiqS3.mjs +1463 -0
  58. package/dist/css-colors-Bx947Ng3.d.cts +179 -0
  59. package/dist/css-colors-CXCDqQbG.cjs +186 -0
  60. package/dist/css-colors-CXTp1vvy.d.mts +179 -0
  61. package/dist/css-colors-DfUW3nTR.mjs +180 -0
  62. package/dist/date.cjs +332 -0
  63. package/dist/date.d.cts +213 -0
  64. package/dist/date.d.mts +213 -0
  65. package/dist/date.mjs +298 -0
  66. package/dist/dom.cjs +461 -0
  67. package/dist/dom.d.cts +228 -0
  68. package/dist/dom.d.mts +228 -0
  69. package/dist/dom.mjs +429 -0
  70. package/dist/form-BMFVGUrN.d.mts +118 -0
  71. package/dist/form-DRFbryvK.d.cts +118 -0
  72. package/dist/guards-3kaUX66g.mjs +157 -0
  73. package/dist/guards-C8gkvIHb.cjs +240 -0
  74. package/dist/guards-DdyU4h4o.mjs +110 -0
  75. package/dist/guards-Efhp1mNy.cjs +151 -0
  76. package/dist/guards.cjs +172 -0
  77. package/dist/guards.d.cts +399 -0
  78. package/dist/guards.d.mts +399 -0
  79. package/dist/guards.mjs +75 -0
  80. package/dist/hash-B6JPEyAz.d.mts +131 -0
  81. package/dist/hash-NTpeKYB_.d.cts +131 -0
  82. package/dist/hash.cjs +2126 -0
  83. package/dist/hash.d.cts +1239 -0
  84. package/dist/hash.d.mts +1239 -0
  85. package/dist/hash.mjs +2095 -0
  86. package/dist/http-status-BAZdtr7-.d.mts +65 -0
  87. package/dist/http-status-U_3MtoGb.d.cts +65 -0
  88. package/dist/http-status.cjs +173 -0
  89. package/dist/http-status.d.cts +142 -0
  90. package/dist/http-status.d.mts +142 -0
  91. package/dist/http-status.mjs +171 -0
  92. package/dist/index.cjs +2551 -0
  93. package/dist/index.d.cts +1493 -0
  94. package/dist/index.d.mts +1493 -0
  95. package/dist/index.mjs +2357 -0
  96. package/dist/object-B0TV3eHx.d.mts +8052 -0
  97. package/dist/object-Blq0Amdv.d.cts +8052 -0
  98. package/dist/objectify-CDs0Fbr1.mjs +417 -0
  99. package/dist/objectify-DIJ-OBmo.cjs +524 -0
  100. package/dist/paginator.cjs +245 -0
  101. package/dist/paginator.d.cts +144 -0
  102. package/dist/paginator.d.mts +144 -0
  103. package/dist/paginator.mjs +243 -0
  104. package/dist/parse-2ubxXZRp.cjs +211 -0
  105. package/dist/parse-N7g942uy.mjs +164 -0
  106. package/dist/pluralizer-BjMIc6uT.d.mts +42 -0
  107. package/dist/pluralizer-Cb6ZmrDl.d.cts +42 -0
  108. package/dist/pluralizer.cjs +678 -0
  109. package/dist/pluralizer.d.cts +152 -0
  110. package/dist/pluralizer.d.mts +152 -0
  111. package/dist/pluralizer.mjs +676 -0
  112. package/dist/primitives-B26uZolQ.cjs +228 -0
  113. package/dist/primitives-KsFUp3kQ.mjs +144 -0
  114. package/dist/specials-D48_IZbd.d.mts +108 -0
  115. package/dist/specials-DzLr1ZgU.cjs +477 -0
  116. package/dist/specials-LVONlKbQ.d.cts +108 -0
  117. package/dist/specials-uhDuRg8H.mjs +292 -0
  118. package/dist/string-CBAbxaG1.d.mts +258 -0
  119. package/dist/string-CsNsm_65.d.cts +258 -0
  120. package/dist/stylog.cjs +621 -0
  121. package/dist/stylog.d.cts +49 -0
  122. package/dist/stylog.d.mts +49 -0
  123. package/dist/stylog.mjs +614 -0
  124. package/dist/timezone-B2OYK6Fh.mjs +5589 -0
  125. package/dist/timezone-Beh9IGpw.cjs +5625 -0
  126. package/dist/types/array.cjs +16 -0
  127. package/dist/types/array.d.cts +18 -0
  128. package/dist/types/array.d.mts +18 -0
  129. package/dist/types/array.mjs +17 -0
  130. package/dist/types/colors.cjs +16 -0
  131. package/dist/types/colors.d.cts +18 -0
  132. package/dist/types/colors.d.mts +18 -0
  133. package/dist/types/colors.mjs +17 -0
  134. package/dist/types/converter.cjs +16 -0
  135. package/dist/types/converter.d.cts +18 -0
  136. package/dist/types/converter.d.mts +18 -0
  137. package/dist/types/converter.mjs +17 -0
  138. package/dist/types/form.cjs +16 -0
  139. package/dist/types/form.d.cts +18 -0
  140. package/dist/types/form.d.mts +18 -0
  141. package/dist/types/form.mjs +17 -0
  142. package/dist/types/hash.cjs +16 -0
  143. package/dist/types/hash.d.cts +18 -0
  144. package/dist/types/hash.d.mts +18 -0
  145. package/dist/types/hash.mjs +17 -0
  146. package/dist/types/http-status.cjs +16 -0
  147. package/dist/types/http-status.d.cts +18 -0
  148. package/dist/types/http-status.d.mts +18 -0
  149. package/dist/types/http-status.mjs +17 -0
  150. package/dist/types/index.cjs +16 -0
  151. package/dist/types/index.d.cts +18 -0
  152. package/dist/types/index.d.mts +18 -0
  153. package/dist/types/index.mjs +17 -0
  154. package/dist/types/number.cjs +16 -0
  155. package/dist/types/number.d.cts +18 -0
  156. package/dist/types/number.d.mts +18 -0
  157. package/dist/types/number.mjs +17 -0
  158. package/dist/types/object.cjs +16 -0
  159. package/dist/types/object.d.cts +18 -0
  160. package/dist/types/object.d.mts +18 -0
  161. package/dist/types/object.mjs +17 -0
  162. package/dist/types/pluralizer.cjs +16 -0
  163. package/dist/types/pluralizer.d.cts +18 -0
  164. package/dist/types/pluralizer.d.mts +18 -0
  165. package/dist/types/pluralizer.mjs +17 -0
  166. package/dist/types/string.cjs +16 -0
  167. package/dist/types/string.d.cts +18 -0
  168. package/dist/types/string.d.mts +18 -0
  169. package/dist/types/string.mjs +17 -0
  170. package/dist/types/stylog.cjs +16 -0
  171. package/dist/types/stylog.d.cts +18 -0
  172. package/dist/types/stylog.d.mts +18 -0
  173. package/dist/types/stylog.mjs +17 -0
  174. package/dist/types/utils.cjs +16 -0
  175. package/dist/types/utils.d.cts +18 -0
  176. package/dist/types/utils.d.mts +18 -0
  177. package/dist/types/utils.mjs +17 -0
  178. package/dist/types/verbalizer.cjs +16 -0
  179. package/dist/types/verbalizer.d.cts +30 -0
  180. package/dist/types/verbalizer.d.mts +30 -0
  181. package/dist/types/verbalizer.mjs +17 -0
  182. package/dist/utilities-CLUmdQeV.cjs +140 -0
  183. package/dist/utilities-m5yFKqLd.mjs +105 -0
  184. package/dist/utils-ClW9LA6f.mjs +449 -0
  185. package/dist/utils-DLFRgXUC.cjs +568 -0
  186. package/dist/verbalizer.cjs +998 -0
  187. package/dist/verbalizer.d.cts +148 -0
  188. package/dist/verbalizer.d.mts +148 -0
  189. package/dist/verbalizer.mjs +996 -0
  190. package/package.json +249 -0
@@ -0,0 +1,519 @@
1
+ /**
2
+ * Copyright 2026 - present Nazmul Hassan
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { s as CSSColor } from "./Color-D38Xrw65.mjs";
18
+
19
+ //#region src/stylog/constants.d.ts
20
+ /** Records of ANSI-16 colors with values */
21
+ declare const ANSI_16_COLORS: Readonly<{
22
+ readonly black: readonly [30, 39];
23
+ readonly red: readonly [31, 39];
24
+ readonly green: readonly [32, 39];
25
+ readonly yellow: readonly [33, 39];
26
+ readonly blue: readonly [34, 39];
27
+ readonly purple: readonly [35, 39];
28
+ readonly cyan: readonly [36, 39];
29
+ readonly white: readonly [37, 39];
30
+ readonly blackBright: readonly [90, 39];
31
+ readonly redBright: readonly [91, 39];
32
+ readonly greenBright: readonly [92, 39];
33
+ readonly yellowBright: readonly [93, 39];
34
+ readonly blueBright: readonly [94, 39];
35
+ readonly purpleBright: readonly [95, 39];
36
+ readonly cyanBright: readonly [96, 39];
37
+ readonly whiteBright: readonly [97, 39];
38
+ readonly bgBlack: readonly [40, 49];
39
+ readonly bgRed: readonly [41, 49];
40
+ readonly bgGreen: readonly [42, 49];
41
+ readonly bgYellow: readonly [43, 49];
42
+ readonly bgBlue: readonly [44, 49];
43
+ readonly bgPurple: readonly [45, 49];
44
+ readonly bgCyan: readonly [46, 49];
45
+ readonly bgWhite: readonly [47, 49];
46
+ readonly bgBlackBright: readonly [100, 49];
47
+ readonly bgRedBright: readonly [101, 49];
48
+ readonly bgGreenBright: readonly [102, 49];
49
+ readonly bgYellowBright: readonly [103, 49];
50
+ readonly bgBlueBright: readonly [104, 49];
51
+ readonly bgPurpleBright: readonly [105, 49];
52
+ readonly bgCyanBright: readonly [106, 49];
53
+ readonly bgWhiteBright: readonly [107, 49];
54
+ }>;
55
+ //#endregion
56
+ //#region src/types/stylog.d.ts
57
+ /** Non-color text styles */
58
+ type TextStyle = 'bold' | 'bolder' | 'dim' | 'italic' | 'underline' | 'strikethrough' | 'inverse';
59
+ /** Represents `ANSI-16` color names available in `LogStyler` */
60
+ type Ansi16Color = keyof typeof ANSI_16_COLORS;
61
+ /** Represents `ANSI-16` color names with `css-` prefix available in `LogStyler` */
62
+ type CSS16Color = `css-${Ansi16Color}`;
63
+ /** Represents the value of `ANSI-16` color codes */
64
+ type Ansi16Value = (typeof ANSI_16_COLORS)[Ansi16Color];
65
+ /** Represents a css color starting with `bg` (e.g. `"bgRed"`). */
66
+ type BGColor = `bg${Capitalize<CSSColor>}`;
67
+ /** Styles allowed for `LogStyler` or `Stylog` */
68
+ type Styles = CSSColor | BGColor | TextStyle;
69
+ /** A `tuple of strings` that represents `ANSI` color code with special closing and ending */
70
+ type AnsiSequence = [string, string];
71
+ /**
72
+ * * Type representing a fully chainable `LogStyler` instance.
73
+ *
74
+ * @remarks
75
+ * - Each property corresponds to a style and returns a new `Stylog` instance, allowing fluent chaining.
76
+ * - **This type combines:**
77
+ * - The methods of `LogStyler` (e.g., `.style()`, `.log()`)
78
+ * - Dynamically generated properties for all available `Styles` that return another `Stylog` instance for chaining.
79
+ *
80
+ * @example
81
+ * Stylog.green.bold.bgBlue.log('Hello World');
82
+ */
83
+ type StylogChain = LogStyler & { [K in Styles]: StylogChain };
84
+ //#endregion
85
+ //#region src/stylog/Stylog.d.ts
86
+ /**
87
+ * @class Utility class for styling console log output with `ANSI` (`Node.js`) or `CSS` (Browser).
88
+ *
89
+ * @remarks
90
+ * - Allows chaining of style methods or initializing with predefined styles.
91
+ * - For fluent, chainable styling with zero configuration use {@link https://toolbox.nazmul-nhb.dev/docs/utilities/misc/stylog Stylog} (`LogStyler` chainable wrapper).
92
+ *
93
+ * @example
94
+ * const styled = new LogStyler(['red', 'bold']);
95
+ * styled.log('Hello World');
96
+ *
97
+ * const logger = new LogStyler();
98
+ * logger.style('blue', 'dim', 'bold').log('Hello Blue');
99
+ * logger.style('blue', 'dim', 'bold').toANSI('Hello Blue');
100
+ * logger.style('blue', 'dim', 'bold').toCSS('Hello Blue');
101
+ */
102
+ declare class LogStyler {
103
+ #private;
104
+ /**
105
+ * * Creates a new `LogStyler` instance.
106
+ *
107
+ * @param styles - Optional array of initial styles to apply (e.g., ['red', 'bold']). Defaults to an empty array.
108
+ *
109
+ * @example
110
+ * const styled = new LogStyler(['red', 'bold']);
111
+ * styled.log('Hello World');
112
+ *
113
+ * const logger = new LogStyler();
114
+ * logger.style('blue', 'dim', 'bold').log('Hello Blue');
115
+ * logger.style('blue', 'dim', 'bold').toANSI('Hello Blue');
116
+ * logger.style('blue', 'dim', 'bold').toCSS('Hello Blue');
117
+ */
118
+ constructor(styles?: Styles[]);
119
+ /**
120
+ * * Chain multiple styles to the input.
121
+ *
122
+ * @param style - One or more styles to apply (color, background, or text style).
123
+ * @returns A new StylogChain instance with the additional styles applied.
124
+ *
125
+ * @remarks
126
+ * - When chaining similar styles, only the last one(s) takes effect.
127
+ * - All colors applied through `style()` method are `truecolor` in form, to apply `ANSI-16` colors, use `ansi16()` method.
128
+ *
129
+ * @example
130
+ * // Single style
131
+ * Stylog.style('red').log('Red text');
132
+ * Stylog.style('red').toANSI('Red text');
133
+ * Stylog.style('red').toCSS('Red text');
134
+ *
135
+ * @example
136
+ * // Multiple styles at once
137
+ * Stylog.style('red', 'bold', 'underline').log('Red bold underlined text');
138
+ * Stylog.style('red', 'bold', 'underline').toANSI('Red bold underlined text');
139
+ * Stylog.style('red', 'bold', 'underline').toCSS('Red bold underlined text');
140
+ *
141
+ * @example
142
+ * // Mixed foreground and background
143
+ * Stylog.style('white', 'bgBlue').log('White text on blue background');
144
+ * Stylog.style('white', 'bgBlue').toANSI('White text on blue background');
145
+ * Stylog.style('white', 'bgBlue').toCSS('White text on blue background');
146
+ *
147
+ * @example
148
+ * // Building on existing styles
149
+ * const errorStyle = Stylog.style('red', 'bold');
150
+ * errorStyle.style('underline').log('Red bold underlined error');
151
+ * errorStyle.style('underline').toANSI('Red bold underlined error');
152
+ * errorStyle.style('underline').toCSS('Red bold underlined error');
153
+ */
154
+ style(...style: Styles[]): StylogChain;
155
+ /**
156
+ * * Apply ANSI 16-color styling to the text.
157
+ *
158
+ * @param color - ANSI 16-color name (e.g., 'red', 'cyanBright', 'bgRed').
159
+ * @returns A new `StylogChain` instance with the `ANSI 16-color` style applied.
160
+ *
161
+ * @remarks
162
+ * - Only one argument (color) can be passed on a single call.
163
+ * - Color applied through `ansi16()` method is `truecolor` in form, to apply `truecolor` colors, use `style()` method.
164
+ *
165
+ * @example
166
+ * // Basic usage
167
+ * Stylog.ansi16('red').log('Error message');
168
+ *
169
+ * @example
170
+ * // Chaining with other styles
171
+ * Stylog.ansi16('redBright').bold.italic.log('Bright red bold italic');
172
+ * Stylog.ansi16('redBright').bold.italic.toANSI('Bright red bold italic');
173
+ * Stylog.ansi16('redBright').bold.italic.toCSS('Bright red bold italic');
174
+ *
175
+ * @example
176
+ * // Background colors
177
+ * Stylog.ansi16('bgRed').log('Red background');
178
+ * Stylog.ansi16('bgRed').toANSI('Red background');
179
+ * Stylog.ansi16('bgRed').toCSS('Red background');
180
+ */
181
+ ansi16(color: Ansi16Color): StylogChain;
182
+ /**
183
+ * * Returns styled tuple `[format, cssList]` for Browser.
184
+ *
185
+ * @remarks
186
+ * - This method is specifically designed for browser environments and returns a tuple containing the formatted string with `%c` placeholder and an array of CSS styles (`string[]`).
187
+ * - Use this when you need direct access to the CSS styling for custom browser output.
188
+ * - If you want to format with ANSI escape codes, consider using {@link https://toolbox.nazmul-nhb.dev/docs/classes/LogStyler#toansiinput-stringify toANSI} method.
189
+ *
190
+ * @param input - Input to style before printing in the shell.
191
+ * @param stringify - Whether to apply `JSON.stringify()` before styling. Defaults to `false`.
192
+ * @returns Tuple `[format, cssList]` where:
193
+ * - `format`: String with `%c` placeholder for CSS styling
194
+ * - `cssList`: Array of CSS style strings
195
+ *
196
+ * @example
197
+ * // Basic usage in browser
198
+ * const styler = new LogStyler(['red', 'bold']);
199
+ * const [format, cssList] = styler.toCSS('Error message');
200
+ * // format: "%cError message"
201
+ * // cssList: ["color: #FF0000", "font-weight: bold"]
202
+ *
203
+ * @example
204
+ * // Custom browser output handling
205
+ * const styled = new LogStyler(['blue', 'bgYellow', 'italic']);
206
+ * const [format, styles] = styled.toCSS('Warning', true);
207
+ *
208
+ * // Use with custom logging function
209
+ * function customLog(formatted: string, styles: string[]) {
210
+ * const styleString = styles.join('; ');
211
+ * console.log(formatted, styleString);
212
+ * }
213
+ * customLog(format, styles);
214
+ *
215
+ * @example
216
+ * // With object stringification
217
+ * const dataOutput = new LogStyler(['green']).toCSS({ id: 123 }, true);
218
+ * // format: "%c{\"id\":123}"
219
+ * // cssList: ["color: #008000"]
220
+ */
221
+ toCSS(input: unknown, stringify?: boolean): [`%c${string}`, string[]];
222
+ /**
223
+ * * Returns the input as a styled string with ANSI escape codes.
224
+ *
225
+ * @remarks
226
+ * - This method returns ANSI-formatted strings suitable for environments that support ANSI escape codes (terminals, modern browser consoles, etc.).
227
+ * - For unsupported browsers, consider using the {@link https://toolbox.nazmul-nhb.dev/docs/classes/LogStyler#loginput-stringify log} method to print directly or {@link https://toolbox.nazmul-nhb.dev/docs/classes/LogStyler#tocssinput-stringify toCSS} to get styled tuple `[format, cssList]` for Browser.
228
+ *
229
+ * @param input - Input to style before printing in the shell.
230
+ * @param stringify - Whether to apply `JSON.stringify()` before styling. Defaults to `false`.
231
+ * @returns The styled string with ANSI escape codes.
232
+ *
233
+ * @example
234
+ * const styled = new LogStyler(['red', 'bold']);
235
+ * const errorMessage = styled.toANSI('Error occurred, using LogStyler');
236
+ * // Or with Stylog
237
+ * const errorMessage = Stylog.red.bold.toANSI('Error occurred, using Stylog');
238
+ * // Returns: "\x1b[31m\x1b[1mError occurred, using Stylog\xx1b[22m\x1b[39m"
239
+ *
240
+ * @example
241
+ * // Use in console (terminal or modern browser consoles)
242
+ * console.error(errorMessage);
243
+ * console.info(Stylog.red.bold.toANSI('I support ANSI!'));
244
+ */
245
+ toANSI(input: unknown, stringify?: boolean): string;
246
+ /**
247
+ * * Print styled input to the console.
248
+ *
249
+ * @param input Input to print to the shell/console.
250
+ * @param stringify Whether to apply `JSON.stringify()` before printing. Defaults to `false`.
251
+ */
252
+ log(input: unknown, stringify?: boolean): void;
253
+ /**
254
+ * * Apply a HEX color to the text foreground.
255
+ *
256
+ * @param code - HEX color string (e.g., `'#4682B4'` or `'4682B4'`).
257
+ * @returns A new `StylogChain` instance with the HEX color applied.
258
+ *
259
+ * @example
260
+ * // With hash prefix
261
+ * Stylog.hex('#4682B4').log('Steel blue text');
262
+ * Stylog.hex('#4682B4').toANSI('Steel blue text');
263
+ * Stylog.hex('#4682B4').toCSS('Steel blue text');
264
+ *
265
+ * @example
266
+ * // Without hash prefix
267
+ * Stylog.hex('4682B4').log('Steel blue text');
268
+ * Stylog.hex('4682B4').toANSI('Steel blue text');
269
+ * Stylog.hex('4682B4').toCSS('Steel blue text');
270
+ *
271
+ * @example
272
+ * // Chaining with other styles
273
+ * Stylog.hex('#FF0000').bold.log('Red bold text');
274
+ * Stylog.hex('#FF0000').bold.toANSI('Red bold text');
275
+ * Stylog.hex('#FF0000').bold.toCSS('Red bold text');
276
+ */
277
+ hex(code: string): StylogChain;
278
+ /**
279
+ * * Apply a HEX color to the text background.
280
+ *
281
+ * @param code - HEX color string (e.g., `'#4682B4'` or `'4682B4'`).
282
+ * @returns A new StylogChain instance with the HEX background color applied.
283
+ *
284
+ * @example
285
+ * // With hash prefix
286
+ * Stylog.bgHex('#4682B4').log('Steel blue background');
287
+ * Stylog.bgHex('#4682B4').toANSI('Steel blue background');
288
+ * Stylog.bgHex('#4682B4').toCSS('Steel blue background');
289
+ *
290
+ * @example
291
+ * // Without hash prefix
292
+ * Stylog.bgHex('4682B4').log('Steel blue background');
293
+ * Stylog.bgHex('4682B4').toANSI('Steel blue background');
294
+ * Stylog.bgHex('4682B4').toCSS('Steel blue background');
295
+ *
296
+ * @example
297
+ * // Chaining with foreground color
298
+ * Stylog.white.bgHex('#000000').log('White text on black background');
299
+ * Stylog.white.bgHex('#000000').toANSI('White text on black background');
300
+ * Stylog.white.bgHex('#000000').toCSS('White text on black background');
301
+ */
302
+ bgHex(code: string): StylogChain;
303
+ /**
304
+ * * Apply an RGB color to the text foreground using a CSS-like string.
305
+ *
306
+ * @param code - RGB color string (e.g., `'rgb(11, 45, 1)'` or `'11, 45, 1'`).
307
+ * @returns A new `StylogChain` instance with the RGB color applied.
308
+ *
309
+ * @example
310
+ * // Full rgb() syntax
311
+ * Stylog.rgb('rgb(11, 45, 1)').log('Dark green text');
312
+ * Stylog.rgb('rgb(11, 45, 1)').toANSI('Dark green text');
313
+ * Stylog.rgb('rgb(11, 45, 1)').toCSS('Dark green text');
314
+ *
315
+ * @example
316
+ * // Comma-separated values
317
+ * Stylog.rgb('11, 45, 1').log('Dark green text');
318
+ * Stylog.rgb('11, 45, 1').toANSI('Dark green text');
319
+ * Stylog.rgb('11, 45, 1').toCSS('Dark green text');
320
+ *
321
+ * @example
322
+ * // Chaining with other styles
323
+ * Stylog.rgb('255, 0, 0').bold.log('Red bold text');
324
+ * Stylog.rgb('255, 0, 0').bold.toANSI('Red bold text');
325
+ * Stylog.rgb('255, 0, 0').bold.toCSS('Red bold text');
326
+ */
327
+ rgb(code: string): StylogChain;
328
+ /**
329
+ * * Apply an RGB color to the text foreground using individual components.
330
+ *
331
+ * @param red - Red component (`0-255`).
332
+ * @param green - Green component (`0-255`).
333
+ * @param blue - Blue component (`0-255`).
334
+ * @returns A new `StylogChain` instance with the RGB color applied.
335
+ *
336
+ * @example
337
+ * // Individual components
338
+ * Stylog.rgb(255, 0, 0).log('Red text');
339
+ * Stylog.rgb(255, 0, 0).toANSI('Red text');
340
+ * Stylog.rgb(255, 0, 0).toCSS('Red text');
341
+ *
342
+ * @example
343
+ * // With other styles
344
+ * Stylog.rgb(0, 255, 0).underline.log('Green underlined text');
345
+ * Stylog.rgb(0, 255, 0).underline.toANSI('Green underlined text');
346
+ * Stylog.rgb(0, 255, 0).underline.toCSS('Green underlined text');
347
+ */
348
+ rgb(red: number, green: number, blue: number): StylogChain;
349
+ /**
350
+ * * Apply an RGB color to the text background using a CSS-like string.
351
+ *
352
+ * @param code - RGB color string (e.g., `'rgb(225, 169, 196)'` or `'225, 169, 196'`).
353
+ * @returns A new `StylogChain` instance with the RGB background color applied.
354
+ *
355
+ * @example
356
+ * // Full rgb() syntax
357
+ * Stylog.bgRGB('rgb(225, 169, 196)').log('Pink background');
358
+ * Stylog.bgRGB('rgb(225, 169, 196)').toANSI('Pink background');
359
+ * Stylog.bgRGB('rgb(225, 169, 196)').toCSS('Pink background');
360
+ *
361
+ * @example
362
+ * // Comma-separated values
363
+ * Stylog.bgRGB('225, 169, 196').log('Pink background');
364
+ * Stylog.bgRGB('225, 169, 196').toANSI('Pink background');
365
+ * Stylog.bgRGB('225, 169, 196').toCSS('Pink background');
366
+ *
367
+ * @example
368
+ * // With foreground color
369
+ * Stylog.black.bgRGB('255, 255, 255').log('Black text on white background');
370
+ * Stylog.black.bgRGB('255, 255, 255').toANSI('Black text on white background');
371
+ * Stylog.black.bgRGB('255, 255, 255').toCSS('Black text on white background');
372
+ */
373
+ bgRGB(code: string): StylogChain;
374
+ /**
375
+ * * Apply an RGB color to the text background using individual components.
376
+ *
377
+ * @param red - Red component (`0-255`).
378
+ * @param green - Green component (`0-255`).
379
+ * @param blue - Blue component (`0-255`).
380
+ * @returns A new `StylogChain` instance with the RGB background color applied.
381
+ *
382
+ * @example
383
+ * // Individual components
384
+ * Stylog.bgRGB(0, 0, 255).log('Blue background');
385
+ * Stylog.bgRGB(0, 0, 255).toANSI('Blue background');
386
+ * Stylog.bgRGB(0, 0, 255).toCSS('Blue background');
387
+ *
388
+ * @example
389
+ * // With text styles
390
+ * Stylog.bgRGB(255, 255, 0).bold.log('Bold text on yellow background');
391
+ * Stylog.bgRGB(255, 255, 0).bold.toANSI('Bold text on yellow background');
392
+ * Stylog.bgRGB(255, 255, 0).bold.toCSS('Bold text on yellow background');
393
+ */
394
+ bgRGB(red: number, green: number, blue: number): StylogChain;
395
+ /**
396
+ * * Apply an HSL color to the text foreground using a CSS-like string.
397
+ *
398
+ * @param code - HSL color string (e.g., `'hsl(50 80.5% 40%)'`).
399
+ * @returns A new `StylogChain` instance with the HSL color applied.
400
+ *
401
+ * @example
402
+ * // Standard HSL syntax
403
+ * Stylog.hsl('hsl(50 80.5% 40%)').log('Gold text');
404
+ * Stylog.hsl('hsl(50 80.5% 40%)').toANSI('Gold text');
405
+ * Stylog.hsl('hsl(50 80.5% 40%)').toCSS('Gold text');
406
+ *
407
+ * @example
408
+ * // With commas
409
+ * Stylog.hsl('50, 80.5%, 40%').log('Gold text');
410
+ * Stylog.hsl('50, 80.5%, 40%').toANSI('Gold text');
411
+ * Stylog.hsl('50, 80.5%, 40%').toCSS('Gold text');
412
+ *
413
+ * @example
414
+ * // Chaining with other styles
415
+ * Stylog.hsl('120, 100%, 50%').italic.log('Green italic text');
416
+ * Stylog.hsl('120, 100%, 50%').italic.toANSI('Green italic text');
417
+ * Stylog.hsl('120, 100%, 50%').italic.toCSS('Green italic text');
418
+ */
419
+ hsl(code: string): StylogChain;
420
+ /**
421
+ * * Apply an HSL color to the text foreground using individual components.
422
+ *
423
+ * @param hue - Hue component (`0-360`).
424
+ * @param saturation - Saturation component (`0-100`).
425
+ * @param lightness - Lightness component (`0-100`).
426
+ * @returns A new `StylogChain` instance with the HSL color applied.
427
+ *
428
+ * @example
429
+ * // Individual components
430
+ * Stylog.hsl(0, 100, 50).log('Red text');
431
+ * Stylog.hsl(0, 100, 50).toANSI('Red text');
432
+ * Stylog.hsl(0, 100, 50).toCSS('Red text');
433
+ *
434
+ * @example
435
+ * // With percentage values
436
+ * Stylog.hsl(240, 100, 50).log('Blue text');
437
+ * Stylog.hsl(240, 100, 50).toANSI('Blue text');
438
+ * Stylog.hsl(240, 100, 50).toCSS('Blue text');
439
+ */
440
+ hsl(hue: number, saturation: number, lightness: number): StylogChain;
441
+ /**
442
+ * * Apply an HSL color to the text background using a CSS-like string.
443
+ *
444
+ * @param code - HSL color string (e.g., `'hsl(50 80.5% 40%)'`).
445
+ * @returns A new `StylogChain` instance with the HSL background color applied.
446
+ *
447
+ * @example
448
+ * // Standard HSL syntax
449
+ * Stylog.bgHSL('hsl(50 80.5% 40%)').log('Gold background');
450
+ * Stylog.bgHSL('hsl(50 80.5% 40%)').toANSI('Gold background');
451
+ * Stylog.bgHSL('hsl(50 80.5% 40%)').toCSS('Gold background');
452
+ *
453
+ * @example
454
+ * // With commas
455
+ * Stylog.bgHSL('50, 80.5%, 40%').log('Gold background');
456
+ * Stylog.bgHSL('50, 80.5%, 40%').toANSI('Gold background');
457
+ * Stylog.bgHSL('50, 80.5%, 40%').toCSS('Gold background');
458
+ *
459
+ * @example
460
+ * // With foreground color
461
+ * Stylog.white.bgHSL('0, 100%, 50%').log('White text on red background');
462
+ * Stylog.white.bgHSL('0, 100%, 50%').toANSI('White text on red background');
463
+ * Stylog.white.bgHSL('0, 100%, 50%').toCSS('White text on red background');
464
+ */
465
+ bgHSL(code: string): StylogChain;
466
+ /**
467
+ * * Apply an HSL color to the text background using individual components.
468
+ *
469
+ * @param hue - Hue component (`0-360`).
470
+ * @param saturation - Saturation component (`0-100`).
471
+ * @param lightness - Lightness component (`0-100`).
472
+ * @returns A new StylogChain instance with the HSL background color applied.
473
+ *
474
+ * @example
475
+ * // Individual components
476
+ * Stylog.bgHSL(120, 100, 50).log('Green background');
477
+ * Stylog.bgHSL(120, 100, 50).toANSI('Green background');
478
+ * Stylog.bgHSL(120, 100, 50).toCSS('Green background');
479
+ *
480
+ * @example
481
+ * // With text styles
482
+ * Stylog.bgHSL(300, 100, 50).bold.log('Bold text on purple background');
483
+ * Stylog.bgHSL(300, 100, 50).bold.toANSI('Bold text on purple background');
484
+ * Stylog.bgHSL(300, 100, 50).bold.toCSS('Bold text on purple background');
485
+ */
486
+ bgHSL(hue: number, saturation: number, lightness: number): StylogChain;
487
+ }
488
+ /**
489
+ * * Styled console logger with chainable, type-safe color and text effects for both `Node.js` (`ANSI true-color`) and browsers (`CSS` via `%c`).
490
+ *
491
+ * @remarks
492
+ * - Chain any mix of foreground colors (e.g. `green`), background colors (e.g. `bgBlue`), and text styles (e.g. `bold`, `italic`, `underline`).
493
+ * - In browsers, styles are applied using `CSS`; in `Node.js`, `ANSI` escape codes are used.
494
+ * - When multiple styles of the same category are chained, the last one wins.
495
+ * - Use `.log(value, stringify?)` to print; set `stringify` to `true` to serialize with `JSON.stringify`.
496
+ * - If you need custom reusable style configurations, use {@link https://toolbox.nazmul-nhb.dev/docs/classes/LogStyler Stylog} class.
497
+ *
498
+ * @example
499
+ * // Simple color
500
+ * Stylog.green.log('Ready');
501
+ *
502
+ * @example
503
+ * // Foreground + background + effect, with JSON stringification
504
+ * Stylog.green.bgBlue.bold.log({ a: 121 }, true);
505
+ *
506
+ * @example
507
+ * // Reusable base chain
508
+ * const base = Stylog.underline;
509
+ * base.red.log('Error');
510
+ * base.error.log('Error');
511
+ * base.bgYellow.bold.log('Caution');
512
+ *
513
+ * @example
514
+ * // Works in the browser console too
515
+ * Stylog.cornflowerblue.italic.log('Hello from the browser');
516
+ */
517
+ declare const Stylog: StylogChain;
518
+ //#endregion
519
+ export { AnsiSequence as a, Styles as c, Ansi16Value as i, StylogChain as l, Stylog as n, BGColor as o, Ansi16Color as r, CSS16Color as s, LogStyler as t, TextStyle as u };
@@ -0,0 +1,130 @@
1
+ /**
2
+ * Copyright 2026 - present Nazmul Hassan
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { E as NestedPrimitiveKey, nt as NormalPrimitiveKey, y as GenericObject } from "./object-B0TV3eHx.mjs";
18
+
19
+ //#region src/types/array.d.ts
20
+ /** * Flatten Array or Wrap in Array */
21
+ type Flattened<T> = T extends (infer U)[] ? Flattened<U> : T;
22
+ /**
23
+ * * Configuration for `createOptionsArray`.
24
+ * - Defines the mapping between keys in the input objects and the keys in the output options.
25
+ *
26
+ * @typeParam T - The type of the objects in the input array.
27
+ * @typeParam K1 - The name of the key for the first field in the output (default: `'value'`).
28
+ * @typeParam K2 - The name of the key for the second field in the output (default: `'label'`).
29
+ * @typeParam V - Whether to keep the `value` field as number if it is a number. Defaults to `false`.
30
+ */
31
+ interface OptionsConfig<T, K1, K2, V extends boolean = false> {
32
+ /**
33
+ * - The key in the input objects to use for the first field of the option. Only primitive values (`string | number | boolean | null | undefined`) are accepted.
34
+ * @example
35
+ * // If the input objects have an `id` field and you want to use it as the `value` field in the output:
36
+ * createOptionsArray(data, {firstFieldKey: 'id'}).
37
+ */
38
+ firstFieldKey: NormalPrimitiveKey<T>;
39
+ /**
40
+ * - The key in the input objects to use for the second field of the option. Only primitive values (`string | number | boolean | null | undefined`) are accepted.
41
+ * @example
42
+ * // If the input objects have a `name` field and you want to use it as the `label` field in the output:
43
+ * createOptionsArray(data, {firstFieldKey: 'id', secondFieldKey: 'name'}).
44
+ */
45
+ secondFieldKey: NormalPrimitiveKey<T>;
46
+ /**
47
+ * - The name of the first field in the output object.
48
+ * - Defaults to `'value'`.
49
+ * @example
50
+ * // If you want the output field to be named `'key'` instead of `'value'`:
51
+ * createOptionsArray(data, {firstFieldKey: 'id', secondFieldKey: 'name', firstFieldName: 'key'}).
52
+ */
53
+ firstFieldName?: K1;
54
+ /**
55
+ * - The name of the second field in the output object.
56
+ * - Defaults to `'label'`.
57
+ * @example
58
+ * // If you want the output field to be named `'title'` instead of `'label'`:
59
+ * createOptionsArray(data, {firstFieldKey: 'id', secondFieldKey: 'name', firstFieldName: 'key', secondFieldName: 'title'}).
60
+ */
61
+ secondFieldName?: K2;
62
+ /**
63
+ * - If `true`, numeric values from `firstFieldKey` will remain as numbers.
64
+ * - All other values (including booleans, null, undefined) will be converted to strings.
65
+ * - When `false` (default), all values are converted to strings.
66
+ * - Defaults to `false`.
67
+ * @example
68
+ * // Numeric IDs remain as numbers
69
+ * createOptionsArray(data, {
70
+ * firstFieldKey: 'id',
71
+ * secondFieldKey: 'name',
72
+ * retainNumberValue: true
73
+ * });
74
+ *
75
+ * // All values become strings (default behavior)
76
+ * createOptionsArray(data, {
77
+ * firstFieldKey: 'id',
78
+ * secondFieldKey: 'name'
79
+ * });
80
+ */
81
+ retainNumberValue?: V;
82
+ }
83
+ /** Type for first field key */
84
+ type FirstFieldKey<T extends GenericObject, K1 extends string = 'value', K2 extends string = 'label', V extends boolean = false> = T[OptionsConfig<T, K1, K2, V>['firstFieldKey']];
85
+ /** Type for firs field value */
86
+ type FirstFieldValue<T extends GenericObject, K1 extends string = 'value', K2 extends string = 'label', V extends boolean = false> = V extends true ? FirstFieldKey<T, K1, K2, V> extends Exclude<FirstFieldKey<T, K1, K2, V>, number> ? string : number : string;
87
+ /** Type of values for the option fields */
88
+ type FieldValue<P extends K1 | K2, T extends GenericObject, K1 extends string = 'value', K2 extends string = 'label', V extends boolean = false> = P extends K1 ? FirstFieldValue<T, K1, K2, V> : string;
89
+ /** Type of an option in `OptionsArray` */
90
+ type Option<T extends GenericObject, K1 extends string = 'value', K2 extends string = 'label', V extends boolean = false> = { [P in K1 | K2]: FieldValue<P, T, K1, K2, V> };
91
+ /** * Option for sorting order. */
92
+ interface OrderOption {
93
+ /**
94
+ * * The order in which to sort the array. Defaults to `'asc'`.
95
+ * - `'asc'`: Sort in ascending order.
96
+ * - `'desc'`: Sort in descending order.
97
+ */
98
+ sortOrder?: 'asc' | 'desc';
99
+ }
100
+ /** * Options for setting sortByField for sorting an array of objects. */
101
+ interface SortByOption<T extends GenericObject> extends OrderOption {
102
+ /** The field by which to sort the objects in the array. */
103
+ sortByField: NestedPrimitiveKey<T>;
104
+ }
105
+ /** * Options for sorting array. */
106
+ type SortOptions<T> = T extends GenericObject ? SortByOption<T> : OrderOption;
107
+ /** Optional settings to configure comparison behavior. */
108
+ interface SortNature {
109
+ /** If true, compares string chunks without case sensitivity. Defaults to `true`. */
110
+ caseInsensitive?: boolean;
111
+ /** If true, uses localeCompare for string chunk comparisons. Defaults to `false`. */
112
+ localeAware?: boolean;
113
+ }
114
+ /** * Options for customizing the search behavior. */
115
+ interface FindOptions<T extends GenericObject = {}> {
116
+ /** * Enables fuzzy matching when exact match fails. Defaults to `false`. */
117
+ fuzzy?: boolean;
118
+ /** * Optional key for caching the result. Defaults to `finder-cache` */
119
+ cacheKey?: string;
120
+ /** * Forces binary search even for small datasets. Defaults to `false`. */
121
+ forceBinary?: boolean;
122
+ /** * If true, matcher and keys will be normalized to lowercase. Defaults to `true`. */
123
+ caseInsensitive?: boolean;
124
+ /** * If true, uses built in `Array.sort()`. Defaults to `true`. Pass `false` if data is already sorted. */
125
+ needSorting?: boolean;
126
+ /** * Optional data source to use instead of constructor items. */
127
+ data?: T[] | (() => T[]);
128
+ }
129
+ //#endregion
130
+ export { Flattened as a, OrderOption as c, SortOptions as d, FirstFieldValue as i, SortByOption as l, FindOptions as n, Option as o, FirstFieldKey as r, OptionsConfig as s, FieldValue as t, SortNature as u };