@rtorcato/js-common 2.0.0 → 2.1.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/CHANGELOG.md +14 -0
- package/README.md +24 -0
- 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/boolean/index.d.ts +41 -0
- package/dist/boolean/index.d.ts.map +1 -0
- 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/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/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/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/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [2.1.0](https://github.com/rtorcato/js-common/compare/v2.0.1...v2.1.0) (2026-06-11)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **docs:** full API reference via TypeDoc ([337eb2c](https://github.com/rtorcato/js-common/commit/337eb2c43122685a5fa8321865112800e67c404c))
|
|
7
|
+
|
|
8
|
+
## [2.0.1](https://github.com/rtorcato/js-common/compare/v2.0.0...v2.0.1) (2026-06-10)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **build:** ship .d.ts files in published tarball ([946cd8a](https://github.com/rtorcato/js-common/commit/946cd8a27ba52923cbcf857d996f52590d9008d5))
|
|
14
|
+
|
|
1
15
|
# [2.0.0](https://github.com/rtorcato/js-common/compare/v1.8.1...v2.0.0) (2026-06-01)
|
|
2
16
|
|
|
3
17
|
|
package/README.md
CHANGED
|
@@ -27,6 +27,30 @@ A comprehensive set of common JavaScript and TypeScript utilities for Node.js pr
|
|
|
27
27
|
npm install @rtorcato/js-common
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
+
## Migrating from 1.x to 2.x
|
|
31
|
+
|
|
32
|
+
The only breaking change in 2.0 is a rename in the `errors` module:
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
// 1.x — swallow errors and fall back to a default value
|
|
36
|
+
import { tryCatch } from '@rtorcato/js-common/errors'
|
|
37
|
+
const data = await tryCatch(() => fetchData(), [])
|
|
38
|
+
|
|
39
|
+
// 2.x — same function, renamed for clarity
|
|
40
|
+
import { tryWithFallback } from '@rtorcato/js-common/errors'
|
|
41
|
+
const data = await tryWithFallback(() => fetchData(), [])
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
The name `tryCatch` is now reserved for the Result-pattern helper in `@rtorcato/js-common/try`, which returns `{ data, error }` instead of swallowing:
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
import { tryCatch } from '@rtorcato/js-common/try'
|
|
48
|
+
const { data, error } = await tryCatch(() => fetchData())
|
|
49
|
+
if (error) { /* handle */ }
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Prefer the Result-style `tryCatch` for new code; reserve `tryWithFallback` for cases where the fallback is genuinely safe.
|
|
53
|
+
|
|
30
54
|
## CLI Usage
|
|
31
55
|
|
|
32
56
|
This package includes a command-line interface for many utilities:
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a new AbortController and returns its controller and signal.
|
|
3
|
+
* @returns {{ controller: AbortController, signal: AbortSignal }}
|
|
4
|
+
*/
|
|
5
|
+
export declare function createAbortController(): {
|
|
6
|
+
controller: AbortController;
|
|
7
|
+
signal: AbortSignal;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Returns a promise that rejects when the given AbortSignal is aborted.
|
|
11
|
+
* @param signal The AbortSignal to listen to.
|
|
12
|
+
* @returns {Promise<never>}
|
|
13
|
+
*/
|
|
14
|
+
export declare function abortPromise(signal: AbortSignal): Promise<never>;
|
|
15
|
+
/**
|
|
16
|
+
* Wraps a promise and rejects it if the signal is aborted.
|
|
17
|
+
* @param promise The promise to wrap.
|
|
18
|
+
* @param signal The AbortSignal.
|
|
19
|
+
* @returns {Promise<T>}
|
|
20
|
+
*/
|
|
21
|
+
export declare function withAbort<T>(promise: Promise<T>, signal: AbortSignal): Promise<T>;
|
|
22
|
+
/**
|
|
23
|
+
* Aborts the given controller after a timeout (ms).
|
|
24
|
+
* @param controller The AbortController.
|
|
25
|
+
* @param ms Timeout in milliseconds.
|
|
26
|
+
* @returns {NodeJS.Timeout | number} The timeout ID.
|
|
27
|
+
*/
|
|
28
|
+
export declare function abortAfter(controller: AbortController, ms: number): ReturnType<typeof setTimeout>;
|
|
29
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/abortController/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,qBAAqB;;;EAGpC;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC,CAchE;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CAEjF;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,UAAU,EAAE,eAAe,EAAE,EAAE,EAAE,MAAM,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAEjG"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the first element of an array, or undefined if the array is empty.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* first([1, 2, 3]) // 1
|
|
7
|
+
* first([]) // undefined
|
|
8
|
+
* first(['a', 'b']) // 'a'
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* @param arr The array to get the first element from
|
|
12
|
+
* @returns The first element or undefined if array is empty
|
|
13
|
+
* @category Array Utilities
|
|
14
|
+
*/
|
|
15
|
+
export declare function first<T>(arr: T[]): T | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Returns the last element of an array, or undefined if the array is empty.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* last([1, 2, 3]) // 3
|
|
22
|
+
* last([]) // undefined
|
|
23
|
+
* last(['a', 'b']) // 'b'
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @param arr The array to get the last element from
|
|
27
|
+
* @returns The last element or undefined if array is empty
|
|
28
|
+
* @category Array Utilities
|
|
29
|
+
*/
|
|
30
|
+
export declare function last<T>(arr: T[]): T | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Removes duplicate values from an array while preserving order.
|
|
33
|
+
* Uses Set for O(n) performance with primitive values.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* unique([1, 2, 2, 3, 1]) // [1, 2, 3]
|
|
38
|
+
* unique(['a', 'b', 'a']) // ['a', 'b']
|
|
39
|
+
* unique([{id: 1}, {id: 2}, {id: 1}]) // [{id: 1}, {id: 2}, {id: 1}] (objects by reference)
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @param arr The array to remove duplicates from
|
|
43
|
+
* @returns A new array with unique values
|
|
44
|
+
* @category Array Utilities
|
|
45
|
+
*/
|
|
46
|
+
export declare function unique<T>(arr: T[]): T[];
|
|
47
|
+
/**
|
|
48
|
+
* Flattens an array one level deep.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* flatten([[1, 2], [3, 4]]) // [1, 2, 3, 4]
|
|
53
|
+
* flatten([1, [2, 3], 4]) // [1, 2, 3, 4]
|
|
54
|
+
* flatten([[1, [2]], [3]]) // [1, [2], 3] (only one level deep)
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* @param arr The array to flatten
|
|
58
|
+
* @returns A new flattened array
|
|
59
|
+
* @category Array Utilities
|
|
60
|
+
*/
|
|
61
|
+
export declare function flatten<T>(arr: readonly (T | T[])[]): T[];
|
|
62
|
+
/**
|
|
63
|
+
* Chunks an array into smaller arrays of a specified size.
|
|
64
|
+
* The last chunk may be smaller if the array length is not evenly divisible.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```typescript
|
|
68
|
+
* chunk([1, 2, 3, 4, 5], 2) // [[1, 2], [3, 4], [5]]
|
|
69
|
+
* chunk(['a', 'b', 'c'], 2) // [['a', 'b'], ['c']]
|
|
70
|
+
* chunk([1, 2, 3], 5) // [[1, 2, 3]]
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* @param arr The array to chunk
|
|
74
|
+
* @param size The size of each chunk (must be positive)
|
|
75
|
+
* @returns An array of chunks
|
|
76
|
+
* @throws {Error} When size is less than 1
|
|
77
|
+
* @category Array Utilities
|
|
78
|
+
*/
|
|
79
|
+
export declare function chunk<T>(arr: T[], size: number): T[][];
|
|
80
|
+
/**
|
|
81
|
+
* Removes all falsy values from an array.
|
|
82
|
+
* Falsy values: false, 0, -0, 0n, "", null, undefined, NaN
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```typescript
|
|
86
|
+
* compact([0, 1, false, 2, '', 3, null, undefined, NaN]) // [1, 2, 3]
|
|
87
|
+
* compact(['', 'hello', 0, 'world']) // ['hello', 'world']
|
|
88
|
+
* compact([true, false, 1, 0]) // [true, 1]
|
|
89
|
+
* ```
|
|
90
|
+
*
|
|
91
|
+
* @param arr The array to filter
|
|
92
|
+
* @returns A new array with only truthy values
|
|
93
|
+
* @category Array Utilities
|
|
94
|
+
*/
|
|
95
|
+
export declare function compact<T>(arr: T[]): T[];
|
|
96
|
+
/**
|
|
97
|
+
* Shuffles an array using the Fisher-Yates algorithm.
|
|
98
|
+
* Returns a new array without modifying the original.
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```typescript
|
|
102
|
+
* shuffle([1, 2, 3, 4, 5]) // [3, 1, 5, 2, 4] (random order)
|
|
103
|
+
* shuffle(['a', 'b', 'c']) // ['c', 'a', 'b'] (random order)
|
|
104
|
+
*
|
|
105
|
+
* // Original array is unchanged
|
|
106
|
+
* const original = [1, 2, 3]
|
|
107
|
+
* const shuffled = shuffle(original)
|
|
108
|
+
* console.log(original) // [1, 2, 3]
|
|
109
|
+
* ```
|
|
110
|
+
*
|
|
111
|
+
* @param arr The array to shuffle
|
|
112
|
+
* @returns A new shuffled array
|
|
113
|
+
* @category Array Utilities
|
|
114
|
+
*/
|
|
115
|
+
export declare function shuffle<T>(arr: T[]): T[];
|
|
116
|
+
/**
|
|
117
|
+
* Groups array elements by a key derived from each element.
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```typescript
|
|
121
|
+
* groupBy([1, 2, 3, 4], n => n % 2 === 0 ? 'even' : 'odd')
|
|
122
|
+
* // { odd: [1, 3], even: [2, 4] }
|
|
123
|
+
*
|
|
124
|
+
* groupBy([{ type: 'a' }, { type: 'b' }, { type: 'a' }], x => x.type)
|
|
125
|
+
* // { a: [{ type: 'a' }, { type: 'a' }], b: [{ type: 'b' }] }
|
|
126
|
+
* ```
|
|
127
|
+
*
|
|
128
|
+
* @param arr The array to group
|
|
129
|
+
* @param fn Function that returns the group key for each element
|
|
130
|
+
* @returns An object mapping keys to arrays of elements
|
|
131
|
+
* @category Array Utilities
|
|
132
|
+
*/
|
|
133
|
+
export declare function groupBy<T>(arr: T[], fn: (item: T) => string | number): Record<string | number, T[]>;
|
|
134
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/arrays/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,SAAS,CAEhD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,SAAS,CAE/C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAEvC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAEzD;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,EAAE,EAAE,CAOtD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAExC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAOxC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,OAAO,CAAC,CAAC,EACxB,GAAG,EAAE,CAAC,EAAE,EACR,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAAG,MAAM,GAC9B,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,CAAC,CAO9B"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a value to a boolean.
|
|
3
|
+
* Accepts 'true', '1', 1 as true; 'false', '0', 0 as false.
|
|
4
|
+
* @param value The value to convert.
|
|
5
|
+
* @returns The boolean representation.
|
|
6
|
+
*/
|
|
7
|
+
export declare function toBoolean(value: unknown): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Checks if a value is a boolean.
|
|
10
|
+
* @param value The value to check.
|
|
11
|
+
* @returns True if the value is a boolean, false otherwise.
|
|
12
|
+
*/
|
|
13
|
+
export declare function isBoolean(value: unknown): value is boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Returns the logical exclusive OR (XOR) of two booleans.
|
|
16
|
+
* @param a First boolean.
|
|
17
|
+
* @param b Second boolean.
|
|
18
|
+
* @returns True if exactly one of a or b is true.
|
|
19
|
+
*/
|
|
20
|
+
export declare function xor(a: boolean, b: boolean): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Logical AND for two booleans.
|
|
23
|
+
* @param a First boolean.
|
|
24
|
+
* @param b Second boolean.
|
|
25
|
+
* @returns True if both a and b are true.
|
|
26
|
+
*/
|
|
27
|
+
export declare function and(a: boolean, b: boolean): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Logical OR for two booleans.
|
|
30
|
+
* @param a First boolean.
|
|
31
|
+
* @param b Second boolean.
|
|
32
|
+
* @returns True if either a or b is true.
|
|
33
|
+
*/
|
|
34
|
+
export declare function or(a: boolean, b: boolean): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Logical NOT for a boolean.
|
|
37
|
+
* @param a The boolean to negate.
|
|
38
|
+
* @returns The negated boolean.
|
|
39
|
+
*/
|
|
40
|
+
export declare function not(a: boolean): boolean;
|
|
41
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/boolean/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAWjD;AAED;;;;GAIG;AAEH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,CAE1D;AAED;;;;;GAKG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAEnD;AAED;;;;;GAKG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAEnD;AAED;;;;;GAKG;AACH,wBAAgB,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAElD;AAED;;;;GAIG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAEvC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates a random hex color string.
|
|
3
|
+
*
|
|
4
|
+
* @returns {string} A string representing a random color in hexadecimal format (e.g., `#a1b2c3`).
|
|
5
|
+
*/
|
|
6
|
+
export declare function randomColor(): string;
|
|
7
|
+
/**
|
|
8
|
+
* Generates a random color with a given alpha value.
|
|
9
|
+
*
|
|
10
|
+
* @export
|
|
11
|
+
* @param {string} color
|
|
12
|
+
* @return {*}
|
|
13
|
+
*/
|
|
14
|
+
export declare function matchingTextColor(color: string): "#000" | "#fff";
|
|
15
|
+
/**
|
|
16
|
+
* Converts a hex color string to an RGB object.
|
|
17
|
+
*
|
|
18
|
+
* @export
|
|
19
|
+
* @param {string} hex
|
|
20
|
+
* @return {*} {({ r: number; g: number; b: number } | null)}
|
|
21
|
+
*/
|
|
22
|
+
export declare function hexToRgb(hex: string): {
|
|
23
|
+
r: number;
|
|
24
|
+
g: number;
|
|
25
|
+
b: number;
|
|
26
|
+
} | null;
|
|
27
|
+
/**
|
|
28
|
+
* Converts RGB values to a hex color string.
|
|
29
|
+
*
|
|
30
|
+
* @export
|
|
31
|
+
* @param {number} r
|
|
32
|
+
* @param {number} g
|
|
33
|
+
* @param {number} b
|
|
34
|
+
* @return {*} {string}
|
|
35
|
+
*/
|
|
36
|
+
export declare function rgbToHex(r: number, g: number, b: number): string;
|
|
37
|
+
/**
|
|
38
|
+
* Converts a hex color string to an HSL object.
|
|
39
|
+
*
|
|
40
|
+
* @export
|
|
41
|
+
* @param {string} hex
|
|
42
|
+
* @return {*} {({ h: number; s: number; l: number } | null)}
|
|
43
|
+
*/
|
|
44
|
+
export declare function isValidHex(hex: string): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Darkens a hex color by a given percentage.
|
|
47
|
+
*
|
|
48
|
+
* @export
|
|
49
|
+
* @param {string} hex
|
|
50
|
+
* @param {number} percent
|
|
51
|
+
* @return {*} {string}
|
|
52
|
+
*/
|
|
53
|
+
export declare function darken(hex: string, percent: number): string;
|
|
54
|
+
/**
|
|
55
|
+
* Lightens a hex color by a given percentage.
|
|
56
|
+
*
|
|
57
|
+
* @export
|
|
58
|
+
* @param {string} hex
|
|
59
|
+
* @param {number} percent
|
|
60
|
+
* @return {*} {string}
|
|
61
|
+
*/
|
|
62
|
+
export declare function lighten(hex: string, percent: number): string;
|
|
63
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/colors/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAKpC;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,mBAO9C;AAED;;;;;;GAMG;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"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Console utility functions for logging and disabling console output in production.
|
|
3
|
+
* @module console
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Disables console output in production environment.
|
|
7
|
+
*/
|
|
8
|
+
export declare const disableConsole: () => void;
|
|
9
|
+
/**
|
|
10
|
+
* Clears the console.
|
|
11
|
+
*
|
|
12
|
+
* @export
|
|
13
|
+
* @return {*} {void}
|
|
14
|
+
*/
|
|
15
|
+
export declare const clearConsole: () => void;
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/console/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,eAAO,MAAM,cAAc,YAK1B,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,YAAY,QAAO,IAE/B,CAAA"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hashes a string using the specified algorithm.
|
|
3
|
+
* @param str The string to hash.
|
|
4
|
+
* @param algorithm The hash algorithm (default: 'sha256').
|
|
5
|
+
* @returns The hex-encoded hash.
|
|
6
|
+
*/
|
|
7
|
+
export declare function hashString(str: string, algorithm?: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* Generates a random hex string of the specified length (in bytes).
|
|
10
|
+
* @param length The number of bytes (not hex chars).
|
|
11
|
+
* @returns A random hex string.
|
|
12
|
+
*/
|
|
13
|
+
export declare function randomHex(length?: number): string;
|
|
14
|
+
/**
|
|
15
|
+
* Creates an HMAC hash of a string using a secret and algorithm.
|
|
16
|
+
* @param str The string to hash.
|
|
17
|
+
* @param secret The secret key.
|
|
18
|
+
* @param algorithm The hash algorithm (default: 'sha256').
|
|
19
|
+
* @returns The hex-encoded HMAC.
|
|
20
|
+
*/
|
|
21
|
+
export declare function hmacHash(str: string, secret: string, algorithm?: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* Encodes a string to base64.
|
|
24
|
+
* @param str The string to encode.
|
|
25
|
+
* @returns The base64-encoded string.
|
|
26
|
+
*/
|
|
27
|
+
export declare function base64Encode(str: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* Decodes a base64 string.
|
|
30
|
+
* @param b64 The base64 string to decode.
|
|
31
|
+
* @returns The decoded string.
|
|
32
|
+
*/
|
|
33
|
+
export declare function base64Decode(b64: string): string;
|
|
34
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/crypto/index.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,SAAW,GAAG,MAAM,CAEpE;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,MAAM,SAAK,GAAG,MAAM,CAE7C;AAED;;;;;;GAMG;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"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* List of supported currency codes.
|
|
3
|
+
*
|
|
4
|
+
* This array contains ISO 4217 currency codes and some special codes
|
|
5
|
+
* (such as precious metals and testing codes) used in financial applications.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* - Some codes represent fiat currencies (e.g., 'USD', 'EUR').
|
|
9
|
+
* - Some codes represent precious metals (e.g., 'XAU' for gold).
|
|
10
|
+
* - Some codes are reserved for testing or special purposes (e.g., 'XTS', 'XXX').
|
|
11
|
+
*
|
|
12
|
+
* @see {@link https://www.iso.org/iso-4217-currency-codes.html ISO 4217 Currency Codes}
|
|
13
|
+
*/
|
|
14
|
+
export declare const currencies: string[];
|
|
15
|
+
export default currencies;
|
|
16
|
+
//# sourceMappingURL=currencies.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"currencies.d.ts","sourceRoot":"","sources":["../../src/currency/currencies.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,UAAU,UA4CtB,CAAA;AAED,eAAe,UAAU,CAAA"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the currency symbol for a given ISO 4217 currency code.
|
|
3
|
+
*
|
|
4
|
+
* Utilizes the `Intl.NumberFormat` API to format a number as currency and extract the symbol.
|
|
5
|
+
*
|
|
6
|
+
* @param currency - The ISO 4217 currency code (e.g., 'USD', 'EUR', 'JPY').
|
|
7
|
+
* @returns The currency symbol as a string (e.g., '$', '€', '¥'), or `undefined` if the symbol cannot be determined.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* getCurrencySymbol('USD') // '$'
|
|
12
|
+
* getCurrencySymbol('EUR') // '€'
|
|
13
|
+
* getCurrencySymbol('JPY') // '¥'
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare const getCurrencySymbol: (currency: string) => string | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Returns the full display name of a currency.
|
|
19
|
+
*
|
|
20
|
+
* @param currency - The ISO 4217 currency code (e.g., 'USD', 'EUR').
|
|
21
|
+
* @param locale - The locale to use for the display name. Defaults to 'en'.
|
|
22
|
+
* @returns The full currency name (e.g., 'US Dollar'), or `undefined` if invalid.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* getCurrencyName('USD') // 'US Dollar'
|
|
27
|
+
* getCurrencyName('EUR') // 'Euro'
|
|
28
|
+
* getCurrencyName('JPY', 'ja') // '日本円'
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function getCurrencyName(currency: string, locale?: string): string | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Returns the default locale typically associated with a currency.
|
|
34
|
+
*
|
|
35
|
+
* @param currency - The ISO 4217 currency code.
|
|
36
|
+
* @returns The locale string (e.g., 'en-US' for USD), or 'en' as fallback.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* getCurrencyLocale('USD') // 'en-US'
|
|
41
|
+
* getCurrencyLocale('EUR') // 'de-DE'
|
|
42
|
+
* getCurrencyLocale('JPY') // 'ja-JP'
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare function getCurrencyLocale(currency: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* Formats a given price value into a localized currency string.
|
|
48
|
+
*
|
|
49
|
+
* @param price - The numeric value or string representation of the price to format.
|
|
50
|
+
* @param currency - The ISO 4217 currency code. Defaults to 'USD'.
|
|
51
|
+
* @param locale - The locale to use for formatting. If not provided, uses the currency's default locale.
|
|
52
|
+
* @returns The formatted currency string.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* formatPrice(1234.56, 'USD') // '$1,234.56'
|
|
57
|
+
* formatPrice(1234.56, 'EUR') // '1.234,56 €'
|
|
58
|
+
* formatPrice(1234.56, 'JPY') // '¥1,235'
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export declare function formatPrice(price: number | string, currency?: string, locale?: string): string;
|
|
62
|
+
/**
|
|
63
|
+
* Formats a price in compact notation (e.g., $1.2K, $1.5M).
|
|
64
|
+
*
|
|
65
|
+
* @param price - The numeric value to format.
|
|
66
|
+
* @param currency - The ISO 4217 currency code. Defaults to 'USD'.
|
|
67
|
+
* @param locale - The locale to use for formatting.
|
|
68
|
+
* @returns The formatted compact currency string.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* formatPriceCompact(1234) // '$1.2K'
|
|
73
|
+
* formatPriceCompact(1234567) // '$1.2M'
|
|
74
|
+
* formatPriceCompact(1234567890) // '$1.2B'
|
|
75
|
+
* formatPriceCompact(1500, 'EUR') // '1,5 Tsd. €'
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export declare function formatPriceCompact(price: number | string, currency?: string, locale?: string): string;
|
|
79
|
+
/**
|
|
80
|
+
* Parses a given price string and returns its numeric value.
|
|
81
|
+
*
|
|
82
|
+
* @param value - The price string to parse.
|
|
83
|
+
* @returns The numeric value of the price, or `null` if the value cannot be parsed.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```typescript
|
|
87
|
+
* parsePrice('$1,234.56') // 1234.56
|
|
88
|
+
* parsePrice('€1.234,56') // 1234.56
|
|
89
|
+
* parsePrice('invalid') // null
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
export declare function parsePrice(value: string): number | null;
|
|
93
|
+
/**
|
|
94
|
+
* Parses a currency string and extracts both the amount and currency code.
|
|
95
|
+
*
|
|
96
|
+
* @param value - The currency string to parse (e.g., '$1,234.56', 'EUR 100').
|
|
97
|
+
* @returns An object with `amount` and `currency`, or `null` if parsing fails.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```typescript
|
|
101
|
+
* parseCurrencyString('$1,234.56') // { amount: 1234.56, currency: 'USD' }
|
|
102
|
+
* parseCurrencyString('€100') // { amount: 100, currency: 'EUR' }
|
|
103
|
+
* parseCurrencyString('1000 JPY') // { amount: 1000, currency: 'JPY' }
|
|
104
|
+
* parseCurrencyString('invalid') // null
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
export declare function parseCurrencyString(value: string): {
|
|
108
|
+
amount: number;
|
|
109
|
+
currency: string;
|
|
110
|
+
} | null;
|
|
111
|
+
/**
|
|
112
|
+
* Converts a given amount from one currency to another using the provided exchange rate.
|
|
113
|
+
*
|
|
114
|
+
* @param amount - The amount of money to convert.
|
|
115
|
+
* @param rate - The exchange rate to use for the conversion.
|
|
116
|
+
* @param decimals - The number of decimal places to include in the result. Defaults to 2.
|
|
117
|
+
* @returns The converted amount as a number.
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```typescript
|
|
121
|
+
* convertCurrency(100, 0.85) // 85 (e.g., USD to EUR)
|
|
122
|
+
* convertCurrency(100, 110.5, 0) // 11050 (e.g., USD to JPY)
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
export declare function convertCurrency(amount: number, rate: number, decimals?: number): number;
|
|
126
|
+
/**
|
|
127
|
+
* Checks if the provided currency code is valid.
|
|
128
|
+
*
|
|
129
|
+
* This function lazily loads the currencies list to minimize bundle size impact.
|
|
130
|
+
*
|
|
131
|
+
* @param code - The currency code to validate (e.g., 'USD', 'eur').
|
|
132
|
+
* @returns Promise resolving to `true` if the currency code is valid; otherwise, `false`.
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* ```typescript
|
|
136
|
+
* await isValidCurrencyCode('USD') // true
|
|
137
|
+
* await isValidCurrencyCode('INVALID') // false
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
export declare function isValidCurrencyCode(code: string): Promise<boolean>;
|
|
141
|
+
/**
|
|
142
|
+
* Synchronously checks if a currency code is valid using the Intl API.
|
|
143
|
+
*
|
|
144
|
+
* This does not require loading the currencies list and has zero bundle size impact.
|
|
145
|
+
*
|
|
146
|
+
* @param code - The currency code to validate.
|
|
147
|
+
* @returns `true` if the currency code is valid; otherwise, `false`.
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```typescript
|
|
151
|
+
* isValidCurrency('USD') // true
|
|
152
|
+
* isValidCurrency('INVALID') // false
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
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
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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,CAavD;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;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,SAAI,GAAG,MAAM,CAG3D"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns today's date as a YYYY-MM-DD string.
|
|
3
|
+
* @returns {string}
|
|
4
|
+
*/
|
|
5
|
+
export declare function today(): string;
|
|
6
|
+
/**
|
|
7
|
+
* Returns a Date object from a YYYY-MM-DD string.
|
|
8
|
+
* @param dateStr The date string.
|
|
9
|
+
* @returns {Date}
|
|
10
|
+
*/
|
|
11
|
+
export declare function parseDate(dateStr: string): Date;
|
|
12
|
+
/**
|
|
13
|
+
* Formats a Date object as YYYY-MM-DD.
|
|
14
|
+
* @param date The Date object.
|
|
15
|
+
* @returns {string}
|
|
16
|
+
*/
|
|
17
|
+
export declare function formatDate(date: Date): string;
|
|
18
|
+
/**
|
|
19
|
+
* Returns the difference in days between two dates (date2 - date1).
|
|
20
|
+
* @param date1 The first date (string or Date).
|
|
21
|
+
* @param date2 The second date (string or Date).
|
|
22
|
+
* @returns {number}
|
|
23
|
+
*/
|
|
24
|
+
export declare function daysBetween(date1: string | Date, date2: string | Date): number;
|
|
25
|
+
/**
|
|
26
|
+
* Checks if a year is a leap year.
|
|
27
|
+
* @param year The year (number or Date).
|
|
28
|
+
* @returns {boolean}
|
|
29
|
+
*/
|
|
30
|
+
export declare function isLeapYear(year: number | Date): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Adds days to a date and returns a new Date object.
|
|
33
|
+
* @param date The date (string or Date).
|
|
34
|
+
* @param days Number of days to add.
|
|
35
|
+
* @returns {Date}
|
|
36
|
+
*/
|
|
37
|
+
export declare function addDays(date: string | Date, days: number): Date;
|
|
38
|
+
/**
|
|
39
|
+
* Returns the day of the week for a date (0=Sunday, 6=Saturday).
|
|
40
|
+
* @param date The date (string or Date).
|
|
41
|
+
* @returns {number}
|
|
42
|
+
*/
|
|
43
|
+
export declare function getDayOfWeek(date: string | Date): number;
|
|
44
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/date/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,KAAK,IAAI,MAAM,CAG9B;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE/C;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAE7C;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAI9E;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAGvD;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAI/D;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAGxD"}
|