@rtorcato/js-common 1.8.1 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/README.md +77 -62
- package/dist/abortController/index.d.ts +29 -0
- package/dist/abortController/index.d.ts.map +1 -0
- package/dist/arrays/index.d.ts +134 -0
- package/dist/arrays/index.d.ts.map +1 -0
- package/dist/arrays/index.js +1 -1
- package/dist/boolean/index.d.ts +41 -0
- package/dist/boolean/index.d.ts.map +1 -0
- package/dist/boolean/index.js +1 -1
- package/dist/colors/index.d.ts +63 -0
- package/dist/colors/index.d.ts.map +1 -0
- package/dist/console/index.d.ts +16 -0
- package/dist/console/index.d.ts.map +1 -0
- package/dist/crypto/index.d.ts +34 -0
- package/dist/crypto/index.d.ts.map +1 -0
- package/dist/currency/currencies.d.ts +16 -0
- package/dist/currency/currencies.d.ts.map +1 -0
- package/dist/currency/index.d.ts +170 -0
- package/dist/currency/index.d.ts.map +1 -0
- package/dist/date/index.d.ts +44 -0
- package/dist/date/index.d.ts.map +1 -0
- package/dist/datetime/index.d.ts +52 -0
- package/dist/datetime/index.d.ts.map +1 -0
- package/dist/emails/banned/index.d.ts +9 -0
- package/dist/emails/banned/index.d.ts.map +1 -0
- package/dist/emails/index.d.ts +26 -0
- package/dist/emails/index.d.ts.map +1 -0
- package/dist/env/index.d.ts +63 -0
- package/dist/env/index.d.ts.map +1 -0
- package/dist/errors/index.d.ts +39 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +1 -1
- package/dist/events/index.d.ts +35 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/fetch/index.d.ts +38 -0
- package/dist/fetch/index.d.ts.map +1 -0
- package/dist/file/index.d.ts +32 -0
- package/dist/file/index.d.ts.map +1 -0
- package/dist/formatting/index.d.ts +40 -0
- package/dist/formatting/index.d.ts.map +1 -0
- package/dist/functions/index.d.ts +33 -0
- package/dist/functions/index.d.ts.map +1 -0
- package/dist/geometry/index.d.ts +58 -0
- package/dist/geometry/index.d.ts.map +1 -0
- package/dist/html/index.d.ts +31 -0
- package/dist/html/index.d.ts.map +1 -0
- package/dist/i18n/index.d.ts +37 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/interval/index.d.ts +13 -0
- package/dist/interval/index.d.ts.map +1 -0
- package/dist/json/index.d.ts +28 -0
- package/dist/json/index.d.ts.map +1 -0
- package/dist/logger/index.d.ts +2 -0
- package/dist/logger/index.d.ts.map +1 -0
- package/dist/logger/logger.d.ts +3 -0
- package/dist/logger/logger.d.ts.map +1 -0
- package/dist/logging/index.d.ts +29 -0
- package/dist/logging/index.d.ts.map +1 -0
- package/dist/logging/index.js +1 -1
- package/dist/maps/index.d.ts +32 -0
- package/dist/maps/index.d.ts.map +1 -0
- package/dist/math/index.d.ts +37 -0
- package/dist/math/index.d.ts.map +1 -0
- package/dist/math/index.js +1 -1
- package/dist/mime-types/db.d.ts +4605 -0
- package/dist/mime-types/db.d.ts.map +1 -0
- package/dist/mime-types/index.d.ts +25 -0
- package/dist/mime-types/index.d.ts.map +1 -0
- package/dist/node/index.d.ts +52 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/numbers/index.d.ts +82 -0
- package/dist/numbers/index.d.ts.map +1 -0
- package/dist/objects/index.d.ts +35 -0
- package/dist/objects/index.d.ts.map +1 -0
- package/dist/os/index.d.ts +26 -0
- package/dist/os/index.d.ts.map +1 -0
- package/dist/process/index.d.ts +31 -0
- package/dist/process/index.d.ts.map +1 -0
- package/dist/promises/index.d.ts +39 -0
- package/dist/promises/index.d.ts.map +1 -0
- package/dist/random/index.d.ts +33 -0
- package/dist/random/index.d.ts.map +1 -0
- package/dist/regex/index.d.ts +36 -0
- package/dist/regex/index.d.ts.map +1 -0
- package/dist/security/index.d.ts +14 -0
- package/dist/security/index.d.ts.map +1 -0
- package/dist/sets/index.d.ts +48 -0
- package/dist/sets/index.d.ts.map +1 -0
- package/dist/sleep/index.d.ts +27 -0
- package/dist/sleep/index.d.ts.map +1 -0
- package/dist/strings/index.d.ts +296 -0
- package/dist/strings/index.d.ts.map +1 -0
- package/dist/system/index.d.ts +36 -0
- package/dist/system/index.d.ts.map +1 -0
- package/dist/time/index.d.ts +36 -0
- package/dist/time/index.d.ts.map +1 -0
- package/dist/try/attempt.d.ts +8 -0
- package/dist/try/attempt.d.ts.map +1 -0
- package/dist/try/index.d.ts +2 -0
- package/dist/try/index.d.ts.map +1 -0
- package/dist/try/trycatch.d.ts +12 -0
- package/dist/try/trycatch.d.ts.map +1 -0
- package/dist/types/common/index.d.ts +9 -0
- package/dist/types/env.d.ts +5 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/url/index.d.ts +40 -0
- package/dist/url/index.d.ts.map +1 -0
- package/dist/uuid/index.d.ts +99 -0
- package/dist/uuid/index.d.ts.map +1 -0
- package/dist/validation/index.d.ts +49 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/index.js +1 -1
- package/package.json +3 -16
- package/dist/chunks/chunk-DCFILRIS.js +0 -1
- package/dist/math/math.js +0 -1
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a string to Title Case (capitalizes the first letter of each word).
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* titleCase('hello world') // 'Hello World'
|
|
7
|
+
* titleCase('javaScript is awesome') // 'Javascript Is Awesome'
|
|
8
|
+
* titleCase('UPPER CASE TEXT') // 'Upper Case Text'
|
|
9
|
+
* titleCase('mixed-case_string') // 'Mixed-case_string'
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* @param str The string to convert to title case
|
|
13
|
+
* @returns The title-cased string
|
|
14
|
+
* @category String Utilities
|
|
15
|
+
*/
|
|
16
|
+
export declare function titleCase(str: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Capitalizes the first letter of a string.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* capitalize('hello') // 'Hello'
|
|
23
|
+
* capitalize('WORLD') // 'WORLD'
|
|
24
|
+
* capitalize('') // ''
|
|
25
|
+
* capitalize('a') // 'A'
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @param str The string to capitalize
|
|
29
|
+
* @returns The capitalized string
|
|
30
|
+
* @category String Utilities
|
|
31
|
+
*/
|
|
32
|
+
export declare function capitalize(str: string): string;
|
|
33
|
+
/**
|
|
34
|
+
* Converts a string to camelCase.
|
|
35
|
+
* Removes hyphens, underscores, and spaces while capitalizing following letters.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* camelCase('hello world') // 'helloWorld'
|
|
40
|
+
* camelCase('hello-world') // 'helloWorld'
|
|
41
|
+
* camelCase('hello_world') // 'helloWorld'
|
|
42
|
+
* camelCase('Hello World') // 'helloWorld'
|
|
43
|
+
* camelCase('API_KEY_NAME') // 'aPIKEYNAME'
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @param str The string to convert to camelCase
|
|
47
|
+
* @returns The camelCased string
|
|
48
|
+
* @category String Utilities
|
|
49
|
+
*/
|
|
50
|
+
export declare function camelCase(str: string): string;
|
|
51
|
+
/**
|
|
52
|
+
* Converts a string to kebab-case.
|
|
53
|
+
* Converts camelCase and spaces/underscores to hyphen-separated lowercase.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* kebabCase('helloWorld') // 'hello-world'
|
|
58
|
+
* kebabCase('Hello World') // 'hello-world'
|
|
59
|
+
* kebabCase('hello_world') // 'hello-world'
|
|
60
|
+
* kebabCase('APIKeyName') // 'a-p-i-key-name'
|
|
61
|
+
* kebabCase('camelCaseString') // 'camel-case-string'
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @param str The string to convert to kebab-case
|
|
65
|
+
* @returns The kebab-cased string
|
|
66
|
+
* @category String Utilities
|
|
67
|
+
*/
|
|
68
|
+
export declare function kebabCase(str: string): string;
|
|
69
|
+
/**
|
|
70
|
+
* Converts a string to snake_case.
|
|
71
|
+
* @param str The string to convert.
|
|
72
|
+
* @returns The snake_cased string.
|
|
73
|
+
*/
|
|
74
|
+
export declare function snakeCase(str: string): string;
|
|
75
|
+
/**
|
|
76
|
+
* Truncates a string to a maximum length, adding ellipsis if needed.
|
|
77
|
+
* @param str The string to truncate.
|
|
78
|
+
* @param maxLength The maximum length.
|
|
79
|
+
* @returns The truncated string.
|
|
80
|
+
*/
|
|
81
|
+
export declare function truncate(str: string, maxLength: number): string;
|
|
82
|
+
/**
|
|
83
|
+
* Pads the start of a string to a given length.
|
|
84
|
+
* @param str The string to pad.
|
|
85
|
+
* @param targetLength The target length.
|
|
86
|
+
* @param padString The string to pad with.
|
|
87
|
+
* @returns The padded string.
|
|
88
|
+
*/
|
|
89
|
+
export declare function padStart(str: string, targetLength: number, padString?: string): string;
|
|
90
|
+
/**
|
|
91
|
+
* Pads the end of a string to a given length.
|
|
92
|
+
* @param str The string to pad.
|
|
93
|
+
* @param targetLength The target length.
|
|
94
|
+
* @param padString The string to pad with.
|
|
95
|
+
* @returns The padded string.
|
|
96
|
+
*/
|
|
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
|
+
/**
|
|
106
|
+
* replace all items in a string using regex
|
|
107
|
+
* @param {string} str
|
|
108
|
+
* @param {string} search
|
|
109
|
+
* @param {string} replacement
|
|
110
|
+
*/
|
|
111
|
+
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
|
+
/**
|
|
119
|
+
* Reverses a string.
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```typescript
|
|
123
|
+
* reverse('hello') // 'olleh'
|
|
124
|
+
* reverse('abc123') // '321cba'
|
|
125
|
+
* ```
|
|
126
|
+
*
|
|
127
|
+
* @param str The string to reverse
|
|
128
|
+
* @returns The reversed string
|
|
129
|
+
*/
|
|
130
|
+
export declare function reverse(str: string): string;
|
|
131
|
+
/**
|
|
132
|
+
* Converts a string to a URL-friendly slug.
|
|
133
|
+
* Handles unicode, accents, and special characters.
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```typescript
|
|
137
|
+
* slugify('Hello World!') // 'hello-world'
|
|
138
|
+
* slugify('Café & Résumé') // 'cafe-resume'
|
|
139
|
+
* slugify(' Multiple Spaces ') // 'multiple-spaces'
|
|
140
|
+
* ```
|
|
141
|
+
*
|
|
142
|
+
* @param str The string to slugify
|
|
143
|
+
* @returns The slugified string
|
|
144
|
+
*/
|
|
145
|
+
export declare function slugify(str: string): string;
|
|
146
|
+
/**
|
|
147
|
+
* Splits a string into an array of words.
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```typescript
|
|
151
|
+
* words('hello world') // ['hello', 'world']
|
|
152
|
+
* words('camelCaseString') // ['camel', 'Case', 'String']
|
|
153
|
+
* words('hello-world_test') // ['hello', 'world', 'test']
|
|
154
|
+
* ```
|
|
155
|
+
*
|
|
156
|
+
* @param str The string to split
|
|
157
|
+
* @returns Array of words
|
|
158
|
+
*/
|
|
159
|
+
export declare function words(str: string): string[];
|
|
160
|
+
/**
|
|
161
|
+
* Counts the number of words in a string.
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```typescript
|
|
165
|
+
* wordCount('hello world') // 2
|
|
166
|
+
* wordCount(' one two three ') // 3
|
|
167
|
+
* wordCount('') // 0
|
|
168
|
+
* ```
|
|
169
|
+
*
|
|
170
|
+
* @param str The string to count words in
|
|
171
|
+
* @returns The word count
|
|
172
|
+
*/
|
|
173
|
+
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
|
+
/**
|
|
214
|
+
* Returns the plural form of a word based on count.
|
|
215
|
+
*
|
|
216
|
+
* @example
|
|
217
|
+
* ```typescript
|
|
218
|
+
* pluralize('item', 0) // 'items'
|
|
219
|
+
* pluralize('item', 1) // 'item'
|
|
220
|
+
* pluralize('item', 5) // 'items'
|
|
221
|
+
* pluralize('box', 2, 'boxes') // 'boxes'
|
|
222
|
+
* ```
|
|
223
|
+
*
|
|
224
|
+
* @param word The singular word
|
|
225
|
+
* @param count The count
|
|
226
|
+
* @param plural Optional custom plural form
|
|
227
|
+
* @returns The pluralized word
|
|
228
|
+
*/
|
|
229
|
+
export declare function pluralize(word: string, count: number, plural?: string): string;
|
|
230
|
+
/**
|
|
231
|
+
* Converts a number to its ordinal form.
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* ```typescript
|
|
235
|
+
* ordinalize(1) // '1st'
|
|
236
|
+
* ordinalize(2) // '2nd'
|
|
237
|
+
* ordinalize(3) // '3rd'
|
|
238
|
+
* ordinalize(4) // '4th'
|
|
239
|
+
* ordinalize(11) // '11th'
|
|
240
|
+
* ordinalize(21) // '21st'
|
|
241
|
+
* ```
|
|
242
|
+
*
|
|
243
|
+
* @param num The number to ordinalize
|
|
244
|
+
* @returns The ordinal string
|
|
245
|
+
*/
|
|
246
|
+
export declare function ordinalize(num: number): string;
|
|
247
|
+
/**
|
|
248
|
+
* Checks if a string is blank (empty or only whitespace).
|
|
249
|
+
*
|
|
250
|
+
* @example
|
|
251
|
+
* ```typescript
|
|
252
|
+
* isBlank('') // true
|
|
253
|
+
* isBlank(' ') // true
|
|
254
|
+
* isBlank('\t\n') // true
|
|
255
|
+
* isBlank('hello') // false
|
|
256
|
+
* isBlank(' a ') // false
|
|
257
|
+
* ```
|
|
258
|
+
*
|
|
259
|
+
* @param str The string to check
|
|
260
|
+
* @returns True if blank, false otherwise
|
|
261
|
+
*/
|
|
262
|
+
export declare function isBlank(str: string): boolean;
|
|
263
|
+
/**
|
|
264
|
+
* Masks part of a string with a specified character.
|
|
265
|
+
*
|
|
266
|
+
* @example
|
|
267
|
+
* ```typescript
|
|
268
|
+
* mask('1234567890', 0, 4) // '******7890'
|
|
269
|
+
* mask('1234567890', 6, 10) // '123456****'
|
|
270
|
+
* mask('secret', 0, 3, 'X') // 'XXXret'
|
|
271
|
+
* mask('4111111111111111', 0, 12) // '************1111'
|
|
272
|
+
* ```
|
|
273
|
+
*
|
|
274
|
+
* @param str The string to mask
|
|
275
|
+
* @param start Start index of masking
|
|
276
|
+
* @param end End index of masking
|
|
277
|
+
* @param char The masking character (default: '*')
|
|
278
|
+
* @returns The masked string
|
|
279
|
+
*/
|
|
280
|
+
export declare function mask(str: string, start: number, end: number, char?: string): string;
|
|
281
|
+
/**
|
|
282
|
+
* Simple template interpolation using ${key} syntax.
|
|
283
|
+
*
|
|
284
|
+
* @example
|
|
285
|
+
* ```typescript
|
|
286
|
+
* template('Hello, ${name}!', { name: 'World' }) // 'Hello, World!'
|
|
287
|
+
* template('${a} + ${b} = ${c}', { a: 1, b: 2, c: 3 }) // '1 + 2 = 3'
|
|
288
|
+
* template('Missing ${key}', {}) // 'Missing ${key}'
|
|
289
|
+
* ```
|
|
290
|
+
*
|
|
291
|
+
* @param str The template string
|
|
292
|
+
* @param data The data object with values
|
|
293
|
+
* @returns The interpolated string
|
|
294
|
+
*/
|
|
295
|
+
export declare function template(str: string, data: Record<string, unknown>): string;
|
|
296
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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,YAAY,GAAI,QAAQ,MAAM,EAAE,OAAO,MAAM,KAAG,MAM5D,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,KAAK,MAAM,EAAE,QAAQ,MAAM,EAAE,aAAa,MAAM,KAAG,MAEhF,CAAA;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAElD;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;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAS9C;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAehD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7C;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"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the current OS is macOS.
|
|
3
|
+
* @returns {boolean} True if macOS, false otherwise.
|
|
4
|
+
*/
|
|
5
|
+
export declare function isMacOs(): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Checks if the current OS is Windows.
|
|
8
|
+
* @returns {boolean} True if Windows, false otherwise.
|
|
9
|
+
*/
|
|
10
|
+
export declare function isWindows(): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Checks if the current OS is Linux.
|
|
13
|
+
* @returns {boolean} True if Linux, false otherwise.
|
|
14
|
+
*/
|
|
15
|
+
export declare function isLinux(): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Checks if the device is running iOS.
|
|
18
|
+
* @returns {boolean} True if iOS, false otherwise.
|
|
19
|
+
*/
|
|
20
|
+
export declare function isIOS(): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Checks if the device is running Android.
|
|
23
|
+
* @returns {boolean} True if Android, false otherwise.
|
|
24
|
+
*/
|
|
25
|
+
export declare function isAndroid(): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Returns a string representing the detected platform.
|
|
28
|
+
* @returns {string} The platform name (e.g., 'macos', 'windows', 'linux', 'ios', 'android', or 'unknown').
|
|
29
|
+
*/
|
|
30
|
+
export declare function getPlatform(): string;
|
|
31
|
+
/**
|
|
32
|
+
* Checks if the device supports touch events.
|
|
33
|
+
* @returns {boolean} True if touch is supported, false otherwise.
|
|
34
|
+
*/
|
|
35
|
+
export declare function isTouchDevice(): boolean;
|
|
36
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/system/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,OAAO,IAAI,OAAO,CAQjC;AAED;;;GAGG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAQnC;AAED;;;GAGG;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"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the current time as HH:MM:SS string.
|
|
3
|
+
* @returns {string}
|
|
4
|
+
*/
|
|
5
|
+
export declare function nowTime(): string;
|
|
6
|
+
/**
|
|
7
|
+
* Parses a time string (HH:MM or HH:MM:SS) into a Date object (today's date).
|
|
8
|
+
* @param timeStr The time string.
|
|
9
|
+
* @returns {Date}
|
|
10
|
+
*/
|
|
11
|
+
export declare function parseTime(timeStr: string): Date;
|
|
12
|
+
/**
|
|
13
|
+
* Formats a Date object as HH:MM:SS.
|
|
14
|
+
* @param date The Date object.
|
|
15
|
+
* @returns {string}
|
|
16
|
+
*/
|
|
17
|
+
export declare function formatTime(date: Date): string;
|
|
18
|
+
/**
|
|
19
|
+
* Returns the difference in seconds between two times (as Date or string).
|
|
20
|
+
* @param t1 First time (Date or string).
|
|
21
|
+
* @param t2 Second time (Date or string).
|
|
22
|
+
* @returns {number}
|
|
23
|
+
*/
|
|
24
|
+
export declare function secondsBetween(t1: string | Date, t2: string | Date): number;
|
|
25
|
+
/**
|
|
26
|
+
* Pads a number to two digits (e.g., 5 -> '05').
|
|
27
|
+
* @param n The number.
|
|
28
|
+
* @returns {string}
|
|
29
|
+
*/
|
|
30
|
+
export declare function pad2(n: number): string;
|
|
31
|
+
/**
|
|
32
|
+
* Returns the current time as HH:MM string.
|
|
33
|
+
* @returns {string}
|
|
34
|
+
*/
|
|
35
|
+
export declare function nowTimeShort(): string;
|
|
36
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/time/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,OAAO,IAAI,MAAM,CAGhC;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAK/C;AAED;;;;GAIG;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"}
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/try/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type Success<T> = {
|
|
2
|
+
data: T;
|
|
3
|
+
error: null;
|
|
4
|
+
};
|
|
5
|
+
export type Failure<E> = {
|
|
6
|
+
data: null;
|
|
7
|
+
error: E;
|
|
8
|
+
};
|
|
9
|
+
export type Result<T, E = Error> = Success<T> | Failure<E>;
|
|
10
|
+
export declare function isSuccess<T, E>(result: Result<T, E>): result is Success<T>;
|
|
11
|
+
export declare function tryCatch<T, E = Error>(fn: () => Promise<T>): Promise<Result<T, E>>;
|
|
12
|
+
//# sourceMappingURL=trycatch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trycatch.d.ts","sourceRoot":"","sources":["../../src/try/trycatch.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI;IAAE,IAAI,EAAE,CAAC,CAAC;IAAC,KAAK,EAAE,IAAI,CAAA;CAAE,CAAA;AAEjD,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,CAAA;AAEjD,MAAM,MAAM,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;AAE1D,wBAAgB,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,CAE1E;AAED,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,9 @@
|
|
|
1
|
+
/** Prettify a type for better intellisense */
|
|
2
|
+
export type Prettify<T> = { [K in keyof T]: T[K] } & {}
|
|
3
|
+
|
|
4
|
+
// export type Prettify<T> = {
|
|
5
|
+
// [K in keyof T]: T[K]
|
|
6
|
+
// }
|
|
7
|
+
|
|
8
|
+
/** Merge two types, with B overriding A */
|
|
9
|
+
export type Merge<A, B> = Omit<A, keyof B> & B
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if a string is a valid URL.
|
|
3
|
+
* @param str The string to check.
|
|
4
|
+
* @returns True if valid URL, false otherwise.
|
|
5
|
+
*/
|
|
6
|
+
export declare function isValidUrl(str: string): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Gets the query parameters from a URL as an object.
|
|
9
|
+
* @param url The URL string.
|
|
10
|
+
* @returns An object of query parameters.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getQueryParams(url: string): Record<string, string>;
|
|
13
|
+
/**
|
|
14
|
+
* Adds or updates a query parameter in a URL.
|
|
15
|
+
* @param url The URL string.
|
|
16
|
+
* @param key The query parameter key.
|
|
17
|
+
* @param value The query parameter value.
|
|
18
|
+
* @returns The updated URL string.
|
|
19
|
+
*/
|
|
20
|
+
export declare function setQueryParam(url: string, key: string, value: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Removes a query parameter from a URL.
|
|
23
|
+
* @param url The URL string.
|
|
24
|
+
* @param key The query parameter key to remove.
|
|
25
|
+
* @returns The updated URL string.
|
|
26
|
+
*/
|
|
27
|
+
export declare function removeQueryParam(url: string, key: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* Joins multiple URL segments into a single URL, ensuring proper slashes.
|
|
30
|
+
* @param parts The URL segments.
|
|
31
|
+
* @returns The joined URL string.
|
|
32
|
+
*/
|
|
33
|
+
export declare function joinUrl(...parts: string[]): string;
|
|
34
|
+
/**
|
|
35
|
+
* Gets the hostname from a URL string.
|
|
36
|
+
* @param url The URL string.
|
|
37
|
+
* @returns The hostname, or an empty string if invalid.
|
|
38
|
+
*/
|
|
39
|
+
export declare function getHostname(url: string): string;
|
|
40
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/url/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAO/C;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAWlE;AAED;;;;;;GAMG;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;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAQlD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAM/C"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates a UUID v4 string.
|
|
3
|
+
* @returns {string} A new UUID v4 string.
|
|
4
|
+
*/
|
|
5
|
+
export declare const getUUID: () => string;
|
|
6
|
+
/**
|
|
7
|
+
* Generates a UUID v7 string (time-ordered).
|
|
8
|
+
* UUID v7 embeds a Unix timestamp, making them sortable and ideal for database primary keys.
|
|
9
|
+
* @returns {string} A new UUID v7 string.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* getUUIDv7() // '018e5e2c-7c0a-7000-8000-0e02b2c3d479'
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare const getUUIDv7: () => string;
|
|
17
|
+
/**
|
|
18
|
+
* Generates a short UUID string using short-uuid.
|
|
19
|
+
* @returns {string} A new short UUID string.
|
|
20
|
+
*/
|
|
21
|
+
export declare const getShortUUID: () => string;
|
|
22
|
+
/**
|
|
23
|
+
* Converts a standard UUID to a short UUID.
|
|
24
|
+
* @param uuid The standard UUID string.
|
|
25
|
+
* @returns {string} The short UUID string.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* toShortUUID('f47ac10b-58cc-4372-a567-0e02b2c3d479') // 'mhvXdrZT4jP5T8vBxuvm75'
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare const toShortUUID: (uuid: string) => string;
|
|
33
|
+
/**
|
|
34
|
+
* Converts a short UUID back to a standard UUID.
|
|
35
|
+
* @param short The short UUID string.
|
|
36
|
+
* @returns {string} The standard UUID string.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* fromShortUUID('mhvXdrZT4jP5T8vBxuvm75') // 'f47ac10b-58cc-4372-a567-0e02b2c3d479'
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare const fromShortUUID: (short: string) => string;
|
|
44
|
+
/**
|
|
45
|
+
* Checks if a string is a valid UUID (any version).
|
|
46
|
+
* @param id The string to validate.
|
|
47
|
+
* @returns {boolean} True if valid UUID, false otherwise.
|
|
48
|
+
*/
|
|
49
|
+
export declare const isUUID: (id: string) => boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Checks if a string is a valid UUID v4.
|
|
52
|
+
* @param id The string to validate.
|
|
53
|
+
* @returns {boolean} True if valid UUID v4, false otherwise.
|
|
54
|
+
*/
|
|
55
|
+
export declare const isUUIDv4: (id: string) => boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Checks if a UUID is the nil UUID (all zeros).
|
|
58
|
+
* @param id The UUID string to check.
|
|
59
|
+
* @returns {boolean} True if nil UUID, false otherwise.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* isNilUUID('00000000-0000-0000-0000-000000000000') // true
|
|
64
|
+
* isNilUUID('f47ac10b-58cc-4372-a567-0e02b2c3d479') // false
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export declare const isNilUUID: (id: string) => boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Gets the version number of a UUID.
|
|
70
|
+
* @param id The UUID string.
|
|
71
|
+
* @returns {number} The UUID version (1, 4, 7, etc.), or 0 for nil UUID.
|
|
72
|
+
* @throws {Error} If the UUID is invalid.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* getUUIDVersion('f47ac10b-58cc-4372-a567-0e02b2c3d479') // 4
|
|
77
|
+
* getUUIDVersion('018e5e2c-7c0a-7000-8000-0e02b2c3d479') // 7
|
|
78
|
+
* getUUIDVersion('00000000-0000-0000-0000-000000000000') // 0
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export declare const getUUIDVersion: (id: string) => number;
|
|
82
|
+
/**
|
|
83
|
+
* Returns the nil UUID (all zeros).
|
|
84
|
+
* @returns {string} The nil UUID string.
|
|
85
|
+
*/
|
|
86
|
+
export declare const getNilUUID: () => string;
|
|
87
|
+
/**
|
|
88
|
+
* Converts a UUID string to a byte array (Uint8Array).
|
|
89
|
+
* @param id The UUID string.
|
|
90
|
+
* @returns {Uint8Array} The byte array representation of the UUID.
|
|
91
|
+
*/
|
|
92
|
+
export declare const uuidToBytes: (id: string) => Uint8Array;
|
|
93
|
+
/**
|
|
94
|
+
* Converts a byte array (Uint8Array) to a UUID string.
|
|
95
|
+
* @param bytes The byte array.
|
|
96
|
+
* @returns {string} The UUID string.
|
|
97
|
+
*/
|
|
98
|
+
export declare const bytesToUUID: (bytes: Uint8Array) => string;
|
|
99
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/uuid/index.ts"],"names":[],"mappings":"AAaA;;;GAGG;AACH,eAAO,MAAM,OAAO,QAAO,MAE1B,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,SAAS,QAAO,MAE5B,CAAA;AAED;;;GAGG;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"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if a value is defined (not null or undefined).
|
|
3
|
+
* @param value The value to check.
|
|
4
|
+
* @returns {boolean}
|
|
5
|
+
*/
|
|
6
|
+
export declare function isDefined<T>(value: T | null | undefined): value is T;
|
|
7
|
+
/**
|
|
8
|
+
* Check if a value is a string.
|
|
9
|
+
* @param value - The value to check.
|
|
10
|
+
* @returns `true` if the value is a string, `false` otherwise.
|
|
11
|
+
*/
|
|
12
|
+
export declare function isString(value: unknown): value is string;
|
|
13
|
+
/**
|
|
14
|
+
* Checks if a value is a number (and not NaN).
|
|
15
|
+
* @param value The value to check.
|
|
16
|
+
* @returns {boolean}
|
|
17
|
+
*/
|
|
18
|
+
export declare function isNumber(value: unknown): value is number;
|
|
19
|
+
/**
|
|
20
|
+
* Checks if a value is a boolean.
|
|
21
|
+
* @param value The value to check.
|
|
22
|
+
* @returns {boolean}
|
|
23
|
+
*/
|
|
24
|
+
export declare function isBoolean(value: unknown): value is boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Checks if a value is an array.
|
|
27
|
+
* @param value The value to check.
|
|
28
|
+
* @returns {boolean}
|
|
29
|
+
*/
|
|
30
|
+
export declare function isArray(value: unknown): value is unknown[];
|
|
31
|
+
/**
|
|
32
|
+
* Checks if a value is an object (but not null or array).
|
|
33
|
+
* @param value The value to check.
|
|
34
|
+
* @returns {boolean}
|
|
35
|
+
*/
|
|
36
|
+
export declare function isObject(value: unknown): value is object;
|
|
37
|
+
/**
|
|
38
|
+
* Checks if a string is a valid email address (simple regex).
|
|
39
|
+
* @param str The string to check.
|
|
40
|
+
* @returns {boolean}
|
|
41
|
+
*/
|
|
42
|
+
export declare function isEmail(str: string): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Checks if a string is a valid URL.
|
|
45
|
+
* @param str The string to check.
|
|
46
|
+
* @returns {boolean}
|
|
47
|
+
*/
|
|
48
|
+
export declare function isUrl(str: string): boolean;
|
|
49
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validation/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,GAAG,SAAS,GAAG,KAAK,IAAI,CAAC,CAEpE;AAED;;;;GAIG;AAEH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAExD;AAED;;;;GAIG;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,CAE5C;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
|
|
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};
|