@rtorcato/js-common 2.8.2 → 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 +23 -0
- package/CONTRIBUTORS.md +5 -0
- package/README.md +70 -21
- package/dist/abortController/index.d.ts +30 -0
- package/dist/abortController/index.d.ts.map +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-7JQSIREC.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/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/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 +23 -25
- 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/cli/cli.mjs
CHANGED
|
@@ -7,6 +7,7 @@ import gradient from 'gradient-string';
|
|
|
7
7
|
import { readFileSync } from 'node:fs';
|
|
8
8
|
import { dirname, resolve } from 'node:path';
|
|
9
9
|
import { fileURLToPath } from 'node:url';
|
|
10
|
+
import { functionCategories } from './catalog.js';
|
|
10
11
|
// Get current directory
|
|
11
12
|
const currentDir = dirname(fileURLToPath(import.meta.url));
|
|
12
13
|
// Get package version
|
|
@@ -15,62 +16,6 @@ program
|
|
|
15
16
|
.name('js-common')
|
|
16
17
|
.description(chalk.cyan('✨ CLI utilities from @rtorcato/js-common'))
|
|
17
18
|
.version(packageJson.version);
|
|
18
|
-
// Function categories for list and interactive mode
|
|
19
|
-
const functionCategories = {
|
|
20
|
-
date: {
|
|
21
|
-
name: '📅 Date & Time',
|
|
22
|
-
functions: [
|
|
23
|
-
{ name: 'today', description: "Get today's date (YYYY-MM-DD)" },
|
|
24
|
-
{ name: 'now', description: 'Get current timestamp' },
|
|
25
|
-
{ name: 'between', description: 'Calculate days between dates' },
|
|
26
|
-
],
|
|
27
|
-
},
|
|
28
|
-
math: {
|
|
29
|
-
name: '🔢 Mathematical',
|
|
30
|
-
functions: [
|
|
31
|
-
{ name: 'sum', description: 'Calculate sum of numbers' },
|
|
32
|
-
{ name: 'avg', description: 'Calculate average of numbers' },
|
|
33
|
-
{ name: 'random', description: 'Generate random number' },
|
|
34
|
-
{ name: 'round', description: 'Round to decimal places' },
|
|
35
|
-
{ name: 'clamp', description: 'Clamp between min/max' },
|
|
36
|
-
],
|
|
37
|
-
},
|
|
38
|
-
text: {
|
|
39
|
-
name: '📝 Text Formatting',
|
|
40
|
-
functions: [
|
|
41
|
-
{ name: 'capitalize', description: 'Capitalize first letter' },
|
|
42
|
-
{ name: 'title', description: 'Convert to title case' },
|
|
43
|
-
{ name: 'pad', description: 'Pad with leading zeros' },
|
|
44
|
-
],
|
|
45
|
-
},
|
|
46
|
-
file: {
|
|
47
|
-
name: '📁 File Operations',
|
|
48
|
-
functions: [
|
|
49
|
-
{ name: 'exists', description: 'Check if file exists' },
|
|
50
|
-
{ name: 'ext', description: 'Get file extension' },
|
|
51
|
-
],
|
|
52
|
-
},
|
|
53
|
-
security: {
|
|
54
|
-
name: '🔒 Security',
|
|
55
|
-
functions: [
|
|
56
|
-
{ name: 'password', description: 'Check password strength' },
|
|
57
|
-
{ name: 'token', description: 'Generate secure token' },
|
|
58
|
-
],
|
|
59
|
-
},
|
|
60
|
-
validate: {
|
|
61
|
-
name: '✅ Validation',
|
|
62
|
-
functions: [{ name: 'url', description: 'Validate URL format' }],
|
|
63
|
-
},
|
|
64
|
-
system: {
|
|
65
|
-
name: '💻 System Info',
|
|
66
|
-
functions: [
|
|
67
|
-
{ name: 'pid', description: 'Get process ID' },
|
|
68
|
-
{ name: 'uptime', description: 'Get process uptime' },
|
|
69
|
-
{ name: 'ci', description: 'Check CI environment' },
|
|
70
|
-
{ name: 'node-version', description: 'Get Node.js version' },
|
|
71
|
-
],
|
|
72
|
-
},
|
|
73
|
-
};
|
|
74
19
|
// List all functions - add as a separate command
|
|
75
20
|
program
|
|
76
21
|
.command('list')
|
|
@@ -212,7 +157,7 @@ program
|
|
|
212
157
|
message: chalk.cyan(`Select ${selectedCategory.name} functions to add:`),
|
|
213
158
|
choices: selectedCategory.functions.map((func) => ({
|
|
214
159
|
name: `${func.name} - ${func.description}`,
|
|
215
|
-
value: func
|
|
160
|
+
value: func,
|
|
216
161
|
checked: false,
|
|
217
162
|
})),
|
|
218
163
|
pageSize: 10,
|
|
@@ -222,20 +167,25 @@ program
|
|
|
222
167
|
console.log(chalk.yellow('\n📝 No functions selected. Exiting...\n'));
|
|
223
168
|
return;
|
|
224
169
|
}
|
|
170
|
+
// A category can span several modules (math → numbers + random), so
|
|
171
|
+
// group by subpath and print one import per module.
|
|
172
|
+
const bySubpath = new Map();
|
|
173
|
+
for (const func of functions) {
|
|
174
|
+
bySubpath.set(func.subpath, [...(bySubpath.get(func.subpath) ?? []), func.exportName]);
|
|
175
|
+
}
|
|
225
176
|
console.log(chalk.green('\n📦 Import Statement:'));
|
|
226
|
-
|
|
177
|
+
for (const [subpath, exportNames] of bySubpath) {
|
|
178
|
+
console.log(chalk.white(`import { ${exportNames.join(', ')} } from '@rtorcato/js-common/${subpath}'`));
|
|
179
|
+
}
|
|
227
180
|
console.log(chalk.green('\n📝 Usage Examples:'));
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
generateUsageExample(category, func);
|
|
233
|
-
}
|
|
234
|
-
});
|
|
181
|
+
for (const func of functions) {
|
|
182
|
+
console.log(chalk.gray(`\n// ${func.description}`));
|
|
183
|
+
console.log(chalk.white(func.example));
|
|
184
|
+
}
|
|
235
185
|
console.log(chalk.green('\n📚 Documentation:'));
|
|
236
186
|
console.log(chalk.blue(`https://github.com/rtorcato/js-common#${category}-utilities`));
|
|
237
187
|
console.log(chalk.yellow('\n💡 Tip: Run ') +
|
|
238
|
-
chalk.green(`js-common ${category} ${functions[0]} --help`) +
|
|
188
|
+
chalk.green(`js-common ${category} ${functions[0]?.name} --help`) +
|
|
239
189
|
chalk.yellow(' for detailed CLI usage\n'));
|
|
240
190
|
}
|
|
241
191
|
catch (error) {
|
|
@@ -248,49 +198,6 @@ program
|
|
|
248
198
|
process.exit(1);
|
|
249
199
|
}
|
|
250
200
|
});
|
|
251
|
-
// Helper function to generate usage examples
|
|
252
|
-
function generateUsageExample(category, functionName) {
|
|
253
|
-
const examples = {
|
|
254
|
-
date: {
|
|
255
|
-
today: `const today = today(); // "${new Date().toISOString().split('T')[0]}"`,
|
|
256
|
-
now: `const timestamp = now(); // ${Date.now()}`,
|
|
257
|
-
between: `const days = daysBetween('2023-01-01', '2023-12-31'); // 364`,
|
|
258
|
-
},
|
|
259
|
-
math: {
|
|
260
|
-
sum: `const total = sum([1, 2, 3, 4, 5]); // 15`,
|
|
261
|
-
avg: `const average = avg([10, 20, 30]); // 20`,
|
|
262
|
-
random: `const num = randomBetween(1, 100); // 42`,
|
|
263
|
-
round: `const rounded = roundTo(3.14159, 2); // 3.14`,
|
|
264
|
-
clamp: `const clamped = clamp(150, 0, 100); // 100`,
|
|
265
|
-
},
|
|
266
|
-
text: {
|
|
267
|
-
capitalize: `const text = capitalize('hello world'); // "Hello world"`,
|
|
268
|
-
title: `const title = toTitleCase('hello world'); // "Hello World"`,
|
|
269
|
-
pad: `const padded = padWithZeros(42, 5); // "00042"`,
|
|
270
|
-
},
|
|
271
|
-
file: {
|
|
272
|
-
exists: `const exists = await fileExists('package.json'); // true`,
|
|
273
|
-
ext: `const extension = getFileExtension('file.txt'); // "txt"`,
|
|
274
|
-
},
|
|
275
|
-
security: {
|
|
276
|
-
password: `const isStrong = checkPasswordStrength('MyPass123!'); // true`,
|
|
277
|
-
token: `const token = generateSecureToken(32); // "abc123..."`,
|
|
278
|
-
},
|
|
279
|
-
validate: {
|
|
280
|
-
url: `const isValid = isValidUrl('https://example.com'); // true`,
|
|
281
|
-
},
|
|
282
|
-
system: {
|
|
283
|
-
pid: `const processId = getProcessId(); // 12345`,
|
|
284
|
-
uptime: `const uptime = getProcessUptime(); // 123.45`,
|
|
285
|
-
ci: `const isCI = isCiEnvironment(); // false`,
|
|
286
|
-
'node-version': `const version = getNodeVersion(); // "18.17.0"`,
|
|
287
|
-
},
|
|
288
|
-
};
|
|
289
|
-
const example = examples[category]?.[functionName];
|
|
290
|
-
if (example) {
|
|
291
|
-
console.log(chalk.white(example));
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
201
|
// Date commands
|
|
295
202
|
const dateCmd = program.command('date').description('📅 Date and time utilities');
|
|
296
203
|
dateCmd
|
package/dist/colors/index.d.ts
CHANGED
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Generates a random hex color string.
|
|
3
3
|
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* randomColor() // '#a1b2c3'
|
|
7
|
+
* randomColor() // '#0f9e21'
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
4
10
|
* @returns {string} A string representing a random color in hexadecimal format (e.g., `#a1b2c3`).
|
|
5
11
|
*/
|
|
6
12
|
export declare function randomColor(): string;
|
|
7
13
|
/**
|
|
8
|
-
*
|
|
14
|
+
* Picks the readable text colour (`#000` or `#fff`) for a hex background.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* matchingTextColor('#ffffff') // '#000'
|
|
19
|
+
* matchingTextColor('#000000') // '#fff'
|
|
20
|
+
* matchingTextColor('#1e90ff') // '#fff'
|
|
21
|
+
* ```
|
|
9
22
|
*
|
|
10
23
|
* @export
|
|
11
24
|
* @param {string} color
|
|
@@ -15,6 +28,13 @@ export declare function matchingTextColor(color: string): "#000" | "#fff";
|
|
|
15
28
|
/**
|
|
16
29
|
* Converts a hex color string to an RGB object.
|
|
17
30
|
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* hexToRgb('#ff8800') // { r: 255, g: 136, b: 0 }
|
|
34
|
+
* hexToRgb('ff8800') // { r: 255, g: 136, b: 0 }
|
|
35
|
+
* hexToRgb('nope') // null
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
18
38
|
* @export
|
|
19
39
|
* @param {string} hex
|
|
20
40
|
* @return {*} {({ r: number; g: number; b: number } | null)}
|
|
@@ -35,11 +55,11 @@ export declare function hexToRgb(hex: string): {
|
|
|
35
55
|
*/
|
|
36
56
|
export declare function rgbToHex(r: number, g: number, b: number): string;
|
|
37
57
|
/**
|
|
38
|
-
*
|
|
58
|
+
* Checks whether a string is a valid 3- or 6-digit hex colour.
|
|
39
59
|
*
|
|
40
60
|
* @export
|
|
41
61
|
* @param {string} hex
|
|
42
|
-
* @return {*} {
|
|
62
|
+
* @return {*} {boolean}
|
|
43
63
|
*/
|
|
44
64
|
export declare function isValidHex(hex: string): boolean;
|
|
45
65
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/colors/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/colors/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAKpC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,mBAO9C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAQhF;AAED;;;;;;;;GAQG;AAEH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAOhE;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAE/C;AAED;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAO3D;AAED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAO5D"}
|
package/dist/console/index.d.ts
CHANGED
|
@@ -4,11 +4,23 @@
|
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* Disables console output in production environment.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* process.env.NODE_ENV = 'production'
|
|
11
|
+
* disableConsole()
|
|
12
|
+
* console.log('hidden') // no output
|
|
13
|
+
* ```
|
|
7
14
|
*/
|
|
8
15
|
export declare const disableConsole: () => void;
|
|
9
16
|
/**
|
|
10
17
|
* Clears the console.
|
|
11
18
|
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* clearConsole() // terminal is wiped, cursor back at the top-left
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
12
24
|
* @export
|
|
13
25
|
* @return {*} {void}
|
|
14
26
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/console/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/console/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,YAK1B,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,QAAO,IAE/B,CAAA"}
|
package/dist/crypto/index.d.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Hashes a string using the specified algorithm.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* hashString('hello')
|
|
7
|
+
* // '2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824'
|
|
8
|
+
* hashString('hello', 'md5') // '5d41402abc4b2a76b9719d911017c592'
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
3
11
|
* @param str The string to hash.
|
|
4
12
|
* @param algorithm The hash algorithm (default: 'sha256').
|
|
5
13
|
* @returns The hex-encoded hash.
|
|
@@ -7,12 +15,27 @@
|
|
|
7
15
|
export declare function hashString(str: string, algorithm?: string): string;
|
|
8
16
|
/**
|
|
9
17
|
* Generates a random hex string of the specified length (in bytes).
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* randomHex(4) // '9f3c1ab7' (8 hex chars)
|
|
22
|
+
* randomHex() // 32 hex chars (16 bytes)
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
10
25
|
* @param length The number of bytes (not hex chars).
|
|
11
26
|
* @returns A random hex string.
|
|
12
27
|
*/
|
|
13
28
|
export declare function randomHex(length?: number): string;
|
|
14
29
|
/**
|
|
15
30
|
* Creates an HMAC hash of a string using a secret and algorithm.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* hmacHash('payload', 's3cret')
|
|
35
|
+
* // 'd1d0f5b6...' (64 hex chars, stable for the same input + secret)
|
|
36
|
+
* hmacHash('payload', 's3cret', 'sha1') // 40 hex chars
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
16
39
|
* @param str The string to hash.
|
|
17
40
|
* @param secret The secret key.
|
|
18
41
|
* @param algorithm The hash algorithm (default: 'sha256').
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/crypto/index.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/crypto/index.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,SAAW,GAAG,MAAM,CAEpE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CAAC,MAAM,SAAK,GAAG,MAAM,CAE7C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,SAAW,GAAG,MAAM,CAElF;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEhD"}
|
package/dist/currency/index.d.ts
CHANGED
|
@@ -153,18 +153,4 @@ export declare function isValidCurrencyCode(code: string): Promise<boolean>;
|
|
|
153
153
|
* ```
|
|
154
154
|
*/
|
|
155
155
|
export declare function isValidCurrency(code: string): boolean;
|
|
156
|
-
/**
|
|
157
|
-
* Rounds a given number to a specified number of decimal places.
|
|
158
|
-
*
|
|
159
|
-
* @param value - The number to be rounded.
|
|
160
|
-
* @param decimals - The number of decimal places to round to. Defaults to 2.
|
|
161
|
-
* @returns The rounded number.
|
|
162
|
-
*
|
|
163
|
-
* @example
|
|
164
|
-
* ```typescript
|
|
165
|
-
* roundTo(3.14159, 2) // 3.14
|
|
166
|
-
* roundTo(10.5, 0) // 11
|
|
167
|
-
* ```
|
|
168
|
-
*/
|
|
169
|
-
export declare function roundTo(value: number, decimals?: number): number;
|
|
170
156
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/currency/index.ts"],"names":[],"mappings":"AAgBA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,iBAAiB,GAAI,UAAU,MAAM,KAAG,MAAM,GAAG,SAY7D,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,SAAO,GAAG,MAAM,GAAG,SAAS,CAMnF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAkC1D;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,QAAQ,SAAQ,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAM7F;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,MAAM,GAAG,MAAM,EACtB,QAAQ,SAAQ,EAChB,MAAM,CAAC,EAAE,MAAM,GACb,MAAM,CAQR;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/currency/index.ts"],"names":[],"mappings":"AAgBA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,iBAAiB,GAAI,UAAU,MAAM,KAAG,MAAM,GAAG,SAY7D,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,SAAO,GAAG,MAAM,GAAG,SAAS,CAMnF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAkC1D;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,QAAQ,SAAQ,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAM7F;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,MAAM,GAAG,MAAM,EACtB,QAAQ,SAAQ,EAChB,MAAM,CAAC,EAAE,MAAM,GACb,MAAM,CAQR;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAevD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CA2C9F;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,SAAI,GAAG,MAAM,CAElF;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAGxE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAOrD"}
|
package/dist/currency/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../chunks/chunk-ANN5UYCF.js";var o=null;async function a(){if(o)return o;let{default:r}=await import("./currencies.js");return o=r,r}var l=r=>{try{let
|
|
1
|
+
import"../chunks/chunk-ANN5UYCF.js";var o=null;async function a(){if(o)return o;let{default:r}=await import("./currencies.js");return o=r,r}var l=r=>{try{let e=new Intl.NumberFormat("en",{currency:r,style:"currency"}).formatToParts(0).find(n=>n.type==="currency");return e?.value==="\xA4"?void 0:e?.value}catch{return}};function m(r,e="en"){try{return new Intl.DisplayNames([e],{type:"currency"}).of(r.toUpperCase())}catch{return}}function i(r){return{USD:"en-US",EUR:"de-DE",GBP:"en-GB",JPY:"ja-JP",CNY:"zh-CN",CAD:"en-CA",AUD:"en-AU",CHF:"de-CH",NZD:"en-NZ",SGD:"en-SG",HKD:"zh-HK",KRW:"ko-KR",INR:"en-IN",BRL:"pt-BR",MXN:"es-MX",RUB:"ru-RU",ZAR:"en-ZA",SEK:"sv-SE",NOK:"nb-NO",DKK:"da-DK",PLN:"pl-PL",TRY:"tr-TR",THB:"th-TH",MYR:"ms-MY",PHP:"en-PH",IDR:"id-ID",CZK:"cs-CZ",HUF:"hu-HU",ILS:"he-IL",TWD:"zh-TW"}[r.toUpperCase()]??"en"}function p(r,e="USD",n){let t=n??i(e);return new Intl.NumberFormat(t,{style:"currency",currency:e}).format(Number(r))}function y(r,e="USD",n){let t=n??i(e);return new Intl.NumberFormat(t,{style:"currency",currency:e,notation:"compact",compactDisplay:"short"}).format(Number(r))}function s(r){let e=/\d\.\d{3},\d{2}$/.test(r),n=r;e&&(n=r.replace(/\./g,"").replace(",","."));let t=n.replace(/[^0-9.-]+/g,""),c=Number.parseFloat(t);return Number.isNaN(c)?null:c}function d(r){let e={$:"USD","\u20AC":"EUR","\xA3":"GBP","\xA5":"JPY","\u20B9":"INR","\u20BD":"RUB",R$:"BRL","\u20A9":"KRW","\u0E3F":"THB","\u20AA":"ILS","\u20B1":"PHP","\u20AB":"VND",kr:"SEK",CHF:"CHF",C$:"CAD",A$:"AUD",NZ$:"NZD",HK$:"HKD",S$:"SGD"},n=r.match(/\b([A-Z]{3})\b/);if(n?.[1]){let t=s(r);if(t!==null)return{amount:t,currency:n[1]}}for(let[t,c]of Object.entries(e))if(r.includes(t)){let u=s(r);if(u!==null)return{amount:u,currency:c}}return null}function f(r,e,n=2){return Number.parseFloat((r*e).toFixed(n))}async function g(r){return(await a()).includes(r.toUpperCase())}function C(r){try{return new Intl.NumberFormat("en",{style:"currency",currency:r}),!0}catch{return!1}}export{f as convertCurrency,p as formatPrice,y as formatPriceCompact,i as getCurrencyLocale,m as getCurrencyName,l as getCurrencySymbol,C as isValidCurrency,g as isValidCurrencyCode,d as parseCurrencyString,s as parsePrice};
|
package/dist/date/index.d.ts
CHANGED
|
@@ -1,13 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Returns today's date as a YYYY-MM-DD string.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* today() // '2026-08-11'
|
|
7
|
+
* ```
|
|
3
8
|
*/
|
|
4
9
|
export declare function today(): string;
|
|
5
10
|
/**
|
|
6
11
|
* Returns a Date object from a YYYY-MM-DD string (parsed as local time).
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* parseDate('2026-08-11') // Date for 2026-08-11 00:00:00 local time
|
|
16
|
+
* parseDate('2026-08-11').getFullYear() // 2026
|
|
17
|
+
* ```
|
|
7
18
|
*/
|
|
8
19
|
export declare function parseDate(dateStr: string): Date;
|
|
9
20
|
/**
|
|
10
21
|
* Formats a Date object as YYYY-MM-DD (UTC).
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* formatDate(new Date('2026-08-11T23:30:00Z')) // '2026-08-11'
|
|
26
|
+
* ```
|
|
11
27
|
*/
|
|
12
28
|
export declare function formatDate(date: Date): string;
|
|
13
29
|
/**
|
package/dist/date/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/date/index.ts"],"names":[],"mappings":"AASA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/date/index.ts"],"names":[],"mappings":"AASA;;;;;;;GAOG;AACH,wBAAgB,KAAK,IAAI,MAAM,CAE9B;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE/C;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAE7C;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAE9E;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAE9E;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAEhF;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAGvD;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAI/D;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAE/D;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAInE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAExD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAIpD;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAIlD;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAGtD;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAQ7E;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAEpD;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,GAAG,GAAE,IAAiB,GAAG,MAAM,CAQlF"}
|
package/dist/datetime/index.d.ts
CHANGED
|
@@ -1,19 +1,37 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Returns the current date and time as an ISO string (YYYY-MM-DDTHH:mm:ss.sssZ).
|
|
2
|
+
* Returns the current date and time as an ISO string (`YYYY-MM-DDTHH:mm:ss.sssZ`).
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* nowIso() // '2026-08-11T14:03:27.913Z'
|
|
7
|
+
* ```
|
|
3
8
|
*/
|
|
4
9
|
export declare function nowIso(): string;
|
|
5
10
|
/**
|
|
6
11
|
* Parses an ISO date-time string to a Date object. Returns null if invalid.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* parseIsoDateTime('2026-08-11T14:03:27Z')?.getUTCHours() // 14
|
|
16
|
+
* parseIsoDateTime('not-a-date') // null
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
7
19
|
* @param iso The ISO string.
|
|
8
20
|
*/
|
|
9
21
|
export declare function parseIsoDateTime(iso: string): Date | null;
|
|
10
22
|
/**
|
|
11
|
-
* Formats a Date as YYYY-MM-DD HH:mm:ss (local time).
|
|
23
|
+
* Formats a Date as `YYYY-MM-DD HH:mm:ss` (local time).
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* formatDateTimeLocal(new Date(2026, 7, 11, 9, 5, 3)) // '2026-08-11 09:05:03'
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
12
30
|
* @param date The Date object.
|
|
13
31
|
*/
|
|
14
32
|
export declare function formatDateTimeLocal(date: Date): string;
|
|
15
33
|
/**
|
|
16
|
-
* Returns the timezone offset in minutes for a given date (local
|
|
34
|
+
* Returns the timezone offset in minutes for a given date (local − UTC).
|
|
17
35
|
* @param date The Date object.
|
|
18
36
|
*/
|
|
19
37
|
export declare function getTimezoneOffset(date?: Date): number;
|
|
@@ -30,12 +48,6 @@ export declare function unixTimestamp(): number;
|
|
|
30
48
|
* Returns the number of milliseconds since the Unix epoch.
|
|
31
49
|
*/
|
|
32
50
|
export declare function unixMillis(): number;
|
|
33
|
-
/**
|
|
34
|
-
* Returns the difference in seconds between two Date objects.
|
|
35
|
-
* @param a First date.
|
|
36
|
-
* @param b Second date.
|
|
37
|
-
*/
|
|
38
|
-
export declare function secondsBetween(a: Date, b: Date): number;
|
|
39
51
|
/**
|
|
40
52
|
* Returns the ISO week number (1–53) of a given date using UTC.
|
|
41
53
|
* @param date A JavaScript Date object.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/datetime/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/datetime/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,MAAM,IAAI,MAAM,CAE/B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAGzD;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAMtD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,GAAE,IAAiB,GAAG,MAAM,CAEjE;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAY1C;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAoB7C;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAmBzE"}
|
package/dist/datetime/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../chunks/chunk-ANN5UYCF.js";function i(){return new Date().toISOString()}function c(e){let t=new Date(e);return Number.isNaN(t.getTime())?null:t}function T(e){let t=n=>n.toString().padStart(2,"0");return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())} ${t(e.getHours())}:${t(e.getMinutes())}:${t(e.getSeconds())}`}function l(e=new Date){return e.getTimezoneOffset()}function f(e){return new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()))}function m(){return Math.floor(Date.now()/1e3)}function
|
|
1
|
+
import"../chunks/chunk-ANN5UYCF.js";function i(){return new Date().toISOString()}function c(e){let t=new Date(e);return Number.isNaN(t.getTime())?null:t}function T(e){let t=n=>n.toString().padStart(2,"0");return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())} ${t(e.getHours())}:${t(e.getMinutes())}:${t(e.getSeconds())}`}function l(e=new Date){return e.getTimezoneOffset()}function f(e){return new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()))}function m(){return Math.floor(Date.now()/1e3)}function U(){return Date.now()}function w(e){let t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())),n=t.getUTCDay(),s=n===0?7:n;t.setUTCDate(t.getUTCDate()+4-s);let o=new Date(Date.UTC(t.getUTCFullYear(),0,1)).getUTCDay(),a=o===0?7:o,D=new Date(Date.UTC(t.getUTCFullYear(),0,1+(4-a))),u=t.getTime()-D.getTime();return 1+Math.round(u/(10080*60*1e3))}function C(e){let t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()));t.setUTCDate(t.getUTCDate()+4-(t.getUTCDay()||7));let n=t.getUTCFullYear(),r=new Date(Date.UTC(n,0,1)).getUTCDay()||7,o=new Date(Date.UTC(n,0,1-r+1+(r>4?7:0))),a=t.getTime()-o.getTime();return{week:Math.floor(a/(10080*60*1e3))+1,year:n}}export{T as formatDateTimeLocal,w as getIsoWeek,C as getIsoWeekInfo,l as getTimezoneOffset,i as nowIso,c as parseIsoDateTime,f as toUtcDate,U as unixMillis,m as unixTimestamp};
|
package/dist/emails/index.d.ts
CHANGED
|
@@ -1,17 +1,39 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Validates if a string is a valid email address (simple regex).
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* isValidEmail('user@example.com') // true
|
|
7
|
+
* isValidEmail('user@example') // false
|
|
8
|
+
* isValidEmail('not an email') // false
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
3
11
|
* @param email The email address to validate.
|
|
4
12
|
* @returns True if valid, false otherwise.
|
|
5
13
|
*/
|
|
6
14
|
export declare function isValidEmail(email: string): boolean;
|
|
7
15
|
/**
|
|
8
16
|
* Normalizes an email address by trimming and converting to lowercase.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* normalizeEmail(' User@Example.COM ') // 'user@example.com'
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
9
23
|
* @param email The email address to normalize.
|
|
10
24
|
* @returns The normalized email address.
|
|
11
25
|
*/
|
|
12
26
|
export declare function normalizeEmail(email: string): string;
|
|
13
27
|
/**
|
|
14
28
|
* Masks an email address for privacy (e.g., j***@domain.com).
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* maskEmail('jane@example.com') // 'j***@example.com'
|
|
33
|
+
* maskEmail('a@example.com') // '*@example.com'
|
|
34
|
+
* maskEmail('nope') // 'nope'
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
15
37
|
* @param email The email address to mask.
|
|
16
38
|
* @returns The masked email address.
|
|
17
39
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/emails/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/emails/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAInD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAK/C;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGpD;AAaD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE1D"}
|
package/dist/emails/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../chunks/chunk-ANN5UYCF.js";function e(t){return/^[^\s@]+@[^\s
|
|
1
|
+
import"../chunks/chunk-ANN5UYCF.js";function e(t){return/^[^\s@]+@[^\s@.]+(?:\.[^\s@.]+)+$/.test(t)}function s(t){return t.trim().toLowerCase()}function a(t){let[o,r]=t.split("@");return!o||!r?t:o.length<=1?`*@${r}`:`${o[0]}${"*".repeat(Math.max(1,o.length-1))}@${r}`}function n(t){let o=t.split("@");return o.length===2?o[1]??"":""}var i=["gmail.com","yahoo.com","outlook.com","hotmail.com","icloud.com","aol.com","zoho.com","mail.com"];function m(t){return i.includes(n(t))}export{n as getEmailDomain,m as isFreeEmailProvider,e as isValidEmail,a as maskEmail,s as normalizeEmail};
|
package/dist/env/index.d.ts
CHANGED
|
@@ -2,6 +2,14 @@ import { z } from 'zod';
|
|
|
2
2
|
/**
|
|
3
3
|
* Retrieves the value of an environment variable by its key.
|
|
4
4
|
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* process.env.API_URL = 'https://api.example.com'
|
|
8
|
+
* getENV('API_URL') // 'https://api.example.com'
|
|
9
|
+
* getENV('MISSING', 'fallback') // 'fallback'
|
|
10
|
+
* getENV('MISSING') // throws Error: Undefined ENV variable - MISSING
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
5
13
|
* @param key - The name of the environment variable to retrieve.
|
|
6
14
|
* @param defaultValue - An optional default value to return if the environment variable is not defined.
|
|
7
15
|
* @returns The value of the environment variable if it exists, otherwise the default value if provided.
|
|
@@ -11,12 +19,28 @@ export declare const getENV: (key: string, defaultValue?: string) => string;
|
|
|
11
19
|
/**
|
|
12
20
|
* Determines if the current environment is set to development.
|
|
13
21
|
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* process.env.NODE_ENV = 'development'
|
|
25
|
+
* isDev() // true
|
|
26
|
+
* process.env.NODE_ENV = 'production'
|
|
27
|
+
* isDev() // false
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
14
30
|
* @returns {boolean} `true` if `process.env.NODE_ENV` is `'development'`, otherwise `false`.
|
|
15
31
|
*/
|
|
16
32
|
export declare const isDev: () => boolean;
|
|
17
33
|
/**
|
|
18
34
|
* Determines if the current environment is set to production.
|
|
19
35
|
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* process.env.NODE_ENV = 'production'
|
|
39
|
+
* isProd() // true
|
|
40
|
+
* process.env.NODE_ENV = 'test'
|
|
41
|
+
* isProd() // false
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
20
44
|
* @returns {boolean} `true` if `process.env.NODE_ENV` is `'production'`, otherwise `false`.
|
|
21
45
|
*/
|
|
22
46
|
export declare const isProd: () => boolean;
|
package/dist/env/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/env/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/env/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,MAAM,GAAI,KAAK,MAAM,EAAE,eAAe,MAAM,WAUxD,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,KAAK,QAAO,OAExB,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,MAAM,QAAO,OAEzB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,MAAM,QAAO,OAEzB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,UAAU,QAAO,MAE7B,CAAA;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,CAAC,WAAW,EAC/C,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EACzB,QAAQ,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,oCAc1D;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;iBAI3B,CAAA;AAEF,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA"}
|
package/dist/errors/index.d.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Creates a new Error with a custom name and message.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* const err = createCustomError('NotFoundError', 'user 42 is missing')
|
|
7
|
+
* err.name // 'NotFoundError'
|
|
8
|
+
* err.message // 'user 42 is missing'
|
|
9
|
+
* err instanceof Error // true
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
3
12
|
* @param name The error name.
|
|
4
13
|
* @param message The error message.
|
|
5
14
|
* @returns The custom Error object.
|
|
@@ -7,6 +16,15 @@
|
|
|
7
16
|
export declare function createCustomError(name: string, message: string): Error;
|
|
8
17
|
/**
|
|
9
18
|
* Checks if an error is an instance of a specific error name.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const err = createCustomError('NotFoundError', 'missing')
|
|
23
|
+
* isErrorName(err, 'NotFoundError') // true
|
|
24
|
+
* isErrorName(err, 'TypeError') // false
|
|
25
|
+
* isErrorName('oops', 'TypeError') // false
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
10
28
|
* @param error The error to check.
|
|
11
29
|
* @param name The error name to match.
|
|
12
30
|
* @returns True if the error matches the name, false otherwise.
|
|
@@ -14,6 +32,14 @@ export declare function createCustomError(name: string, message: string): Error;
|
|
|
14
32
|
export declare function isErrorName(error: unknown, name: string): boolean;
|
|
15
33
|
/**
|
|
16
34
|
* Gets the error message from an unknown error value.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* getErrorMessage(new Error('boom')) // 'boom'
|
|
39
|
+
* getErrorMessage('boom') // 'boom'
|
|
40
|
+
* getErrorMessage({ code: 500 }) // '{"code":500}'
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
17
43
|
* @param error The error value.
|
|
18
44
|
* @returns The error message, or a stringified version if not an Error.
|
|
19
45
|
*/
|
|
@@ -32,8 +58,10 @@ export declare function assert(condition: unknown, message: string): asserts con
|
|
|
32
58
|
* @param fallback The fallback value to return on error.
|
|
33
59
|
*
|
|
34
60
|
* @example
|
|
35
|
-
*
|
|
36
|
-
* //
|
|
61
|
+
* ```typescript
|
|
62
|
+
* await tryWithFallback(async () => fetchData(), []) // the data, or [] if it throws
|
|
63
|
+
* await tryWithFallback(() => JSON.parse('{'), {}) // {}
|
|
64
|
+
* ```
|
|
37
65
|
*/
|
|
38
66
|
export declare function tryWithFallback<T>(fn: () => Promise<T> | T, fallback: T): Promise<T>;
|
|
39
67
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,KAAK,CAItE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAEjE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAQtD;AAED;;;;GAIG;AAEH,wBAAgB,MAAM,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAI7E;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,eAAe,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAM1F"}
|