nhb-toolbox 2.8.2 → 2.8.3
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/dist/colors/initials.d.ts +2 -2
- package/dist/colors/initials.d.ts.map +1 -1
- package/dist/guards/non-primitives.d.ts +10 -10
- package/dist/guards/non-primitives.js +10 -10
- package/dist/guards/primitives.d.ts +12 -12
- package/dist/guards/primitives.js +12 -12
- package/dist/guards/specials.d.ts +12 -12
- package/dist/guards/specials.js +12 -12
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ColorInputArray, OpacityValue } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* * Generates a hex color based on the first character (initial) of a string or number.
|
|
4
4
|
*
|
|
@@ -9,7 +9,7 @@ import type { ColorInput, ColorInputArray, OpacityValue } from './types';
|
|
|
9
9
|
* @param opacity - A value from 0 to 100 representing the opacity percentage.
|
|
10
10
|
* @returns A hex color for the first character of the provided string/number.
|
|
11
11
|
*/
|
|
12
|
-
export declare function getColorForInitial(input:
|
|
12
|
+
export declare function getColorForInitial(input: string | number, opacity?: OpacityValue): string;
|
|
13
13
|
/**
|
|
14
14
|
* * Generates an array of hex colors based on the first character (initial) of an array of strings/numbers or even nested arrays of strings/numbers.
|
|
15
15
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initials.d.ts","sourceRoot":"","sources":["../../src/colors/initials.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"initials.d.ts","sourceRoot":"","sources":["../../src/colors/initials.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAc,eAAe,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEzE;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,MAAM,GAAG,MAAM,EACtB,OAAO,CAAC,EAAE,YAAY,GACpB,MAAM,CAAC;AAEV;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,eAAe,EACtB,OAAO,CAAC,EAAE,YAAY,GACpB,MAAM,EAAE,CAAC"}
|
|
@@ -31,62 +31,62 @@ export declare function isDate(value: unknown): value is Date;
|
|
|
31
31
|
*/
|
|
32
32
|
export declare function isObjectWithKeys<T extends Record<string, unknown>>(value: unknown, keys: (keyof T)[]): value is T;
|
|
33
33
|
/**
|
|
34
|
-
* Type guard to check if a value is an empty object.
|
|
34
|
+
* * Type guard to check if a value is an empty object.
|
|
35
35
|
* @param value - The value to check.
|
|
36
36
|
* @returns `true` if the value is an empty object, otherwise `false`.
|
|
37
37
|
*/
|
|
38
38
|
export declare function isEmptyObject(value: unknown): value is Record<string, unknown>;
|
|
39
39
|
/**
|
|
40
|
-
* Type guard to check if a value is an array of a specific type.
|
|
40
|
+
* * Type guard to check if a value is an array of a specific type.
|
|
41
41
|
* @param value - The value to check.
|
|
42
42
|
* @param typeCheck - The type guard function to check each item of the array.
|
|
43
43
|
* @returns `true` if the value is an array of the specified type, otherwise `false`.
|
|
44
44
|
*/
|
|
45
45
|
export declare function isArrayOfType<T>(value: unknown, typeCheck: (item: unknown) => item is T): value is T[];
|
|
46
46
|
/**
|
|
47
|
-
* Type guard to check if a value is a Promise.
|
|
47
|
+
* * Type guard to check if a value is a Promise.
|
|
48
48
|
* @param value - The value to check.
|
|
49
49
|
* @returns `true` if the value is a Promise, otherwise `false`.
|
|
50
50
|
*/
|
|
51
51
|
export declare function isPromise(value: unknown): value is Promise<unknown>;
|
|
52
52
|
/**
|
|
53
|
-
* Type guard to check if a value is a Set.
|
|
53
|
+
* * Type guard to check if a value is a Set.
|
|
54
54
|
* @param value - The value to check.
|
|
55
55
|
* @returns `true` if the value is a Set, otherwise `false`.
|
|
56
56
|
*/
|
|
57
57
|
export declare function isSet<T>(value: unknown): value is Set<T>;
|
|
58
58
|
/**
|
|
59
|
-
* Type guard to check if a value is a Map.
|
|
59
|
+
* * Type guard to check if a value is a Map.
|
|
60
60
|
* @param value - The value to check.
|
|
61
61
|
* @returns `true` if the value is a Map, otherwise `false`.
|
|
62
62
|
*/
|
|
63
63
|
export declare function isMap<K, V>(value: unknown): value is Map<K, V>;
|
|
64
64
|
/**
|
|
65
|
-
* Type guard to check if a value is a RegExp.
|
|
65
|
+
* * Type guard to check if a value is a RegExp.
|
|
66
66
|
* @param value - The value to check.
|
|
67
67
|
* @returns `true` if the value is a RegExp, otherwise `false`.
|
|
68
68
|
*/
|
|
69
69
|
export declare function isRegExp(value: unknown): value is RegExp;
|
|
70
70
|
/**
|
|
71
|
-
* Type guard to check if a value is an Error object.
|
|
71
|
+
* * Type guard to check if a value is an Error object.
|
|
72
72
|
* @param value - The value to check.
|
|
73
73
|
* @returns `true` if the value is an Error object, otherwise `false`.
|
|
74
74
|
*/
|
|
75
75
|
export declare function isError(value: unknown): value is Error;
|
|
76
76
|
/**
|
|
77
|
-
* Type guard to check if a value is a BigInt.
|
|
77
|
+
* * Type guard to check if a value is a BigInt.
|
|
78
78
|
* @param value - The value to check.
|
|
79
79
|
* @returns `true` if the value is a BigInt, otherwise `false`.
|
|
80
80
|
*/
|
|
81
81
|
export declare function isBigInt(value: unknown): value is bigint;
|
|
82
82
|
/**
|
|
83
|
-
* Type guard to check if a string is valid JSON.
|
|
83
|
+
* * Type guard to check if a string is valid JSON.
|
|
84
84
|
* @param value - The value to check.
|
|
85
85
|
* @returns `true` if the value is valid JSON, otherwise `false`.
|
|
86
86
|
*/
|
|
87
87
|
export declare function isJSON(value: unknown): value is string;
|
|
88
88
|
/**
|
|
89
|
-
* Type guard to check if a function returns a Promise.
|
|
89
|
+
* * Type guard to check if a function returns a Promise.
|
|
90
90
|
* @param fn - The function to check.
|
|
91
91
|
* @returns `true` if the function returns a Promise, otherwise `false`.
|
|
92
92
|
*/
|
|
@@ -41,7 +41,7 @@ export function isObjectWithKeys(value, keys) {
|
|
|
41
41
|
return isObject(value) && keys.every((key) => key in value);
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
|
-
* Type guard to check if a value is an empty object.
|
|
44
|
+
* * Type guard to check if a value is an empty object.
|
|
45
45
|
* @param value - The value to check.
|
|
46
46
|
* @returns `true` if the value is an empty object, otherwise `false`.
|
|
47
47
|
*/
|
|
@@ -49,7 +49,7 @@ export function isEmptyObject(value) {
|
|
|
49
49
|
return isObject(value) && Object.keys(value).length === 0;
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
52
|
-
* Type guard to check if a value is an array of a specific type.
|
|
52
|
+
* * Type guard to check if a value is an array of a specific type.
|
|
53
53
|
* @param value - The value to check.
|
|
54
54
|
* @param typeCheck - The type guard function to check each item of the array.
|
|
55
55
|
* @returns `true` if the value is an array of the specified type, otherwise `false`.
|
|
@@ -58,7 +58,7 @@ export function isArrayOfType(value, typeCheck) {
|
|
|
58
58
|
return isArray(value) && value.every(typeCheck);
|
|
59
59
|
}
|
|
60
60
|
/**
|
|
61
|
-
* Type guard to check if a value is a Promise.
|
|
61
|
+
* * Type guard to check if a value is a Promise.
|
|
62
62
|
* @param value - The value to check.
|
|
63
63
|
* @returns `true` if the value is a Promise, otherwise `false`.
|
|
64
64
|
*/
|
|
@@ -66,7 +66,7 @@ export function isPromise(value) {
|
|
|
66
66
|
return isObject(value) && isFunction(value.then);
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
69
|
-
* Type guard to check if a value is a Set.
|
|
69
|
+
* * Type guard to check if a value is a Set.
|
|
70
70
|
* @param value - The value to check.
|
|
71
71
|
* @returns `true` if the value is a Set, otherwise `false`.
|
|
72
72
|
*/
|
|
@@ -74,7 +74,7 @@ export function isSet(value) {
|
|
|
74
74
|
return value instanceof Set;
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
77
|
-
* Type guard to check if a value is a Map.
|
|
77
|
+
* * Type guard to check if a value is a Map.
|
|
78
78
|
* @param value - The value to check.
|
|
79
79
|
* @returns `true` if the value is a Map, otherwise `false`.
|
|
80
80
|
*/
|
|
@@ -82,7 +82,7 @@ export function isMap(value) {
|
|
|
82
82
|
return value instanceof Map;
|
|
83
83
|
}
|
|
84
84
|
/**
|
|
85
|
-
* Type guard to check if a value is a RegExp.
|
|
85
|
+
* * Type guard to check if a value is a RegExp.
|
|
86
86
|
* @param value - The value to check.
|
|
87
87
|
* @returns `true` if the value is a RegExp, otherwise `false`.
|
|
88
88
|
*/
|
|
@@ -90,7 +90,7 @@ export function isRegExp(value) {
|
|
|
90
90
|
return value instanceof RegExp;
|
|
91
91
|
}
|
|
92
92
|
/**
|
|
93
|
-
* Type guard to check if a value is an Error object.
|
|
93
|
+
* * Type guard to check if a value is an Error object.
|
|
94
94
|
* @param value - The value to check.
|
|
95
95
|
* @returns `true` if the value is an Error object, otherwise `false`.
|
|
96
96
|
*/
|
|
@@ -98,7 +98,7 @@ export function isError(value) {
|
|
|
98
98
|
return value instanceof Error;
|
|
99
99
|
}
|
|
100
100
|
/**
|
|
101
|
-
* Type guard to check if a value is a BigInt.
|
|
101
|
+
* * Type guard to check if a value is a BigInt.
|
|
102
102
|
* @param value - The value to check.
|
|
103
103
|
* @returns `true` if the value is a BigInt, otherwise `false`.
|
|
104
104
|
*/
|
|
@@ -106,7 +106,7 @@ export function isBigInt(value) {
|
|
|
106
106
|
return typeof value === 'bigint';
|
|
107
107
|
}
|
|
108
108
|
/**
|
|
109
|
-
* Type guard to check if a string is valid JSON.
|
|
109
|
+
* * Type guard to check if a string is valid JSON.
|
|
110
110
|
* @param value - The value to check.
|
|
111
111
|
* @returns `true` if the value is valid JSON, otherwise `false`.
|
|
112
112
|
*/
|
|
@@ -122,7 +122,7 @@ export function isJSON(value) {
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
/**
|
|
125
|
-
* Type guard to check if a function returns a Promise.
|
|
125
|
+
* * Type guard to check if a function returns a Promise.
|
|
126
126
|
* @param fn - The function to check.
|
|
127
127
|
* @returns `true` if the function returns a Promise, otherwise `false`.
|
|
128
128
|
*/
|
|
@@ -1,72 +1,72 @@
|
|
|
1
1
|
import type { FalsyPrimitive } from '../types';
|
|
2
2
|
/**
|
|
3
|
-
* Type guard to check if a value is a number.
|
|
3
|
+
* * Type guard to check if a value is a number.
|
|
4
4
|
* @param value - The value to check.
|
|
5
5
|
* @returns `true` if the value is a number, otherwise `false`.
|
|
6
6
|
*/
|
|
7
7
|
export declare function isNumber(value: unknown): value is number;
|
|
8
8
|
/**
|
|
9
|
-
* Type guard to check if a value is a string.
|
|
9
|
+
* * Type guard to check if a value is a string.
|
|
10
10
|
* @param value - The value to check.
|
|
11
11
|
* @returns `true` if the value is a string, otherwise `false`.
|
|
12
12
|
*/
|
|
13
13
|
export declare function isString(value: unknown): value is string;
|
|
14
14
|
/**
|
|
15
|
-
* Type guard to check if a value is an integer.
|
|
15
|
+
* * Type guard to check if a value is an integer.
|
|
16
16
|
* @param value - The value to check.
|
|
17
17
|
* @returns `true` if the value is an integer, otherwise `false`.
|
|
18
18
|
*/
|
|
19
19
|
export declare function isInteger(value: unknown): value is number;
|
|
20
20
|
/**
|
|
21
|
-
* Type guard to check if a value is a positive integer.
|
|
21
|
+
* * Type guard to check if a value is a positive integer.
|
|
22
22
|
* @param value - The value to check.
|
|
23
23
|
* @returns `true` if the value is a positive integer, otherwise `false`.
|
|
24
24
|
*/
|
|
25
25
|
export declare function isPositiveInteger(value: unknown): value is number;
|
|
26
26
|
/**
|
|
27
|
-
* Type guard to check if a value is a boolean.
|
|
27
|
+
* * Type guard to check if a value is a boolean.
|
|
28
28
|
* @param value - The value to check.
|
|
29
29
|
* @returns `true` if the value is a boolean, otherwise `false`.
|
|
30
30
|
*/
|
|
31
31
|
export declare function isBoolean(value: unknown): value is boolean;
|
|
32
32
|
/**
|
|
33
|
-
* Type guard to check if a value is null.
|
|
33
|
+
* * Type guard to check if a value is null.
|
|
34
34
|
* @param value - The value to check.
|
|
35
35
|
* @returns `true` if the value is null, otherwise `false`.
|
|
36
36
|
*/
|
|
37
37
|
export declare function isNull(value: unknown): value is null;
|
|
38
38
|
/**
|
|
39
|
-
* Type guard to check if a value is undefined.
|
|
39
|
+
* * Type guard to check if a value is undefined.
|
|
40
40
|
* @param value - The value to check.
|
|
41
41
|
* @returns `true` if the value is undefined, otherwise `false`.
|
|
42
42
|
*/
|
|
43
43
|
export declare function isUndefined(value: unknown): value is undefined;
|
|
44
44
|
/**
|
|
45
|
-
* Type guard to check if a value is a symbol.
|
|
45
|
+
* * Type guard to check if a value is a symbol.
|
|
46
46
|
* @param value - The value to check.
|
|
47
47
|
* @returns `true` if the value is a symbol, otherwise `false`.
|
|
48
48
|
*/
|
|
49
49
|
export declare function isSymbol(value: unknown): value is symbol;
|
|
50
50
|
/**
|
|
51
|
-
* Type guard to check if a value is a primitive.
|
|
51
|
+
* * Type guard to check if a value is a primitive.
|
|
52
52
|
* @param value - The value to check.
|
|
53
53
|
* @returns `true` if the value is a primitive, otherwise `false`.
|
|
54
54
|
*/
|
|
55
55
|
export declare function isPrimitive(value: unknown): value is string | number | boolean | symbol | null | undefined;
|
|
56
56
|
/**
|
|
57
|
-
* Type guard to check if a value is a non-empty string.
|
|
57
|
+
* * Type guard to check if a value is a non-empty string.
|
|
58
58
|
* @param value - The value to check.
|
|
59
59
|
* @returns `true` if the value is a non-empty string, otherwise `false`.
|
|
60
60
|
*/
|
|
61
61
|
export declare function isNonEmptyString(value: unknown): value is string;
|
|
62
62
|
/**
|
|
63
|
-
* Type guard to check if a value is falsy.
|
|
63
|
+
* * Type guard to check if a value is falsy.
|
|
64
64
|
* @param value - The value to check.
|
|
65
65
|
* @returns `true` if the value is falsy, otherwise `false`.
|
|
66
66
|
*/
|
|
67
67
|
export declare function isFalsy(value: unknown): value is FalsyPrimitive;
|
|
68
68
|
/**
|
|
69
|
-
* Type guard to check if a value is truthy.
|
|
69
|
+
* * Type guard to check if a value is truthy.
|
|
70
70
|
* @param value - The value to check.
|
|
71
71
|
* @returns `true` if the value is truthy (not null or undefined), otherwise `false`.
|
|
72
72
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Type guard to check if a value is a number.
|
|
2
|
+
* * Type guard to check if a value is a number.
|
|
3
3
|
* @param value - The value to check.
|
|
4
4
|
* @returns `true` if the value is a number, otherwise `false`.
|
|
5
5
|
*/
|
|
@@ -7,7 +7,7 @@ export function isNumber(value) {
|
|
|
7
7
|
return typeof value === 'number' && !isNaN(value);
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
|
-
* Type guard to check if a value is a string.
|
|
10
|
+
* * Type guard to check if a value is a string.
|
|
11
11
|
* @param value - The value to check.
|
|
12
12
|
* @returns `true` if the value is a string, otherwise `false`.
|
|
13
13
|
*/
|
|
@@ -15,7 +15,7 @@ export function isString(value) {
|
|
|
15
15
|
return typeof value === 'string';
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
-
* Type guard to check if a value is an integer.
|
|
18
|
+
* * Type guard to check if a value is an integer.
|
|
19
19
|
* @param value - The value to check.
|
|
20
20
|
* @returns `true` if the value is an integer, otherwise `false`.
|
|
21
21
|
*/
|
|
@@ -23,7 +23,7 @@ export function isInteger(value) {
|
|
|
23
23
|
return isNumber(value) && Number.isInteger(value);
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
|
-
* Type guard to check if a value is a positive integer.
|
|
26
|
+
* * Type guard to check if a value is a positive integer.
|
|
27
27
|
* @param value - The value to check.
|
|
28
28
|
* @returns `true` if the value is a positive integer, otherwise `false`.
|
|
29
29
|
*/
|
|
@@ -31,7 +31,7 @@ export function isPositiveInteger(value) {
|
|
|
31
31
|
return isInteger(value) && value > 0;
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
|
-
* Type guard to check if a value is a boolean.
|
|
34
|
+
* * Type guard to check if a value is a boolean.
|
|
35
35
|
* @param value - The value to check.
|
|
36
36
|
* @returns `true` if the value is a boolean, otherwise `false`.
|
|
37
37
|
*/
|
|
@@ -39,7 +39,7 @@ export function isBoolean(value) {
|
|
|
39
39
|
return typeof value === 'boolean';
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
|
-
* Type guard to check if a value is null.
|
|
42
|
+
* * Type guard to check if a value is null.
|
|
43
43
|
* @param value - The value to check.
|
|
44
44
|
* @returns `true` if the value is null, otherwise `false`.
|
|
45
45
|
*/
|
|
@@ -47,7 +47,7 @@ export function isNull(value) {
|
|
|
47
47
|
return value === null;
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
|
-
* Type guard to check if a value is undefined.
|
|
50
|
+
* * Type guard to check if a value is undefined.
|
|
51
51
|
* @param value - The value to check.
|
|
52
52
|
* @returns `true` if the value is undefined, otherwise `false`.
|
|
53
53
|
*/
|
|
@@ -55,7 +55,7 @@ export function isUndefined(value) {
|
|
|
55
55
|
return value === undefined;
|
|
56
56
|
}
|
|
57
57
|
/**
|
|
58
|
-
* Type guard to check if a value is a symbol.
|
|
58
|
+
* * Type guard to check if a value is a symbol.
|
|
59
59
|
* @param value - The value to check.
|
|
60
60
|
* @returns `true` if the value is a symbol, otherwise `false`.
|
|
61
61
|
*/
|
|
@@ -63,7 +63,7 @@ export function isSymbol(value) {
|
|
|
63
63
|
return typeof value === 'symbol';
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
66
|
-
* Type guard to check if a value is a primitive.
|
|
66
|
+
* * Type guard to check if a value is a primitive.
|
|
67
67
|
* @param value - The value to check.
|
|
68
68
|
* @returns `true` if the value is a primitive, otherwise `false`.
|
|
69
69
|
*/
|
|
@@ -72,7 +72,7 @@ export function isPrimitive(value) {
|
|
|
72
72
|
['string', 'number', 'boolean', 'symbol', 'undefined'].includes(typeof value));
|
|
73
73
|
}
|
|
74
74
|
/**
|
|
75
|
-
* Type guard to check if a value is a non-empty string.
|
|
75
|
+
* * Type guard to check if a value is a non-empty string.
|
|
76
76
|
* @param value - The value to check.
|
|
77
77
|
* @returns `true` if the value is a non-empty string, otherwise `false`.
|
|
78
78
|
*/
|
|
@@ -80,7 +80,7 @@ export function isNonEmptyString(value) {
|
|
|
80
80
|
return isString(value) && value?.trim().length > 0;
|
|
81
81
|
}
|
|
82
82
|
/**
|
|
83
|
-
* Type guard to check if a value is falsy.
|
|
83
|
+
* * Type guard to check if a value is falsy.
|
|
84
84
|
* @param value - The value to check.
|
|
85
85
|
* @returns `true` if the value is falsy, otherwise `false`.
|
|
86
86
|
*/
|
|
@@ -88,7 +88,7 @@ export function isFalsy(value) {
|
|
|
88
88
|
return !value;
|
|
89
89
|
}
|
|
90
90
|
/**
|
|
91
|
-
* Type guard to check if a value is truthy.
|
|
91
|
+
* * Type guard to check if a value is truthy.
|
|
92
92
|
* @param value - The value to check.
|
|
93
93
|
* @returns `true` if the value is truthy (not null or undefined), otherwise `false`.
|
|
94
94
|
*/
|
|
@@ -1,69 +1,69 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Type guard to check if a value is a valid email string.
|
|
2
|
+
* * Type guard to check if a value is a valid email string.
|
|
3
3
|
* @param value - The value to check.
|
|
4
4
|
* @returns `true` if the value is a valid email, otherwise `false`.
|
|
5
5
|
*/
|
|
6
6
|
export declare function isEmail(value: unknown): value is string;
|
|
7
7
|
/**
|
|
8
|
-
* Type guard to check if a value is an array of valid email strings.
|
|
8
|
+
* * Type guard to check if a value is an array of valid email strings.
|
|
9
9
|
* @param value - The value to check.
|
|
10
10
|
* @returns `true` if the value is an array of valid email strings, otherwise `false`.
|
|
11
11
|
*/
|
|
12
12
|
export declare function isEmailArray(value: unknown): value is string[];
|
|
13
13
|
/**
|
|
14
|
-
* Type guard to check if a value is a valid date string.
|
|
14
|
+
* * Type guard to check if a value is a valid date string.
|
|
15
15
|
* @param value - The value to check.
|
|
16
16
|
* @returns `true` if the value is a valid date string, otherwise `false`.
|
|
17
17
|
*/
|
|
18
18
|
export declare function isDateString(value: unknown): value is string;
|
|
19
19
|
/**
|
|
20
|
-
* Type guard to check if a value is a valid UUID (v4).
|
|
20
|
+
* * Type guard to check if a value is a valid UUID (v4).
|
|
21
21
|
* @param value - The value to check.
|
|
22
22
|
* @returns `true` if the value is a valid UUID, otherwise `false`.
|
|
23
23
|
*/
|
|
24
24
|
export declare function isUUID(value: unknown): value is string;
|
|
25
25
|
/**
|
|
26
|
-
* Type guard to check if the code is running in a browser environment.
|
|
26
|
+
* * Type guard to check if the code is running in a browser environment.
|
|
27
27
|
* @returns `true` if the code is running in a browser, otherwise `false`.
|
|
28
28
|
*/
|
|
29
29
|
export declare function isBrowser(): boolean;
|
|
30
30
|
/**
|
|
31
|
-
* Type guard to check if the code is running in a Node.js environment.
|
|
31
|
+
* * Type guard to check if the code is running in a Node.js environment.
|
|
32
32
|
* @returns `true` if the code is running in Node.js, otherwise `false`.
|
|
33
33
|
*/
|
|
34
34
|
export declare function isNode(): boolean;
|
|
35
35
|
/**
|
|
36
|
-
* Type guard to check if a value is a valid URL.
|
|
36
|
+
* * Type guard to check if a value is a valid URL.
|
|
37
37
|
* @param value - The value to check.
|
|
38
38
|
* @returns `true` if the value is a valid URL, otherwise `false`.
|
|
39
39
|
*/
|
|
40
40
|
export declare function isURL(value: unknown): value is string;
|
|
41
41
|
/**
|
|
42
|
-
* Type guard to check if a value is a valid Base64 encoded string.
|
|
42
|
+
* * Type guard to check if a value is a valid Base64 encoded string.
|
|
43
43
|
* @param value - The value to check.
|
|
44
44
|
* @returns `true` if the value is a valid Base64 string, otherwise `false`.
|
|
45
45
|
*/
|
|
46
46
|
export declare function isBase64(value: unknown): value is string;
|
|
47
47
|
/**
|
|
48
|
-
* Type guard to check if a value is a valid phone number.
|
|
48
|
+
* * Type guard to check if a value is a valid phone number.
|
|
49
49
|
* @param value - The value to check.
|
|
50
50
|
* @returns `true` if the value is a valid phone number, otherwise `false`.
|
|
51
51
|
*/
|
|
52
52
|
export declare function isPhoneNumber(value: unknown): value is string;
|
|
53
53
|
/**
|
|
54
|
-
* Type guard to check if a value is a valid IP address (IPv4 or IPv6).
|
|
54
|
+
* * Type guard to check if a value is a valid IP address (IPv4 or IPv6).
|
|
55
55
|
* @param value - The value to check.
|
|
56
56
|
* @returns `true` if the value is a valid IP address, otherwise `false`.
|
|
57
57
|
*/
|
|
58
58
|
export declare function isIPAddress(value: unknown): value is string;
|
|
59
59
|
/**
|
|
60
|
-
* Type guard to check if the current environment matches a given string.
|
|
60
|
+
* * Type guard to check if the current environment matches a given string.
|
|
61
61
|
* @param env - The expected environment (e.g., "production", "development").
|
|
62
62
|
* @returns `true` if the current environment matches, otherwise `false`.
|
|
63
63
|
*/
|
|
64
64
|
export declare function isEnvironment(env: string): boolean;
|
|
65
65
|
/**
|
|
66
|
-
* Type guard to check if a value is a numeric string.
|
|
66
|
+
* * Type guard to check if a value is a numeric string.
|
|
67
67
|
* @param value - The value to check.
|
|
68
68
|
* @returns `true` if the value is a numeric string, otherwise `false`.
|
|
69
69
|
*/
|
package/dist/guards/specials.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isArray } from './non-primitives';
|
|
2
2
|
import { isString } from './primitives';
|
|
3
3
|
/**
|
|
4
|
-
* Type guard to check if a value is a valid email string.
|
|
4
|
+
* * Type guard to check if a value is a valid email string.
|
|
5
5
|
* @param value - The value to check.
|
|
6
6
|
* @returns `true` if the value is a valid email, otherwise `false`.
|
|
7
7
|
*/
|
|
@@ -10,7 +10,7 @@ export function isEmail(value) {
|
|
|
10
10
|
/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(value));
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
|
-
* Type guard to check if a value is an array of valid email strings.
|
|
13
|
+
* * Type guard to check if a value is an array of valid email strings.
|
|
14
14
|
* @param value - The value to check.
|
|
15
15
|
* @returns `true` if the value is an array of valid email strings, otherwise `false`.
|
|
16
16
|
*/
|
|
@@ -18,7 +18,7 @@ export function isEmailArray(value) {
|
|
|
18
18
|
return isArray(value) && value.every(isEmail);
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
|
-
* Type guard to check if a value is a valid date string.
|
|
21
|
+
* * Type guard to check if a value is a valid date string.
|
|
22
22
|
* @param value - The value to check.
|
|
23
23
|
* @returns `true` if the value is a valid date string, otherwise `false`.
|
|
24
24
|
*/
|
|
@@ -26,7 +26,7 @@ export function isDateString(value) {
|
|
|
26
26
|
return isString(value) && !isNaN(Date.parse(value));
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
|
-
* Type guard to check if a value is a valid UUID (v4).
|
|
29
|
+
* * Type guard to check if a value is a valid UUID (v4).
|
|
30
30
|
* @param value - The value to check.
|
|
31
31
|
* @returns `true` if the value is a valid UUID, otherwise `false`.
|
|
32
32
|
*/
|
|
@@ -35,14 +35,14 @@ export function isUUID(value) {
|
|
|
35
35
|
/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value));
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
|
-
* Type guard to check if the code is running in a browser environment.
|
|
38
|
+
* * Type guard to check if the code is running in a browser environment.
|
|
39
39
|
* @returns `true` if the code is running in a browser, otherwise `false`.
|
|
40
40
|
*/
|
|
41
41
|
export function isBrowser() {
|
|
42
42
|
return typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
|
-
* Type guard to check if the code is running in a Node.js environment.
|
|
45
|
+
* * Type guard to check if the code is running in a Node.js environment.
|
|
46
46
|
* @returns `true` if the code is running in Node.js, otherwise `false`.
|
|
47
47
|
*/
|
|
48
48
|
export function isNode() {
|
|
@@ -51,7 +51,7 @@ export function isNode() {
|
|
|
51
51
|
process.versions.node != null);
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
|
-
* Type guard to check if a value is a valid URL.
|
|
54
|
+
* * Type guard to check if a value is a valid URL.
|
|
55
55
|
* @param value - The value to check.
|
|
56
56
|
* @returns `true` if the value is a valid URL, otherwise `false`.
|
|
57
57
|
*/
|
|
@@ -65,7 +65,7 @@ export function isURL(value) {
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
68
|
-
* Type guard to check if a value is a valid Base64 encoded string.
|
|
68
|
+
* * Type guard to check if a value is a valid Base64 encoded string.
|
|
69
69
|
* @param value - The value to check.
|
|
70
70
|
* @returns `true` if the value is a valid Base64 string, otherwise `false`.
|
|
71
71
|
*/
|
|
@@ -74,7 +74,7 @@ export function isBase64(value) {
|
|
|
74
74
|
/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(value));
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
77
|
-
* Type guard to check if a value is a valid phone number.
|
|
77
|
+
* * Type guard to check if a value is a valid phone number.
|
|
78
78
|
* @param value - The value to check.
|
|
79
79
|
* @returns `true` if the value is a valid phone number, otherwise `false`.
|
|
80
80
|
*/
|
|
@@ -82,7 +82,7 @@ export function isPhoneNumber(value) {
|
|
|
82
82
|
return isString(value) && /^\+?[1-9]\d{1,14}$/.test(value);
|
|
83
83
|
}
|
|
84
84
|
/**
|
|
85
|
-
* Type guard to check if a value is a valid IP address (IPv4 or IPv6).
|
|
85
|
+
* * Type guard to check if a value is a valid IP address (IPv4 or IPv6).
|
|
86
86
|
* @param value - The value to check.
|
|
87
87
|
* @returns `true` if the value is a valid IP address, otherwise `false`.
|
|
88
88
|
*/
|
|
@@ -91,7 +91,7 @@ export function isIPAddress(value) {
|
|
|
91
91
|
/^(?:\d{1,3}\.){3}\d{1,3}$|^([a-f0-9:]+:+)+[a-f0-9]+$/i.test(value));
|
|
92
92
|
}
|
|
93
93
|
/**
|
|
94
|
-
* Type guard to check if the current environment matches a given string.
|
|
94
|
+
* * Type guard to check if the current environment matches a given string.
|
|
95
95
|
* @param env - The expected environment (e.g., "production", "development").
|
|
96
96
|
* @returns `true` if the current environment matches, otherwise `false`.
|
|
97
97
|
*/
|
|
@@ -99,7 +99,7 @@ export function isEnvironment(env) {
|
|
|
99
99
|
return process.env.NODE_ENV === env;
|
|
100
100
|
}
|
|
101
101
|
/**
|
|
102
|
-
* Type guard to check if a value is a numeric string.
|
|
102
|
+
* * Type guard to check if a value is a numeric string.
|
|
103
103
|
* @param value - The value to check.
|
|
104
104
|
* @returns `true` if the value is a numeric string, otherwise `false`.
|
|
105
105
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { generateAnagrams } from './string/anagram';
|
|
|
3
3
|
export { convertStringCase, replaceAllInString } from './string/convert';
|
|
4
4
|
export { calculateHCF as calculateGCD, calculateHCF, calculateLCM as calculateLCD, calculateLCM, convertToDecimal, getRandomNumber, isEven, isEven as isEvenNumber, isMultiple, isOdd, isOdd as isOddNumber, } from './number/basics';
|
|
5
5
|
export { numberToWords } from './number/convert';
|
|
6
|
-
export { findPrimeNumbers, isPrime } from './number/prime';
|
|
6
|
+
export { findPrimeNumbers, isPrime, isPrime as isPrimeNumber, } from './number/prime';
|
|
7
7
|
export { getNumbersInRange } from './number/range';
|
|
8
8
|
export { getColorForInitial } from './colors/initials';
|
|
9
9
|
export { generateRandomColorInHexRGB, generateRandomHSLColor, } from './colors/random';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACN,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,cAAc,GACd,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAGzE,OAAO,EACN,YAAY,IAAI,YAAY,EAC5B,YAAY,EACZ,YAAY,IAAI,YAAY,EAC5B,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,MAAM,EACN,MAAM,IAAI,YAAY,EACtB,UAAU,EACV,KAAK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tB,KAAK,EACL,aAAa,IAAI,aAAa,EAC9B,gBAAgB,EAChB,SAAS,EACT,QAAQ,EACR,QAAQ,IAAI,mBAAmB,EAC/B,kBAAkB,EAClB,KAAK,EACL,MAAM,IAAI,WAAW,EACrB,KAAK,IAAI,UAAU,EACnB,QAAQ,IAAI,aAAa,EACzB,KAAK,IAAI,UAAU,GACnB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EACN,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,OAAO,EACP,YAAY,EACZ,aAAa,EACb,aAAa,IAAI,iBAAiB,EAClC,WAAW,EACX,MAAM,EACN,aAAa,IAAI,SAAS,EAC1B,aAAa,IAAI,iBAAiB,EAClC,eAAe,EACf,aAAa,EACb,KAAK,EACL,MAAM,EACN,OAAO,IAAI,YAAY,EACvB,KAAK,IAAI,UAAU,GACnB,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ export { convertStringCase, replaceAllInString } from './string/convert';
|
|
|
5
5
|
// ! Number Utilities
|
|
6
6
|
export { calculateHCF as calculateGCD, calculateHCF, calculateLCM as calculateLCD, calculateLCM, convertToDecimal, getRandomNumber, isEven, isEven as isEvenNumber, isMultiple, isOdd, isOdd as isOddNumber, } from './number/basics';
|
|
7
7
|
export { numberToWords } from './number/convert';
|
|
8
|
-
export { findPrimeNumbers, isPrime } from './number/prime';
|
|
8
|
+
export { findPrimeNumbers, isPrime, isPrime as isPrimeNumber, } from './number/prime';
|
|
9
9
|
export { getNumbersInRange } from './number/range';
|
|
10
10
|
// ! Color Utilities
|
|
11
11
|
export { getColorForInitial } from './colors/initials';
|
package/package.json
CHANGED