@rtorcato/js-common 2.8.1 → 3.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.
- package/AGENTS.md +116 -0
- package/CHANGELOG.md +30 -0
- package/CONTRIBUTORS.md +5 -0
- package/README.md +71 -22
- package/dist/abortController/index.d.ts +30 -0
- package/dist/abortController/index.d.ts.map +1 -1
- package/dist/arrays/arrays.test-d.d.ts +2 -0
- package/dist/arrays/arrays.test-d.d.ts.map +1 -0
- package/dist/arrays/arrays.test-d.js +1 -0
- package/dist/arrays/index.js +1 -1
- package/dist/boolean/index.d.ts +18 -6
- package/dist/boolean/index.d.ts.map +1 -1
- package/dist/boolean/index.js +1 -1
- package/dist/chunks/chunk-5IA77ERW.js +1 -0
- package/dist/chunks/chunk-7JQSIREC.js +1 -0
- package/dist/chunks/chunk-ARW46OJS.js +1 -0
- package/dist/chunks/chunk-MFJ5XPUX.js +1 -0
- package/dist/chunks/chunk-RBXTRLWB.js +1 -0
- package/dist/cli/catalog.js +131 -0
- package/dist/cli/cli.mjs +16 -109
- package/dist/colors/index.d.ts +23 -3
- package/dist/colors/index.d.ts.map +1 -1
- package/dist/console/index.d.ts +12 -0
- package/dist/console/index.d.ts.map +1 -1
- package/dist/crypto/index.d.ts +23 -0
- package/dist/crypto/index.d.ts.map +1 -1
- package/dist/currency/index.d.ts +0 -14
- package/dist/currency/index.d.ts.map +1 -1
- package/dist/currency/index.js +1 -1
- package/dist/date/index.d.ts +16 -0
- package/dist/date/index.d.ts.map +1 -1
- package/dist/datetime/index.d.ts +21 -9
- package/dist/datetime/index.d.ts.map +1 -1
- package/dist/datetime/index.js +1 -1
- package/dist/emails/index.d.ts +22 -0
- package/dist/emails/index.d.ts.map +1 -1
- package/dist/emails/index.js +1 -1
- package/dist/env/index.d.ts +24 -0
- package/dist/env/index.d.ts.map +1 -1
- package/dist/errors/index.d.ts +30 -2
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/events/index.d.ts +25 -1
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +1 -1
- package/dist/fetch/index.d.ts +25 -0
- package/dist/fetch/index.d.ts.map +1 -1
- package/dist/file/index.d.ts +20 -0
- package/dist/file/index.d.ts.map +1 -1
- package/dist/functions/functions.test-d.d.ts +2 -0
- package/dist/functions/functions.test-d.d.ts.map +1 -0
- package/dist/functions/functions.test-d.js +1 -0
- package/dist/functions/index.d.ts +32 -2
- package/dist/functions/index.d.ts.map +1 -1
- package/dist/functions/index.js +1 -1
- package/dist/geometry/index.d.ts +21 -0
- package/dist/geometry/index.d.ts.map +1 -1
- package/dist/html/index.d.ts +38 -0
- package/dist/html/index.d.ts.map +1 -1
- package/dist/html/index.js +1 -1
- package/dist/i18n/index.d.ts +23 -7
- package/dist/i18n/index.d.ts.map +1 -1
- package/dist/i18n/index.js +1 -1
- package/dist/interval/index.d.ts +15 -0
- package/dist/interval/index.d.ts.map +1 -1
- package/dist/json/index.d.ts +27 -0
- package/dist/json/index.d.ts.map +1 -1
- package/dist/logger/index.js +1 -1
- package/dist/logger/logger.d.ts +12 -2
- package/dist/logger/logger.d.ts.map +1 -1
- package/dist/logger/logger.js +1 -1
- package/dist/logging/index.d.ts +19 -0
- package/dist/logging/index.d.ts.map +1 -1
- package/dist/maps/index.d.ts +21 -0
- package/dist/maps/index.d.ts.map +1 -1
- package/dist/mime-types/index.d.ts +20 -0
- package/dist/mime-types/index.d.ts.map +1 -1
- package/dist/node/index.d.ts +0 -9
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +1 -1
- package/dist/numbers/index.d.ts +28 -12
- package/dist/numbers/index.d.ts.map +1 -1
- package/dist/numbers/index.js +1 -1
- package/dist/objects/index.d.ts +23 -0
- package/dist/objects/index.d.ts.map +1 -1
- package/dist/objects/index.js +1 -1
- package/dist/objects/objects.test-d.d.ts +2 -0
- package/dist/objects/objects.test-d.d.ts.map +1 -0
- package/dist/objects/objects.test-d.js +1 -0
- package/dist/os/index.d.ts +18 -0
- package/dist/os/index.d.ts.map +1 -1
- package/dist/process/index.d.ts +18 -0
- package/dist/process/index.d.ts.map +1 -1
- package/dist/promises/index.d.ts +29 -2
- package/dist/promises/index.d.ts.map +1 -1
- package/dist/promises/index.js +1 -1
- package/dist/promises/promises.test-d.d.ts +2 -0
- package/dist/promises/promises.test-d.d.ts.map +1 -0
- package/dist/promises/promises.test-d.js +1 -0
- package/dist/random/index.d.ts +21 -0
- package/dist/random/index.d.ts.map +1 -1
- package/dist/regex/index.d.ts +23 -0
- package/dist/regex/index.d.ts.map +1 -1
- package/dist/security/index.d.ts +36 -4
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/index.js +1 -1
- package/dist/sets/index.d.ts +19 -0
- package/dist/sets/index.d.ts.map +1 -1
- package/dist/sleep/index.d.ts +20 -0
- package/dist/sleep/index.d.ts.map +1 -1
- package/dist/strings/index.d.ts +0 -52
- package/dist/strings/index.d.ts.map +1 -1
- package/dist/strings/index.js +1 -1
- package/dist/system/index.d.ts +18 -0
- package/dist/system/index.d.ts.map +1 -1
- package/dist/time/index.d.ts +23 -4
- package/dist/time/index.d.ts.map +1 -1
- package/dist/try/trycatch.d.ts +24 -0
- package/dist/try/trycatch.d.ts.map +1 -1
- package/dist/try/trycatch.test-d.d.ts +2 -0
- package/dist/try/trycatch.test-d.d.ts.map +1 -0
- package/dist/try/trycatch.test-d.js +1 -0
- package/dist/types/index.d.ts +0 -1
- package/dist/url/index.d.ts +23 -0
- package/dist/url/index.d.ts.map +1 -1
- package/dist/url/index.js +1 -1
- package/dist/uuid/index.d.ts +10 -0
- package/dist/uuid/index.d.ts.map +1 -1
- package/dist/validation/index.d.ts +25 -0
- package/dist/validation/index.d.ts.map +1 -1
- package/dist/validation/index.js +1 -1
- package/package.json +25 -23
- package/dist/chunks/chunk-6J7HIWG6.js +0 -1
- package/dist/formatting/index.d.ts +0 -40
- package/dist/formatting/index.d.ts.map +0 -1
- package/dist/formatting/index.js +0 -1
- package/dist/math/index.d.ts +0 -37
- package/dist/math/index.d.ts.map +0 -1
- package/dist/math/index.js +0 -1
- package/dist/try/attempt.d.ts +0 -8
- package/dist/try/attempt.d.ts.map +0 -1
- package/dist/try/attempt.js +0 -1
package/dist/strings/index.d.ts
CHANGED
|
@@ -95,13 +95,6 @@ export declare function padStart(str: string, targetLength: number, padString?:
|
|
|
95
95
|
* @returns The padded string.
|
|
96
96
|
*/
|
|
97
97
|
export declare function padEnd(str: string, targetLength: number, padString?: string): string;
|
|
98
|
-
/**
|
|
99
|
-
* get a random string
|
|
100
|
-
* var rStr= randomString(32,'0123456789abcdefghijklmn');
|
|
101
|
-
* @param {number} length
|
|
102
|
-
* @param {string} chars
|
|
103
|
-
*/
|
|
104
|
-
export declare const randomString: (length: number, chars: string) => string;
|
|
105
98
|
/**
|
|
106
99
|
* replace all items in a string using regex
|
|
107
100
|
* @param {string} str
|
|
@@ -109,12 +102,6 @@ export declare const randomString: (length: number, chars: string) => string;
|
|
|
109
102
|
* @param {string} replacement
|
|
110
103
|
*/
|
|
111
104
|
export declare const replaceString: (str: string, search: string, replacement: string) => string;
|
|
112
|
-
/**
|
|
113
|
-
* Sanitizes a string by removing script tags and event handlers.
|
|
114
|
-
* @param str The string to sanitize.
|
|
115
|
-
* @returns The sanitized string.
|
|
116
|
-
*/
|
|
117
|
-
export declare function sanitizeString(str: string): string;
|
|
118
105
|
/**
|
|
119
106
|
* Reverses a string.
|
|
120
107
|
*
|
|
@@ -171,45 +158,6 @@ export declare function words(str: string): string[];
|
|
|
171
158
|
* @returns The word count
|
|
172
159
|
*/
|
|
173
160
|
export declare function wordCount(str: string): number;
|
|
174
|
-
/**
|
|
175
|
-
* Escapes HTML special characters to prevent XSS.
|
|
176
|
-
*
|
|
177
|
-
* @example
|
|
178
|
-
* ```typescript
|
|
179
|
-
* escapeHtml('<div>Hello & "World"</div>') // '<div>Hello & "World"</div>'
|
|
180
|
-
* escapeHtml("It's <script>") // "It's <script>"
|
|
181
|
-
* ```
|
|
182
|
-
*
|
|
183
|
-
* @param str The string to escape
|
|
184
|
-
* @returns The escaped string
|
|
185
|
-
*/
|
|
186
|
-
export declare function escapeHtml(str: string): string;
|
|
187
|
-
/**
|
|
188
|
-
* Unescapes HTML entities back to their original characters.
|
|
189
|
-
*
|
|
190
|
-
* @example
|
|
191
|
-
* ```typescript
|
|
192
|
-
* unescapeHtml('<div>') // '<div>'
|
|
193
|
-
* unescapeHtml('&"'') // '&"''
|
|
194
|
-
* ```
|
|
195
|
-
*
|
|
196
|
-
* @param str The string to unescape
|
|
197
|
-
* @returns The unescaped string
|
|
198
|
-
*/
|
|
199
|
-
export declare function unescapeHtml(str: string): string;
|
|
200
|
-
/**
|
|
201
|
-
* Removes all HTML tags from a string.
|
|
202
|
-
*
|
|
203
|
-
* @example
|
|
204
|
-
* ```typescript
|
|
205
|
-
* stripHtml('<p>Hello <b>World</b></p>') // 'Hello World'
|
|
206
|
-
* stripHtml('<script>alert(1)</script>Text') // 'Text'
|
|
207
|
-
* ```
|
|
208
|
-
*
|
|
209
|
-
* @param str The string to strip HTML from
|
|
210
|
-
* @returns The string without HTML tags
|
|
211
|
-
*/
|
|
212
|
-
export declare function stripHtml(str: string): string;
|
|
213
161
|
/**
|
|
214
162
|
* Returns the plural form of a word based on count.
|
|
215
163
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/strings/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAI7C;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK7C;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK7C;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAE/D;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,SAAM,GAAG,MAAM,CAEnF;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,SAAM,GAAG,MAAM,CAEjF;AAED;;;;;GAKG;AACH,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/strings/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAI7C;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK7C;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK7C;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAE/D;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,SAAM,GAAG,MAAM,CAEnF;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,SAAM,GAAG,MAAM,CAEjF;AAED;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,KAAK,MAAM,EAAE,QAAQ,MAAM,EAAE,aAAa,MAAM,KAAG,MAEhF,CAAA;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE3C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAU3C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAO3C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAI7C;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAG9E;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAmB9C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAE5C;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,SAAM,GAAG,MAAM,CAOhF;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAI3E"}
|
package/dist/strings/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../chunks/chunk-ANN5UYCF.js";function s(r){return r.replace(/\w\S*/g,
|
|
1
|
+
import"../chunks/chunk-ANN5UYCF.js";function s(r){return r.replace(/\w\S*/g,e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase())}function o(r){return r.length===0?"":(r[0]?.toUpperCase()??"")+r.slice(1)}function g(r){return r.replace(/[-_\s]+(.)?/g,(e,t)=>t?t.toUpperCase():"").replace(/^(.)/,e=>e.toLowerCase())}function a(r){return r.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[_\s]+/g,"-").toLowerCase()}function c(r){return r.replace(/([a-z])([A-Z])/g,"$1_$2").replace(/[-\s]+/g,"_").toLowerCase()}function u(r,e){return r.length>e?`${r.slice(0,e-1)}\u2026`:r}function p(r,e,t=" "){return r.padStart(e,t)}function l(r,e,t=" "){return r.padEnd(e,t)}var f=(r,e,t)=>r.replace(new RegExp(e,"g"),t);function x(r){return[...r].reverse().join("")}function $(r){return r.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim().replace(/[^a-z0-9\s-]/g,"").replace(/[\s_]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function b(r){return r.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[-_]+/g," ").trim().split(/\s+/).filter(Boolean)}function m(r){let e=r.trim();return e===""?0:e.split(/\s+/).length}function w(r,e,t){return e===1?r:t??`${r}s`}function C(r){let e=Math.abs(r),t=e%100,n=e%10;if(t>=11&&t<=13)return`${r}th`;switch(n){case 1:return`${r}st`;case 2:return`${r}nd`;case 3:return`${r}rd`;default:return`${r}th`}}function h(r){return r.trim().length===0}function d(r,e,t,n="*"){if(e<0&&(e=0),t>r.length&&(t=r.length),e>=t)return r;let i=n.repeat(t-e);return r.slice(0,e)+i+r.slice(t)}function z(r,e){return r.replace(/\$\{(\w+)\}/g,(t,n)=>Object.hasOwn(e,n)?String(e[n]):t)}export{g as camelCase,o as capitalize,h as isBlank,a as kebabCase,d as mask,C as ordinalize,l as padEnd,p as padStart,w as pluralize,f as replaceString,x as reverse,$ as slugify,c as snakeCase,z as template,s as titleCase,u as truncate,m as wordCount,b as words};
|
package/dist/system/index.d.ts
CHANGED
|
@@ -1,15 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Checks if the current OS is macOS.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* isMacOs() // true on macOS (via process.platform in Node, userAgent in the browser)
|
|
7
|
+
* ```
|
|
8
|
+
*
|
|
3
9
|
* @returns {boolean} True if macOS, false otherwise.
|
|
4
10
|
*/
|
|
5
11
|
export declare function isMacOs(): boolean;
|
|
6
12
|
/**
|
|
7
13
|
* Checks if the current OS is Windows.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* isWindows() // true when process.platform === 'win32'
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
8
20
|
* @returns {boolean} True if Windows, false otherwise.
|
|
9
21
|
*/
|
|
10
22
|
export declare function isWindows(): boolean;
|
|
11
23
|
/**
|
|
12
24
|
* Checks if the current OS is Linux.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* isLinux() // true when process.platform === 'linux'
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
13
31
|
* @returns {boolean} True if Linux, false otherwise.
|
|
14
32
|
*/
|
|
15
33
|
export declare function isLinux(): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/system/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/system/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,OAAO,IAAI,OAAO,CAQjC;AAED;;;;;;;;;GASG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAQnC;AAED;;;;;;;;;GASG;AACH,wBAAgB,OAAO,IAAI,OAAO,CAQjC;AAED;;;GAGG;AACH,wBAAgB,KAAK,IAAI,OAAO,CAK/B;AAED;;;GAGG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAKnC;AAED;;;GAGG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAOpC;AAED;;;GAGG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAMvC"}
|
package/dist/time/index.d.ts
CHANGED
|
@@ -1,16 +1,35 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Returns the current time as HH:MM:SS string.
|
|
2
|
+
* Returns the current time as an `HH:MM:SS` string.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* nowTime() // '14:03:27'
|
|
7
|
+
* ```
|
|
8
|
+
*
|
|
3
9
|
* @returns {string}
|
|
4
10
|
*/
|
|
5
11
|
export declare function nowTime(): string;
|
|
6
12
|
/**
|
|
7
|
-
* Parses a time string (HH:MM or HH:MM:SS) into a Date object (today's date).
|
|
13
|
+
* Parses a time string (`HH:MM` or `HH:MM:SS`) into a Date object (today's date).
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* parseTime('09:30').getHours() // 9
|
|
18
|
+
* parseTime('09:30:15').getSeconds() // 15
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
8
21
|
* @param timeStr The time string.
|
|
9
22
|
* @returns {Date}
|
|
10
23
|
*/
|
|
11
24
|
export declare function parseTime(timeStr: string): Date;
|
|
12
25
|
/**
|
|
13
|
-
* Formats a Date object as HH:MM:SS
|
|
26
|
+
* Formats a Date object as `HH:MM:SS`.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* formatTime(new Date(2026, 7, 11, 9, 5, 3)) // '09:05:03'
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
14
33
|
* @param date The Date object.
|
|
15
34
|
* @returns {string}
|
|
16
35
|
*/
|
|
@@ -23,7 +42,7 @@ export declare function formatTime(date: Date): string;
|
|
|
23
42
|
*/
|
|
24
43
|
export declare function secondsBetween(t1: string | Date, t2: string | Date): number;
|
|
25
44
|
/**
|
|
26
|
-
* Pads a number to two digits (e.g
|
|
45
|
+
* Pads a number to two digits (e.g. `5` → `'05'`).
|
|
27
46
|
* @param n The number.
|
|
28
47
|
* @returns {string}
|
|
29
48
|
*/
|
package/dist/time/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/time/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/time/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,OAAO,IAAI,MAAM,CAGhC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAK/C;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAE7C;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAI3E;AAED;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAEtC;AAED;;;GAGG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAGrC"}
|
package/dist/try/trycatch.d.ts
CHANGED
|
@@ -15,15 +15,39 @@ export type Failure<E> = {
|
|
|
15
15
|
/**
|
|
16
16
|
* Go-style discriminated union representing either a `Success<T>` or a `Failure<E>`,
|
|
17
17
|
* for async code that prefers explicit error returns over thrown exceptions.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const ok: Result<number> = { data: 42, error: null }
|
|
22
|
+
* const bad: Result<number> = { data: null, error: new Error('boom') }
|
|
23
|
+
* ```
|
|
18
24
|
*/
|
|
19
25
|
export type Result<T, E = Error> = Success<T> | Failure<E>;
|
|
20
26
|
/**
|
|
21
27
|
* Type guard that narrows a `Result` to its `Success` branch when the error is `null`.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* const result = await tryCatch(async () => 42)
|
|
32
|
+
* if (isSuccess(result)) {
|
|
33
|
+
* result.data // 42, narrowed to number
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
22
36
|
*/
|
|
23
37
|
export declare function isSuccess<T, E>(result: Result<T, E>): result is Success<T>;
|
|
24
38
|
/**
|
|
25
39
|
* Run an async function and capture any thrown error into a `Result`, eliminating
|
|
26
40
|
* try/catch at the call site.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* const { data, error } = await tryCatch(() => fetch('/api/user').then((r) => r.json()))
|
|
45
|
+
* // success: { data: { id: 1 }, error: null }
|
|
46
|
+
* // failure: { data: null, error: Error }
|
|
47
|
+
*
|
|
48
|
+
* if (error) return console.error(error)
|
|
49
|
+
* console.log(data.id)
|
|
50
|
+
* ```
|
|
27
51
|
*/
|
|
28
52
|
export declare function tryCatch<T, E = Error>(fn: () => Promise<T>): Promise<Result<T, E>>;
|
|
29
53
|
//# sourceMappingURL=trycatch.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trycatch.d.ts","sourceRoot":"","sources":["../../src/try/trycatch.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI;IAAE,IAAI,EAAE,CAAC,CAAC;IAAC,KAAK,EAAE,IAAI,CAAA;CAAE,CAAA;AAEjD;;GAEG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,CAAA;AAEjD
|
|
1
|
+
{"version":3,"file":"trycatch.d.ts","sourceRoot":"","sources":["../../src/try/trycatch.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI;IAAE,IAAI,EAAE,CAAC,CAAC;IAAC,KAAK,EAAE,IAAI,CAAA;CAAE,CAAA;AAEjD;;GAEG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,CAAA;AAEjD;;;;;;;;;GASG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;AAE1D;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,CAE1E;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,QAAQ,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAOxF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trycatch.test-d.d.ts","sourceRoot":"","sources":["../../src/try/trycatch.test-d.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as u,b as t}from"../chunks/chunk-XAQ7VMV4.js";import"../chunks/chunk-ANN5UYCF.js";import{describe as l,expectTypeOf as e,it as s}from"vitest";l("try \u2014 types",()=>{s("Result<T,E> is the union of Success<T> and Failure<E>",()=>{e().toEqualTypeOf(),e().toEqualTypeOf()}),s("isSuccess narrows Result to Success in the true branch",()=>{let r={data:1,error:null};u(r)?(e(r).toEqualTypeOf(),e(r.data).toEqualTypeOf(),e(r.error).toEqualTypeOf()):e(r).toEqualTypeOf()}),s("tryCatch returns Promise<Result<T, E>> with the resolved type",async()=>{let r=t(async()=>42);e(r).toEqualTypeOf();let o=t(async()=>"x");e(o).toEqualTypeOf()})});
|
package/dist/types/index.d.ts
CHANGED
package/dist/url/index.d.ts
CHANGED
|
@@ -1,17 +1,40 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Checks if a string is a valid URL.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* isValidUrl('https://example.com/a?b=1') // true
|
|
7
|
+
* isValidUrl('example.com') // false (no protocol)
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
3
10
|
* @param str The string to check.
|
|
4
11
|
* @returns True if valid URL, false otherwise.
|
|
5
12
|
*/
|
|
6
13
|
export declare function isValidUrl(str: string): boolean;
|
|
7
14
|
/**
|
|
8
15
|
* Gets the query parameters from a URL as an object.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* getQueryParams('https://example.com/s?q=cats&page=2') // { q: 'cats', page: '2' }
|
|
20
|
+
* getQueryParams('not a url') // {}
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
9
23
|
* @param url The URL string.
|
|
10
24
|
* @returns An object of query parameters.
|
|
11
25
|
*/
|
|
12
26
|
export declare function getQueryParams(url: string): Record<string, string>;
|
|
13
27
|
/**
|
|
14
28
|
* Adds or updates a query parameter in a URL.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* setQueryParam('https://example.com/s?q=cats', 'page', '2')
|
|
33
|
+
* // 'https://example.com/s?q=cats&page=2'
|
|
34
|
+
* setQueryParam('https://example.com/s?q=cats', 'q', 'dogs')
|
|
35
|
+
* // 'https://example.com/s?q=dogs'
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
15
38
|
* @param url The URL string.
|
|
16
39
|
* @param key The query parameter key.
|
|
17
40
|
* @param value The query parameter value.
|
package/dist/url/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/url/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/url/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAO/C;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAWlE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAQ7E;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAQjE;AAgBD;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAKlD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAM/C"}
|
package/dist/url/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../chunks/chunk-ANN5UYCF.js";function
|
|
1
|
+
import"../chunks/chunk-ANN5UYCF.js";function o(r){try{return new URL(r),!0}catch{return!1}}function a(r){try{let e=new URL(r).searchParams,t={};return e.forEach((n,s)=>{t[s]=n}),t}catch{return{}}}function c(r,e,t){try{let n=new URL(r);return n.searchParams.set(e,t),n.toString()}catch{return r}}function g(r,e){try{let t=new URL(r);return t.searchParams.delete(e),t.toString()}catch{return r}}function i(r,e){let t=0,n=r.length;if(e)for(;t<n&&r[t]==="/";)t++;for(;n>t&&r[n-1]==="/";)n--;return r.slice(t,n)}function u(...r){return r.map((e,t)=>i(e,t>0)).filter(Boolean).join("/")}function l(r){try{return new URL(r).hostname}catch{return""}}export{l as getHostname,a as getQueryParams,o as isValidUrl,u as joinUrl,g as removeQueryParam,c as setQueryParam};
|
package/dist/uuid/index.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Generates a UUID v4 string.
|
|
3
3
|
* @returns {string} A new UUID v4 string.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* getUUID() // 'f47ac10b-58cc-4372-a567-0e02b2c3d479'
|
|
8
|
+
* ```
|
|
4
9
|
*/
|
|
5
10
|
export declare const getUUID: () => string;
|
|
6
11
|
/**
|
|
@@ -17,6 +22,11 @@ export declare const getUUIDv7: () => string;
|
|
|
17
22
|
/**
|
|
18
23
|
* Generates a short UUID string using short-uuid.
|
|
19
24
|
* @returns {string} A new short UUID string.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* getShortUUID() // 'mhvXdrZT4jP5T8vBxuvm75'
|
|
29
|
+
* ```
|
|
20
30
|
*/
|
|
21
31
|
export declare const getShortUUID: () => string;
|
|
22
32
|
/**
|
package/dist/uuid/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/uuid/index.ts"],"names":[],"mappings":"AAaA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/uuid/index.ts"],"names":[],"mappings":"AAaA;;;;;;;;GAQG;AACH,eAAO,MAAM,OAAO,QAAO,MAE1B,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,SAAS,QAAO,MAE5B,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,QAAO,MAE/B,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,WAAW,GAAI,MAAM,MAAM,KAAG,MAE1C,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,KAAG,MAE7C,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,MAAM,GAAI,IAAI,MAAM,KAAG,OAA2B,CAAA;AAE/D;;;;GAIG;AACH,eAAO,MAAM,QAAQ,GAAI,IAAI,MAAM,KAAG,OAAoD,CAAA;AAE1F;;;;;;;;;;GAUG;AACH,eAAO,MAAM,SAAS,GAAI,IAAI,MAAM,KAAG,OAA0B,CAAA;AAEjE;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,cAAc,GAAI,IAAI,MAAM,KAAG,MAK3C,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,UAAU,QAAO,MAAkB,CAAA;AAEhD;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,IAAI,MAAM,KAAG,UAA2B,CAAA;AAEpE;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,UAAU,KAAG,MAA8B,CAAA"}
|
|
@@ -1,17 +1,42 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Checks if a value is defined (not null or undefined).
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* isDefined(0) // true
|
|
7
|
+
* isDefined('') // true
|
|
8
|
+
* isDefined(null) // false
|
|
9
|
+
* isDefined(undefined) // false
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
3
12
|
* @param value The value to check.
|
|
4
13
|
* @returns {boolean}
|
|
5
14
|
*/
|
|
6
15
|
export declare function isDefined<T>(value: T | null | undefined): value is T;
|
|
7
16
|
/**
|
|
8
17
|
* Check if a value is a string.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* isString('hi') // true
|
|
22
|
+
* isString(42) // false
|
|
23
|
+
* isString(new String('hi')) // false (boxed, not a primitive)
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
9
26
|
* @param value - The value to check.
|
|
10
27
|
* @returns `true` if the value is a string, `false` otherwise.
|
|
11
28
|
*/
|
|
12
29
|
export declare function isString(value: unknown): value is string;
|
|
13
30
|
/**
|
|
14
31
|
* Checks if a value is a number (and not NaN).
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* isNumber(42) // true
|
|
36
|
+
* isNumber(Number.NaN) // false
|
|
37
|
+
* isNumber('42') // false
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
15
40
|
* @param value The value to check.
|
|
16
41
|
* @returns {boolean}
|
|
17
42
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validation/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validation/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,GAAG,SAAS,GAAG,KAAK,IAAI,CAAC,CAEpE;AAED;;;;;;;;;;;;GAYG;AAEH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAExD;AAED;;;;;;;;;;;;GAYG;AAEH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAExD;AAED;;;;GAIG;AAEH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,CAE1D;AAED;;;;GAIG;AAEH,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,EAAE,CAE1D;AAED;;;;GAIG;AAEH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAExD;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAI5C;AAED;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAO1C"}
|
package/dist/validation/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../chunks/chunk-ANN5UYCF.js";function r(n){return n!=null}function e(n){return typeof n=="string"}function t(n){return typeof n=="number"&&!Number.isNaN(n)}function o(n){return typeof n=="boolean"}function u(n){return Array.isArray(n)}function i(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function s(n){return/^[^\s@]+@[^\s
|
|
1
|
+
import"../chunks/chunk-ANN5UYCF.js";function r(n){return n!=null}function e(n){return typeof n=="string"}function t(n){return typeof n=="number"&&!Number.isNaN(n)}function o(n){return typeof n=="boolean"}function u(n){return Array.isArray(n)}function i(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function s(n){return/^[^\s@]+@[^\s@.]+(?:\.[^\s@.]+)+$/.test(n)}function a(n){try{return new URL(n),!0}catch{return!1}}export{u as isArray,o as isBoolean,r as isDefined,s as isEmail,t as isNumber,i as isObject,e as isString,a as isUrl};
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rtorcato/js-common",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "JavaScript and TypeScript common code",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"packageManager": "pnpm@11.17.0",
|
|
6
7
|
"main": "dist/index.js",
|
|
7
8
|
"module": "dist/index.js",
|
|
8
9
|
"types": "dist/index.d.ts",
|
|
@@ -40,12 +41,17 @@
|
|
|
40
41
|
"test": "vitest",
|
|
41
42
|
"test:watch": "vitest --watch",
|
|
42
43
|
"coverage": "vitest run --coverage",
|
|
44
|
+
"size": "size-limit",
|
|
43
45
|
"benchmark": "node scripts/benchmark.mjs",
|
|
44
46
|
"docs:generate": "node scripts/generate-module-docs.mjs",
|
|
47
|
+
"sync:agents": "node scripts/sync-agents.mjs",
|
|
48
|
+
"check:readme": "node scripts/check-readme-exports.mjs --check",
|
|
45
49
|
"commit": "cz",
|
|
50
|
+
"verify": "pnpm typecheck && pnpm check && pnpm exec vitest run",
|
|
46
51
|
"================================================": ""
|
|
47
52
|
},
|
|
48
53
|
"files": [
|
|
54
|
+
"AGENTS.md",
|
|
49
55
|
"CHANGELOG.md",
|
|
50
56
|
"CONTRIBUTORS.md",
|
|
51
57
|
"dist",
|
|
@@ -117,10 +123,6 @@
|
|
|
117
123
|
"import": "./dist/file/index.js",
|
|
118
124
|
"types": "./dist/file/index.d.ts"
|
|
119
125
|
},
|
|
120
|
-
"./formatting": {
|
|
121
|
-
"import": "./dist/formatting/index.js",
|
|
122
|
-
"types": "./dist/formatting/index.d.ts"
|
|
123
|
-
},
|
|
124
126
|
"./functions": {
|
|
125
127
|
"import": "./dist/functions/index.js",
|
|
126
128
|
"types": "./dist/functions/index.d.ts"
|
|
@@ -157,10 +159,6 @@
|
|
|
157
159
|
"import": "./dist/maps/index.js",
|
|
158
160
|
"types": "./dist/maps/index.d.ts"
|
|
159
161
|
},
|
|
160
|
-
"./math": {
|
|
161
|
-
"import": "./dist/math/index.js",
|
|
162
|
-
"types": "./dist/math/index.d.ts"
|
|
163
|
-
},
|
|
164
162
|
"./mime-types": {
|
|
165
163
|
"import": "./dist/mime-types/index.js",
|
|
166
164
|
"types": "./dist/mime-types/index.d.ts"
|
|
@@ -242,28 +240,31 @@
|
|
|
242
240
|
}
|
|
243
241
|
},
|
|
244
242
|
"devDependencies": {
|
|
245
|
-
"@biomejs/biome": "^2.
|
|
246
|
-
"@commitlint/cli": "^
|
|
247
|
-
"@commitlint/config-conventional": "^
|
|
248
|
-
"@rtorcato/
|
|
249
|
-
"@semantic-release/changelog": "^
|
|
243
|
+
"@biomejs/biome": "^2.5.0",
|
|
244
|
+
"@commitlint/cli": "^21.2.1",
|
|
245
|
+
"@commitlint/config-conventional": "^21.2.0",
|
|
246
|
+
"@rtorcato/repo-tooling": "^3.9.1",
|
|
247
|
+
"@semantic-release/changelog": "^7.0.0",
|
|
250
248
|
"@semantic-release/commit-analyzer": "^13.0.1",
|
|
251
|
-
"@semantic-release/git": "^
|
|
249
|
+
"@semantic-release/git": "^11.0.1",
|
|
252
250
|
"@semantic-release/github": "^12.0.0",
|
|
253
251
|
"@semantic-release/npm": "^13.1.1",
|
|
254
252
|
"@semantic-release/release-notes-generator": "^14.1.0",
|
|
253
|
+
"@size-limit/preset-small-lib": "^13.0.3",
|
|
255
254
|
"@types/chalk-animation": "^1.6.3",
|
|
256
255
|
"@types/figlet": "^1.7.0",
|
|
257
256
|
"@types/luxon": "^3.7.1",
|
|
258
|
-
"@types/node": "^
|
|
259
|
-
"@vitest/coverage-
|
|
257
|
+
"@types/node": "^26.1.2",
|
|
258
|
+
"@vitest/coverage-v8": "^4.0.17",
|
|
260
259
|
"cross-env": "^10.1.0",
|
|
261
|
-
"esbuild": "^0.
|
|
260
|
+
"esbuild": "^0.28.1",
|
|
261
|
+
"fast-check": "^4.8.0",
|
|
262
262
|
"husky": "^9.1.7",
|
|
263
|
-
"jsdom": "^
|
|
263
|
+
"jsdom": "^30.0.1",
|
|
264
264
|
"knip": "^6.14.2",
|
|
265
265
|
"rimraf": "^6.0.1",
|
|
266
266
|
"semantic-release": "^25.0.1",
|
|
267
|
+
"size-limit": "^13.0.3",
|
|
267
268
|
"typescript": "^6.0.2",
|
|
268
269
|
"vitest": "^4.0.17"
|
|
269
270
|
},
|
|
@@ -273,16 +274,17 @@
|
|
|
273
274
|
"luxon": "^3.7.2",
|
|
274
275
|
"pino": "^10.1.0",
|
|
275
276
|
"short-uuid": "^6.0.3",
|
|
276
|
-
"uuid": "^
|
|
277
|
+
"uuid": "^14.0.1",
|
|
277
278
|
"zod": "^4.1.12"
|
|
278
279
|
},
|
|
279
280
|
"optionalDependencies": {
|
|
280
281
|
"@inquirer/prompts": "^8.5.0",
|
|
281
|
-
"chalk": "^
|
|
282
|
+
"chalk": "^6.0.0",
|
|
282
283
|
"chalk-animation": "^2.0.3",
|
|
283
|
-
"commander": "^
|
|
284
|
+
"commander": "^15.0.0",
|
|
284
285
|
"figlet": "^1.9.3",
|
|
285
|
-
"gradient-string": "^3.0.0"
|
|
286
|
+
"gradient-string": "^3.0.0",
|
|
287
|
+
"pino-pretty": "^13.0.0"
|
|
286
288
|
},
|
|
287
289
|
"config": {
|
|
288
290
|
"commitizen": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as e}from"./chunk-FBDKWWIQ.js";import o from"pino";var i=e()?o({level:"debug",transport:{target:"pino-pretty",options:{colorize:!0,ignore:"pid,hostname,time",levelFirst:!1,singleLine:!0,customColors:"err:red,info:blue",translateTime:"HH:MM:ss"}}}):o({level:"info"});export{i as a};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pads a string or number with leading zeros to a given length.
|
|
3
|
-
* @param value The value to pad.
|
|
4
|
-
* @param length The desired length.
|
|
5
|
-
* @returns The padded string.
|
|
6
|
-
*/
|
|
7
|
-
export declare function padZero(value: string | number, length?: number): string;
|
|
8
|
-
/**
|
|
9
|
-
* Formats a number with thousands separators.
|
|
10
|
-
* @param num The number to format.
|
|
11
|
-
* @param locale Optional locale string (default: 'en-US').
|
|
12
|
-
* @returns The formatted string.
|
|
13
|
-
*/
|
|
14
|
-
export declare function formatNumber(num: number, locale?: string): string;
|
|
15
|
-
/**
|
|
16
|
-
* Formats a number as a percentage string.
|
|
17
|
-
* @param value The value to format (e.g. 0.25 for 25%).
|
|
18
|
-
* @param fractionDigits Number of decimal places (default: 0).
|
|
19
|
-
* @returns The formatted percentage string.
|
|
20
|
-
*/
|
|
21
|
-
export declare function formatPercent(value: number, fractionDigits?: number): string;
|
|
22
|
-
/**
|
|
23
|
-
* Formats a Date as YYYY-MM-DD.
|
|
24
|
-
* @param date The date to format.
|
|
25
|
-
* @returns The formatted date string.
|
|
26
|
-
*/
|
|
27
|
-
export declare function formatDate(date: Date): string;
|
|
28
|
-
/**
|
|
29
|
-
* Formats a Date as HH:MM:SS.
|
|
30
|
-
* @param date The date to format.
|
|
31
|
-
* @returns The formatted time string.
|
|
32
|
-
*/
|
|
33
|
-
export declare function formatTime(date: Date): string;
|
|
34
|
-
/**
|
|
35
|
-
* Formats a Date as YYYY-MM-DD HH:MM:SS.
|
|
36
|
-
* @param date The date to format.
|
|
37
|
-
* @returns The formatted date-time string.
|
|
38
|
-
*/
|
|
39
|
-
export declare function formatDateTime(date: Date): string;
|
|
40
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/formatting/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,MAAM,GAAE,MAAU,GAAG,MAAM,CAE1E;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,GAAE,MAAgB,GAAG,MAAM,CAE1E;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,SAAI,GAAG,MAAM,CAEvE;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAE7C;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAE7C;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAEjD"}
|
package/dist/formatting/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"../chunks/chunk-ANN5UYCF.js";function n(t,r=2){return String(t).padStart(r,"0")}function i(t,r="en-US"){return t.toLocaleString(r)}function u(t,r=0){return`${(t*100).toFixed(r)}%`}function e(t){return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}`}function o(t){return`${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`}function g(t){return`${e(t)} ${o(t)}`}export{e as formatDate,g as formatDateTime,i as formatNumber,u as formatPercent,o as formatTime,n as padZero};
|
package/dist/math/index.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Add two numbers.
|
|
3
|
-
* For example, 1 + 2 = 3.
|
|
4
|
-
*
|
|
5
|
-
* @param {number} a
|
|
6
|
-
* @param {number} b
|
|
7
|
-
* @returns {number} number
|
|
8
|
-
*/
|
|
9
|
-
export declare const add: (a: number, b: number) => number;
|
|
10
|
-
/**
|
|
11
|
-
* Subtract two numbers.
|
|
12
|
-
* For example, 2 - 1 = 1.
|
|
13
|
-
*
|
|
14
|
-
* @param {number} a
|
|
15
|
-
* @param {number} b
|
|
16
|
-
* @returns {number} number
|
|
17
|
-
*/
|
|
18
|
-
export declare const subtract: (a: number, b: number) => number;
|
|
19
|
-
/**
|
|
20
|
-
* Multiply two numbers.
|
|
21
|
-
* For example, 2 * 2 = 4.
|
|
22
|
-
*
|
|
23
|
-
* @param {number} a
|
|
24
|
-
* @param {number} b
|
|
25
|
-
* @returns {number} number
|
|
26
|
-
*/
|
|
27
|
-
export declare const multiply: (a: number, b: number) => number;
|
|
28
|
-
/**
|
|
29
|
-
* Divide two numbers.
|
|
30
|
-
* For example, 4 / 2 = 2.
|
|
31
|
-
*
|
|
32
|
-
* @param {number} a
|
|
33
|
-
* @param {number} b
|
|
34
|
-
* @returns {number} number
|
|
35
|
-
*/
|
|
36
|
-
export declare const divide: (a: number, b: number) => number;
|
|
37
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/math/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/math/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,GAAG,GAAI,GAAG,MAAM,EAAE,GAAG,MAAM,KAAG,MAAe,CAAA;AAE1D;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,GAAI,GAAG,MAAM,EAAE,GAAG,MAAM,KAAG,MAAe,CAAA;AAE/D;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,GAAI,GAAG,MAAM,EAAE,GAAG,MAAM,KAAG,MAAe,CAAA;AAE/D;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,GAAI,GAAG,MAAM,EAAE,GAAG,MAAM,KAAG,MAAe,CAAA"}
|
package/dist/math/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"../chunks/chunk-ANN5UYCF.js";var n=(e,r)=>e+r,u=(e,r)=>e-r,b=(e,r)=>e*r,m=(e,r)=>e/r;export{n as add,m as divide,b as multiply,u as subtract};
|
package/dist/try/attempt.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
type AttemptSuccess<T> = readonly [null, T];
|
|
2
|
-
type AttemptFailure<E> = readonly [E, null];
|
|
3
|
-
type AttemptResult<E, T> = AttemptSuccess<T> | AttemptFailure<E>;
|
|
4
|
-
type AttemptResultAsync<E, T> = Promise<AttemptResult<E, T>>;
|
|
5
|
-
export declare function attempt<E = Error, T = Promise<any>>(operation: T): AttemptResultAsync<E, T>;
|
|
6
|
-
export declare function attempt<E = Error, T = any>(operation: () => T): AttemptResult<E, T>;
|
|
7
|
-
export {};
|
|
8
|
-
//# sourceMappingURL=attempt.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"attempt.d.ts","sourceRoot":"","sources":["../../src/try/attempt.ts"],"names":[],"mappings":"AAAA,KAAK,cAAc,CAAC,CAAC,IAAI,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC,CAAA;AAC3C,KAAK,cAAc,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,CAAA;AAC3C,KAAK,aAAa,CAAC,CAAC,EAAE,CAAC,IAAI,cAAc,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAAA;AAChE,KAAK,kBAAkB,CAAC,CAAC,EAAE,CAAC,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;AAE5D,wBAAgB,OAAO,CAAC,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,EAAE,SAAS,EAAE,CAAC,GAAG,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AAC5F,wBAAgB,OAAO,CAAC,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,GAAG,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA"}
|
package/dist/try/attempt.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"../chunks/chunk-ANN5UYCF.js";function r(e){if(e instanceof Promise)return e.then(t=>[null,t]).catch(t=>[t,null]);try{return[null,e()]}catch(t){return[t,null]}}export{r as attempt};
|