nhb-toolbox 2.7.5 → 2.8.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/dist/guards/non-primitives.d.ts +94 -0
- package/dist/guards/non-primitives.d.ts.map +1 -0
- package/dist/guards/non-primitives.js +148 -0
- package/dist/guards/primitives.d.ts +74 -0
- package/dist/guards/primitives.d.ts.map +1 -0
- package/dist/guards/primitives.js +111 -0
- package/dist/guards/specials.d.ts +71 -0
- package/dist/guards/specials.d.ts.map +1 -0
- package/dist/guards/specials.js +122 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +58 -1
- package/dist/types/index.d.ts +9 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/index.d.ts +3 -3
- package/dist/utils/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { AsyncFunction, GenericFn } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Type guard to check if a value is an array.
|
|
4
|
+
* @param value - The value to check.
|
|
5
|
+
* @returns `true` if the value is an array, otherwise `false`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function isArray<T>(value: unknown): value is Array<T>;
|
|
8
|
+
/**
|
|
9
|
+
* Type guard to check if a value is an object (excluding null).
|
|
10
|
+
* @param value - The value to check.
|
|
11
|
+
* @returns `true` if the value is an object, otherwise `false`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function isObject(value: unknown): value is Record<string, unknown>;
|
|
14
|
+
/**
|
|
15
|
+
* Type guard to check if a value is a function.
|
|
16
|
+
* @param value - The value to check.
|
|
17
|
+
* @returns `true` if the value is a function, otherwise `false`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function isFunction(value: unknown): value is GenericFn;
|
|
20
|
+
/**
|
|
21
|
+
* Type guard to check if a value is a Date object.
|
|
22
|
+
* @param value - The value to check.
|
|
23
|
+
* @returns `true` if the value is a Date object, otherwise `false`.
|
|
24
|
+
*/
|
|
25
|
+
export declare function isDate(value: unknown): value is Date;
|
|
26
|
+
/**
|
|
27
|
+
* Type guard to check if a value is an object with specific keys.
|
|
28
|
+
* @param value - The value to check.
|
|
29
|
+
* @param keys - The set of keys the object should contain.
|
|
30
|
+
* @returns `true` if the value is an object with the specified keys, otherwise `false`.
|
|
31
|
+
*/
|
|
32
|
+
export declare function isObjectWithKeys<T extends Record<string, unknown>>(value: unknown, keys: (keyof T)[]): value is T;
|
|
33
|
+
/**
|
|
34
|
+
* Type guard to check if a value is an empty object.
|
|
35
|
+
* @param value - The value to check.
|
|
36
|
+
* @returns `true` if the value is an empty object, otherwise `false`.
|
|
37
|
+
*/
|
|
38
|
+
export declare function isEmptyObject(value: unknown): value is Record<string, unknown>;
|
|
39
|
+
/**
|
|
40
|
+
* Type guard to check if a value is an array of a specific type.
|
|
41
|
+
* @param value - The value to check.
|
|
42
|
+
* @param typeCheck - The type guard function to check each item of the array.
|
|
43
|
+
* @returns `true` if the value is an array of the specified type, otherwise `false`.
|
|
44
|
+
*/
|
|
45
|
+
export declare function isArrayOfType<T>(value: unknown, typeCheck: (item: unknown) => item is T): value is T[];
|
|
46
|
+
/**
|
|
47
|
+
* Type guard to check if a value is a Promise.
|
|
48
|
+
* @param value - The value to check.
|
|
49
|
+
* @returns `true` if the value is a Promise, otherwise `false`.
|
|
50
|
+
*/
|
|
51
|
+
export declare function isPromise(value: unknown): value is Promise<unknown>;
|
|
52
|
+
/**
|
|
53
|
+
* Type guard to check if a value is a Set.
|
|
54
|
+
* @param value - The value to check.
|
|
55
|
+
* @returns `true` if the value is a Set, otherwise `false`.
|
|
56
|
+
*/
|
|
57
|
+
export declare function isSet<T>(value: unknown): value is Set<T>;
|
|
58
|
+
/**
|
|
59
|
+
* Type guard to check if a value is a Map.
|
|
60
|
+
* @param value - The value to check.
|
|
61
|
+
* @returns `true` if the value is a Map, otherwise `false`.
|
|
62
|
+
*/
|
|
63
|
+
export declare function isMap<K, V>(value: unknown): value is Map<K, V>;
|
|
64
|
+
/**
|
|
65
|
+
* Type guard to check if a value is a RegExp.
|
|
66
|
+
* @param value - The value to check.
|
|
67
|
+
* @returns `true` if the value is a RegExp, otherwise `false`.
|
|
68
|
+
*/
|
|
69
|
+
export declare function isRegExp(value: unknown): value is RegExp;
|
|
70
|
+
/**
|
|
71
|
+
* Type guard to check if a value is an Error object.
|
|
72
|
+
* @param value - The value to check.
|
|
73
|
+
* @returns `true` if the value is an Error object, otherwise `false`.
|
|
74
|
+
*/
|
|
75
|
+
export declare function isError(value: unknown): value is Error;
|
|
76
|
+
/**
|
|
77
|
+
* Type guard to check if a value is a BigInt.
|
|
78
|
+
* @param value - The value to check.
|
|
79
|
+
* @returns `true` if the value is a BigInt, otherwise `false`.
|
|
80
|
+
*/
|
|
81
|
+
export declare function isBigInt(value: unknown): value is bigint;
|
|
82
|
+
/**
|
|
83
|
+
* Type guard to check if a string is valid JSON.
|
|
84
|
+
* @param value - The value to check.
|
|
85
|
+
* @returns `true` if the value is valid JSON, otherwise `false`.
|
|
86
|
+
*/
|
|
87
|
+
export declare function isJSON(value: unknown): value is string;
|
|
88
|
+
/**
|
|
89
|
+
* Type guard to check if a function returns a Promise.
|
|
90
|
+
* @param fn - The function to check.
|
|
91
|
+
* @returns `true` if the function returns a Promise, otherwise `false`.
|
|
92
|
+
*/
|
|
93
|
+
export declare function isReturningPromise<T>(fn: unknown): fn is AsyncFunction<T>;
|
|
94
|
+
//# sourceMappingURL=non-primitives.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"non-primitives.d.ts","sourceRoot":"","sources":["../../src/guards/non-primitives.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAGzD;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC,CAE5D;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M,CAExD;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,KAAK,CAEtD;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAExD;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAStD;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,EAAE,EAAE,OAAO,GAAG,EAAE,IAAI,aAAa,CAAC,CAAC,CAAC,CAEzE"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isArray = isArray;
|
|
4
|
+
exports.isObject = isObject;
|
|
5
|
+
exports.isFunction = isFunction;
|
|
6
|
+
exports.isDate = isDate;
|
|
7
|
+
exports.isObjectWithKeys = isObjectWithKeys;
|
|
8
|
+
exports.isEmptyObject = isEmptyObject;
|
|
9
|
+
exports.isArrayOfType = isArrayOfType;
|
|
10
|
+
exports.isPromise = isPromise;
|
|
11
|
+
exports.isSet = isSet;
|
|
12
|
+
exports.isMap = isMap;
|
|
13
|
+
exports.isRegExp = isRegExp;
|
|
14
|
+
exports.isError = isError;
|
|
15
|
+
exports.isBigInt = isBigInt;
|
|
16
|
+
exports.isJSON = isJSON;
|
|
17
|
+
exports.isReturningPromise = isReturningPromise;
|
|
18
|
+
const primitives_1 = require("./primitives");
|
|
19
|
+
/**
|
|
20
|
+
* Type guard to check if a value is an array.
|
|
21
|
+
* @param value - The value to check.
|
|
22
|
+
* @returns `true` if the value is an array, otherwise `false`.
|
|
23
|
+
*/
|
|
24
|
+
function isArray(value) {
|
|
25
|
+
return Array.isArray(value);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Type guard to check if a value is an object (excluding null).
|
|
29
|
+
* @param value - The value to check.
|
|
30
|
+
* @returns `true` if the value is an object, otherwise `false`.
|
|
31
|
+
*/
|
|
32
|
+
function isObject(value) {
|
|
33
|
+
return value !== null && typeof value === 'object' && !isArray(value);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Type guard to check if a value is a function.
|
|
37
|
+
* @param value - The value to check.
|
|
38
|
+
* @returns `true` if the value is a function, otherwise `false`.
|
|
39
|
+
*/
|
|
40
|
+
function isFunction(value) {
|
|
41
|
+
return typeof value === 'function';
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Type guard to check if a value is a Date object.
|
|
45
|
+
* @param value - The value to check.
|
|
46
|
+
* @returns `true` if the value is a Date object, otherwise `false`.
|
|
47
|
+
*/
|
|
48
|
+
function isDate(value) {
|
|
49
|
+
return value instanceof Date;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Type guard to check if a value is an object with specific keys.
|
|
53
|
+
* @param value - The value to check.
|
|
54
|
+
* @param keys - The set of keys the object should contain.
|
|
55
|
+
* @returns `true` if the value is an object with the specified keys, otherwise `false`.
|
|
56
|
+
*/
|
|
57
|
+
function isObjectWithKeys(value, keys) {
|
|
58
|
+
return isObject(value) && keys.every((key) => key in value);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Type guard to check if a value is an empty object.
|
|
62
|
+
* @param value - The value to check.
|
|
63
|
+
* @returns `true` if the value is an empty object, otherwise `false`.
|
|
64
|
+
*/
|
|
65
|
+
function isEmptyObject(value) {
|
|
66
|
+
return isObject(value) && Object.keys(value).length === 0;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Type guard to check if a value is an array of a specific type.
|
|
70
|
+
* @param value - The value to check.
|
|
71
|
+
* @param typeCheck - The type guard function to check each item of the array.
|
|
72
|
+
* @returns `true` if the value is an array of the specified type, otherwise `false`.
|
|
73
|
+
*/
|
|
74
|
+
function isArrayOfType(value, typeCheck) {
|
|
75
|
+
return isArray(value) && value.every(typeCheck);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Type guard to check if a value is a Promise.
|
|
79
|
+
* @param value - The value to check.
|
|
80
|
+
* @returns `true` if the value is a Promise, otherwise `false`.
|
|
81
|
+
*/
|
|
82
|
+
function isPromise(value) {
|
|
83
|
+
return isObject(value) && isFunction(value.then);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Type guard to check if a value is a Set.
|
|
87
|
+
* @param value - The value to check.
|
|
88
|
+
* @returns `true` if the value is a Set, otherwise `false`.
|
|
89
|
+
*/
|
|
90
|
+
function isSet(value) {
|
|
91
|
+
return value instanceof Set;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Type guard to check if a value is a Map.
|
|
95
|
+
* @param value - The value to check.
|
|
96
|
+
* @returns `true` if the value is a Map, otherwise `false`.
|
|
97
|
+
*/
|
|
98
|
+
function isMap(value) {
|
|
99
|
+
return value instanceof Map;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Type guard to check if a value is a RegExp.
|
|
103
|
+
* @param value - The value to check.
|
|
104
|
+
* @returns `true` if the value is a RegExp, otherwise `false`.
|
|
105
|
+
*/
|
|
106
|
+
function isRegExp(value) {
|
|
107
|
+
return value instanceof RegExp;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Type guard to check if a value is an Error object.
|
|
111
|
+
* @param value - The value to check.
|
|
112
|
+
* @returns `true` if the value is an Error object, otherwise `false`.
|
|
113
|
+
*/
|
|
114
|
+
function isError(value) {
|
|
115
|
+
return value instanceof Error;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Type guard to check if a value is a BigInt.
|
|
119
|
+
* @param value - The value to check.
|
|
120
|
+
* @returns `true` if the value is a BigInt, otherwise `false`.
|
|
121
|
+
*/
|
|
122
|
+
function isBigInt(value) {
|
|
123
|
+
return typeof value === 'bigint';
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Type guard to check if a string is valid JSON.
|
|
127
|
+
* @param value - The value to check.
|
|
128
|
+
* @returns `true` if the value is valid JSON, otherwise `false`.
|
|
129
|
+
*/
|
|
130
|
+
function isJSON(value) {
|
|
131
|
+
if (!(0, primitives_1.isString)(value))
|
|
132
|
+
return false;
|
|
133
|
+
try {
|
|
134
|
+
JSON.parse(value);
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Type guard to check if a function returns a Promise.
|
|
143
|
+
* @param fn - The function to check.
|
|
144
|
+
* @returns `true` if the function returns a Promise, otherwise `false`.
|
|
145
|
+
*/
|
|
146
|
+
function isReturningPromise(fn) {
|
|
147
|
+
return isFunction(fn) && fn.constructor.name === 'AsyncFunction';
|
|
148
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { FalsyPrimitive } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Type guard to check if a value is a number.
|
|
4
|
+
* @param value - The value to check.
|
|
5
|
+
* @returns `true` if the value is a number, otherwise `false`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function isNumber(value: unknown): value is number;
|
|
8
|
+
/**
|
|
9
|
+
* Type guard to check if a value is a string.
|
|
10
|
+
* @param value - The value to check.
|
|
11
|
+
* @returns `true` if the value is a string, otherwise `false`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function isString(value: unknown): value is string;
|
|
14
|
+
/**
|
|
15
|
+
* Type guard to check if a value is an integer.
|
|
16
|
+
* @param value - The value to check.
|
|
17
|
+
* @returns `true` if the value is an integer, otherwise `false`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function isInteger(value: unknown): value is number;
|
|
20
|
+
/**
|
|
21
|
+
* Type guard to check if a value is a positive integer.
|
|
22
|
+
* @param value - The value to check.
|
|
23
|
+
* @returns `true` if the value is a positive integer, otherwise `false`.
|
|
24
|
+
*/
|
|
25
|
+
export declare function isPositiveInteger(value: unknown): value is number;
|
|
26
|
+
/**
|
|
27
|
+
* Type guard to check if a value is a boolean.
|
|
28
|
+
* @param value - The value to check.
|
|
29
|
+
* @returns `true` if the value is a boolean, otherwise `false`.
|
|
30
|
+
*/
|
|
31
|
+
export declare function isBoolean(value: unknown): value is boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Type guard to check if a value is null.
|
|
34
|
+
* @param value - The value to check.
|
|
35
|
+
* @returns `true` if the value is null, otherwise `false`.
|
|
36
|
+
*/
|
|
37
|
+
export declare function isNull(value: unknown): value is null;
|
|
38
|
+
/**
|
|
39
|
+
* Type guard to check if a value is undefined.
|
|
40
|
+
* @param value - The value to check.
|
|
41
|
+
* @returns `true` if the value is undefined, otherwise `false`.
|
|
42
|
+
*/
|
|
43
|
+
export declare function isUndefined(value: unknown): value is undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Type guard to check if a value is a symbol.
|
|
46
|
+
* @param value - The value to check.
|
|
47
|
+
* @returns `true` if the value is a symbol, otherwise `false`.
|
|
48
|
+
*/
|
|
49
|
+
export declare function isSymbol(value: unknown): value is symbol;
|
|
50
|
+
/**
|
|
51
|
+
* Type guard to check if a value is a primitive.
|
|
52
|
+
* @param value - The value to check.
|
|
53
|
+
* @returns `true` if the value is a primitive, otherwise `false`.
|
|
54
|
+
*/
|
|
55
|
+
export declare function isPrimitive(value: unknown): value is string | number | boolean | symbol | null | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Type guard to check if a value is a non-empty string.
|
|
58
|
+
* @param value - The value to check.
|
|
59
|
+
* @returns `true` if the value is a non-empty string, otherwise `false`.
|
|
60
|
+
*/
|
|
61
|
+
export declare function isNonEmptyString(value: unknown): value is string;
|
|
62
|
+
/**
|
|
63
|
+
* Type guard to check if a value is falsy.
|
|
64
|
+
* @param value - The value to check.
|
|
65
|
+
* @returns `true` if the value is falsy, otherwise `false`.
|
|
66
|
+
*/
|
|
67
|
+
export declare function isFalsy(value: unknown): value is FalsyPrimitive;
|
|
68
|
+
/**
|
|
69
|
+
* Type guard to check if a value is truthy.
|
|
70
|
+
* @param value - The value to check.
|
|
71
|
+
* @returns `true` if the value is truthy (not null or undefined), otherwise `false`.
|
|
72
|
+
*/
|
|
73
|
+
export declare function isTruthy<T>(value: T): value is Exclude<T, FalsyPrimitive>;
|
|
74
|
+
//# sourceMappingURL=primitives.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primitives.d.ts","sourceRoot":"","sources":["../../src/guards/primitives.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAExD;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAExD;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAEzD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAEjE;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,CAE1D;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,IAAI,CAEpD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,CAE9D;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAExD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAC1B,KAAK,EAAE,OAAO,GACZ,KAAK,IAAI,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAOhE;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAEhE;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,cAAc,CAE/D;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,KAAK,IAAI,OAAO,CAAC,CAAC,EAAE,cAAc,CAAC,CAEzE"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isNumber = isNumber;
|
|
4
|
+
exports.isString = isString;
|
|
5
|
+
exports.isInteger = isInteger;
|
|
6
|
+
exports.isPositiveInteger = isPositiveInteger;
|
|
7
|
+
exports.isBoolean = isBoolean;
|
|
8
|
+
exports.isNull = isNull;
|
|
9
|
+
exports.isUndefined = isUndefined;
|
|
10
|
+
exports.isSymbol = isSymbol;
|
|
11
|
+
exports.isPrimitive = isPrimitive;
|
|
12
|
+
exports.isNonEmptyString = isNonEmptyString;
|
|
13
|
+
exports.isFalsy = isFalsy;
|
|
14
|
+
exports.isTruthy = isTruthy;
|
|
15
|
+
/**
|
|
16
|
+
* Type guard to check if a value is a number.
|
|
17
|
+
* @param value - The value to check.
|
|
18
|
+
* @returns `true` if the value is a number, otherwise `false`.
|
|
19
|
+
*/
|
|
20
|
+
function isNumber(value) {
|
|
21
|
+
return typeof value === 'number' && !isNaN(value);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Type guard to check if a value is a string.
|
|
25
|
+
* @param value - The value to check.
|
|
26
|
+
* @returns `true` if the value is a string, otherwise `false`.
|
|
27
|
+
*/
|
|
28
|
+
function isString(value) {
|
|
29
|
+
return typeof value === 'string';
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Type guard to check if a value is an integer.
|
|
33
|
+
* @param value - The value to check.
|
|
34
|
+
* @returns `true` if the value is an integer, otherwise `false`.
|
|
35
|
+
*/
|
|
36
|
+
function isInteger(value) {
|
|
37
|
+
return isNumber(value) && Number.isInteger(value);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Type guard to check if a value is a positive integer.
|
|
41
|
+
* @param value - The value to check.
|
|
42
|
+
* @returns `true` if the value is a positive integer, otherwise `false`.
|
|
43
|
+
*/
|
|
44
|
+
function isPositiveInteger(value) {
|
|
45
|
+
return isInteger(value) && value > 0;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Type guard to check if a value is a boolean.
|
|
49
|
+
* @param value - The value to check.
|
|
50
|
+
* @returns `true` if the value is a boolean, otherwise `false`.
|
|
51
|
+
*/
|
|
52
|
+
function isBoolean(value) {
|
|
53
|
+
return typeof value === 'boolean';
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Type guard to check if a value is null.
|
|
57
|
+
* @param value - The value to check.
|
|
58
|
+
* @returns `true` if the value is null, otherwise `false`.
|
|
59
|
+
*/
|
|
60
|
+
function isNull(value) {
|
|
61
|
+
return value === null;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Type guard to check if a value is undefined.
|
|
65
|
+
* @param value - The value to check.
|
|
66
|
+
* @returns `true` if the value is undefined, otherwise `false`.
|
|
67
|
+
*/
|
|
68
|
+
function isUndefined(value) {
|
|
69
|
+
return value === undefined;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Type guard to check if a value is a symbol.
|
|
73
|
+
* @param value - The value to check.
|
|
74
|
+
* @returns `true` if the value is a symbol, otherwise `false`.
|
|
75
|
+
*/
|
|
76
|
+
function isSymbol(value) {
|
|
77
|
+
return typeof value === 'symbol';
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Type guard to check if a value is a primitive.
|
|
81
|
+
* @param value - The value to check.
|
|
82
|
+
* @returns `true` if the value is a primitive, otherwise `false`.
|
|
83
|
+
*/
|
|
84
|
+
function isPrimitive(value) {
|
|
85
|
+
return (value === null ||
|
|
86
|
+
['string', 'number', 'boolean', 'symbol', 'undefined'].includes(typeof value));
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Type guard to check if a value is a non-empty string.
|
|
90
|
+
* @param value - The value to check.
|
|
91
|
+
* @returns `true` if the value is a non-empty string, otherwise `false`.
|
|
92
|
+
*/
|
|
93
|
+
function isNonEmptyString(value) {
|
|
94
|
+
return isString(value) && value?.trim().length > 0;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Type guard to check if a value is falsy.
|
|
98
|
+
* @param value - The value to check.
|
|
99
|
+
* @returns `true` if the value is falsy, otherwise `false`.
|
|
100
|
+
*/
|
|
101
|
+
function isFalsy(value) {
|
|
102
|
+
return !value;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Type guard to check if a value is truthy.
|
|
106
|
+
* @param value - The value to check.
|
|
107
|
+
* @returns `true` if the value is truthy (not null or undefined), otherwise `false`.
|
|
108
|
+
*/
|
|
109
|
+
function isTruthy(value) {
|
|
110
|
+
return Boolean(value);
|
|
111
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type guard to check if a value is a valid email string.
|
|
3
|
+
* @param value - The value to check.
|
|
4
|
+
* @returns `true` if the value is a valid email, otherwise `false`.
|
|
5
|
+
*/
|
|
6
|
+
export declare function isEmail(value: unknown): value is string;
|
|
7
|
+
/**
|
|
8
|
+
* Type guard to check if a value is an array of valid email strings.
|
|
9
|
+
* @param value - The value to check.
|
|
10
|
+
* @returns `true` if the value is an array of valid email strings, otherwise `false`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function isEmailArray(value: unknown): value is string[];
|
|
13
|
+
/**
|
|
14
|
+
* Type guard to check if a value is a valid date string.
|
|
15
|
+
* @param value - The value to check.
|
|
16
|
+
* @returns `true` if the value is a valid date string, otherwise `false`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function isDateString(value: unknown): value is string;
|
|
19
|
+
/**
|
|
20
|
+
* Type guard to check if a value is a valid UUID (v4).
|
|
21
|
+
* @param value - The value to check.
|
|
22
|
+
* @returns `true` if the value is a valid UUID, otherwise `false`.
|
|
23
|
+
*/
|
|
24
|
+
export declare function isUUID(value: unknown): value is string;
|
|
25
|
+
/**
|
|
26
|
+
* Type guard to check if the code is running in a browser environment.
|
|
27
|
+
* @returns `true` if the code is running in a browser, otherwise `false`.
|
|
28
|
+
*/
|
|
29
|
+
export declare function isBrowser(): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Type guard to check if the code is running in a Node.js environment.
|
|
32
|
+
* @returns `true` if the code is running in Node.js, otherwise `false`.
|
|
33
|
+
*/
|
|
34
|
+
export declare function isNode(): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Type guard to check if a value is a valid URL.
|
|
37
|
+
* @param value - The value to check.
|
|
38
|
+
* @returns `true` if the value is a valid URL, otherwise `false`.
|
|
39
|
+
*/
|
|
40
|
+
export declare function isURL(value: unknown): value is string;
|
|
41
|
+
/**
|
|
42
|
+
* Type guard to check if a value is a valid Base64 encoded string.
|
|
43
|
+
* @param value - The value to check.
|
|
44
|
+
* @returns `true` if the value is a valid Base64 string, otherwise `false`.
|
|
45
|
+
*/
|
|
46
|
+
export declare function isBase64(value: unknown): value is string;
|
|
47
|
+
/**
|
|
48
|
+
* Type guard to check if a value is a valid phone number.
|
|
49
|
+
* @param value - The value to check.
|
|
50
|
+
* @returns `true` if the value is a valid phone number, otherwise `false`.
|
|
51
|
+
*/
|
|
52
|
+
export declare function isPhoneNumber(value: unknown): value is string;
|
|
53
|
+
/**
|
|
54
|
+
* Type guard to check if a value is a valid IP address (IPv4 or IPv6).
|
|
55
|
+
* @param value - The value to check.
|
|
56
|
+
* @returns `true` if the value is a valid IP address, otherwise `false`.
|
|
57
|
+
*/
|
|
58
|
+
export declare function isIPAddress(value: unknown): value is string;
|
|
59
|
+
/**
|
|
60
|
+
* Type guard to check if the current environment matches a given string.
|
|
61
|
+
* @param env - The expected environment (e.g., "production", "development").
|
|
62
|
+
* @returns `true` if the current environment matches, otherwise `false`.
|
|
63
|
+
*/
|
|
64
|
+
export declare function isEnvironment(env: string): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Type guard to check if a value is a numeric string.
|
|
67
|
+
* @param value - The value to check.
|
|
68
|
+
* @returns `true` if the value is a numeric string, otherwise `false`.
|
|
69
|
+
*/
|
|
70
|
+
export declare function isNumericString(value: unknown): value is `${number}`;
|
|
71
|
+
//# sourceMappingURL=specials.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"specials.d.ts","sourceRoot":"","sources":["../../src/guards/specials.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAKvD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,EAAE,CAE9D;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAE5D;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAOtD;AAED;;;GAGG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAEnC;AAED;;;GAGG;AACH,wBAAgB,MAAM,IAAI,OAAO,CAMhC;AAED;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAOrD;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAOxD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAE7D;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAK3D;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAElD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,GAAG,MAAM,EAAE,CAEpE"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isEmail = isEmail;
|
|
4
|
+
exports.isEmailArray = isEmailArray;
|
|
5
|
+
exports.isDateString = isDateString;
|
|
6
|
+
exports.isUUID = isUUID;
|
|
7
|
+
exports.isBrowser = isBrowser;
|
|
8
|
+
exports.isNode = isNode;
|
|
9
|
+
exports.isURL = isURL;
|
|
10
|
+
exports.isBase64 = isBase64;
|
|
11
|
+
exports.isPhoneNumber = isPhoneNumber;
|
|
12
|
+
exports.isIPAddress = isIPAddress;
|
|
13
|
+
exports.isEnvironment = isEnvironment;
|
|
14
|
+
exports.isNumericString = isNumericString;
|
|
15
|
+
const non_primitives_1 = require("./non-primitives");
|
|
16
|
+
const primitives_1 = require("./primitives");
|
|
17
|
+
/**
|
|
18
|
+
* Type guard to check if a value is a valid email string.
|
|
19
|
+
* @param value - The value to check.
|
|
20
|
+
* @returns `true` if the value is a valid email, otherwise `false`.
|
|
21
|
+
*/
|
|
22
|
+
function isEmail(value) {
|
|
23
|
+
return ((0, primitives_1.isString)(value) &&
|
|
24
|
+
/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(value));
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Type guard to check if a value is an array of valid email strings.
|
|
28
|
+
* @param value - The value to check.
|
|
29
|
+
* @returns `true` if the value is an array of valid email strings, otherwise `false`.
|
|
30
|
+
*/
|
|
31
|
+
function isEmailArray(value) {
|
|
32
|
+
return (0, non_primitives_1.isArray)(value) && value.every(isEmail);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Type guard to check if a value is a valid date string.
|
|
36
|
+
* @param value - The value to check.
|
|
37
|
+
* @returns `true` if the value is a valid date string, otherwise `false`.
|
|
38
|
+
*/
|
|
39
|
+
function isDateString(value) {
|
|
40
|
+
return (0, primitives_1.isString)(value) && !isNaN(Date.parse(value));
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Type guard to check if a value is a valid UUID (v4).
|
|
44
|
+
* @param value - The value to check.
|
|
45
|
+
* @returns `true` if the value is a valid UUID, otherwise `false`.
|
|
46
|
+
*/
|
|
47
|
+
function isUUID(value) {
|
|
48
|
+
return ((0, primitives_1.isString)(value) &&
|
|
49
|
+
/^[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));
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Type guard to check if the code is running in a browser environment.
|
|
53
|
+
* @returns `true` if the code is running in a browser, otherwise `false`.
|
|
54
|
+
*/
|
|
55
|
+
function isBrowser() {
|
|
56
|
+
return typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Type guard to check if the code is running in a Node.js environment.
|
|
60
|
+
* @returns `true` if the code is running in Node.js, otherwise `false`.
|
|
61
|
+
*/
|
|
62
|
+
function isNode() {
|
|
63
|
+
return (typeof process !== 'undefined' &&
|
|
64
|
+
process.versions != null &&
|
|
65
|
+
process.versions.node != null);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Type guard to check if a value is a valid URL.
|
|
69
|
+
* @param value - The value to check.
|
|
70
|
+
* @returns `true` if the value is a valid URL, otherwise `false`.
|
|
71
|
+
*/
|
|
72
|
+
function isURL(value) {
|
|
73
|
+
try {
|
|
74
|
+
new URL((0, primitives_1.isString)(value) ? value : '');
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Type guard to check if a value is a valid Base64 encoded string.
|
|
83
|
+
* @param value - The value to check.
|
|
84
|
+
* @returns `true` if the value is a valid Base64 string, otherwise `false`.
|
|
85
|
+
*/
|
|
86
|
+
function isBase64(value) {
|
|
87
|
+
return ((0, primitives_1.isString)(value) &&
|
|
88
|
+
/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(value));
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Type guard to check if a value is a valid phone number.
|
|
92
|
+
* @param value - The value to check.
|
|
93
|
+
* @returns `true` if the value is a valid phone number, otherwise `false`.
|
|
94
|
+
*/
|
|
95
|
+
function isPhoneNumber(value) {
|
|
96
|
+
return (0, primitives_1.isString)(value) && /^\+?[1-9]\d{1,14}$/.test(value);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Type guard to check if a value is a valid IP address (IPv4 or IPv6).
|
|
100
|
+
* @param value - The value to check.
|
|
101
|
+
* @returns `true` if the value is a valid IP address, otherwise `false`.
|
|
102
|
+
*/
|
|
103
|
+
function isIPAddress(value) {
|
|
104
|
+
return ((0, primitives_1.isString)(value) &&
|
|
105
|
+
/^(?:\d{1,3}\.){3}\d{1,3}$|^([a-f0-9:]+:+)+[a-f0-9]+$/i.test(value));
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Type guard to check if the current environment matches a given string.
|
|
109
|
+
* @param env - The expected environment (e.g., "production", "development").
|
|
110
|
+
* @returns `true` if the current environment matches, otherwise `false`.
|
|
111
|
+
*/
|
|
112
|
+
function isEnvironment(env) {
|
|
113
|
+
return process.env.NODE_ENV === env;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Type guard to check if a value is a numeric string.
|
|
117
|
+
* @param value - The value to check.
|
|
118
|
+
* @returns `true` if the value is a numeric string, otherwise `false`.
|
|
119
|
+
*/
|
|
120
|
+
function isNumericString(value) {
|
|
121
|
+
return (0, primitives_1.isString)(value) && /^\d+(\.\d+)?$/.test(value);
|
|
122
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -14,9 +14,13 @@ export { sortAnArray } from './array/sort';
|
|
|
14
14
|
export { createOptionsArray, removeDuplicatesFromArray, } from './array/transform';
|
|
15
15
|
export { convertIntoFormData, isEmptyFormData } from './form/convert';
|
|
16
16
|
export { createControlledFormData } from './form/transform';
|
|
17
|
+
export { isCustomFile, isCustomFileArray, isFileUpload, isOriginFileObj, } from './form/guards';
|
|
17
18
|
export { cloneObject, countObjectFields, generateQueryParams, isEmptyObject, isObject, } from './object/basics';
|
|
18
19
|
export { extractNewFields, extractUpdatedAndNewFields, extractUpdatedFields, flattenObjectDotNotation, flattenObjectKeyValue, mergeAndFlattenObjects, mergeObjects, } from './object/objectify';
|
|
19
20
|
export { sanitizeData } from './object/sanitize';
|
|
20
21
|
export { convertObjectValues } from './object/convert';
|
|
21
22
|
export { convertArrayToString, debounceAction, isDeepEqual, throttleAction, } from './utils';
|
|
23
|
+
export { isBoolean, isFalsy, isInteger, isNonEmptyString, isNull, isNumber, isPositiveInteger, isPrimitive, isString, isSymbol, isTruthy, isUndefined, } from './guards/primitives';
|
|
24
|
+
export { isArray, isArrayOfType, isBigInt, isDate, isError, isFunction, isJSON, isJSON as isValidJSON, isJSON as isJSONObject, isMap, isMap as isValidMap, isEmptyObject as isObjectEmpty, isObjectWithKeys, isPromise, isRegExp, isReturningPromise, isSet, isSet as isValidSet, isObject as isValidObject, } from './guards/non-primitives';
|
|
25
|
+
export { isBrowser, isDateString, isEmail, isEmail as isValidEmail, isEmailArray, isUUID, isBase64, isEnvironment, isIPAddress, isNode, isNumericString, isPhoneNumber, isURL, isURL as isValidURL, } from './guards/specials';
|
|
22
26
|
//# sourceMappingURL=index.d.ts.map
|
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,UAAU,EACV,KAAK,GACL,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,EACN,2BAA2B,EAC3B,sBAAsB,GACtB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACN,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,gBAAgB,GAChB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAGvC,OAAO,EACN,oBAAoB,EACpB,YAAY,EACZ,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,IAAI,iBAAiB,EAC1C,YAAY,GACZ,MAAM,gBA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AAY,EACtB,KAAK,EACL,KAAK,IAAI,UAAU,EACnB,aAAa,IAAI,aAAa,EAC9B,gBAAgB,EAChB,SAAS,EACT,QAAQ,EACR,kBAAkB,EAClB,KAAK,EACL,KAAK,IAAI,UAAU,EACnB,QAAQ,IAAI,aAAa,GACzB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EACN,SAAS,EACT,YAAY,EACZ,OAAO,EACP,OAAO,IAAI,YAAY,EACvB,YAAY,EACZ,MAAM,EACN,QAAQ,EACR,aAAa,EACb,WAAW,EACX,MAAM,EACN,eAAe,EACf,aAAa,EACb,KAAK,EACL,KAAK,IAAI,UAAU,GACnB,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createControlledFormData = exports.isEmptyFormData = exports.convertIntoFormData = exports.removeDuplicatesFromArray = exports.createOptionsArray = exports.sortAnArray = exports.shuffleArray = exports.isValidEmptyArray = exports.isInvalidOrEmptyArray = exports.getLastArrayElement = exports.flattenArray = exports.filterArrayOfObjects = exports.Color = exports.convertRgbToRgba = exports.convertRgbToHsl = exports.convertRgbToHex = exports.convertRgbaToHsla = exports.convertRgbaToHex8 = exports.convertHslToRgb = exports.convertHslToHex = exports.convertHslaToRgba = exports.convertHslaToHex8 = exports.convertHexToRgb = exports.convertHexToHsl = exports.convertHex8ToRgba = exports.convertHex8ToHsla = exports.convertColorCode = exports.generateRandomHSLColor = exports.generateRandomColorInHexRGB = exports.getColorForInitial = exports.getNumbersInRange = exports.isPrime = exports.findPrimeNumbers = exports.numberToWords = exports.isOdd = exports.isMultiple = exports.isEven = exports.getRandomNumber = exports.convertToDecimal = exports.calculateLCM = exports.calculateLCD = exports.calculateHCF = exports.calculateGCD = exports.replaceAllInString = exports.convertStringCase = exports.generateAnagrams = exports.truncateString = exports.trimString = exports.generateRandomID = exports.capitalizeString = void 0;
|
|
4
|
-
exports.throttleAction = exports.isDeepEqual = exports.debounceAction = exports.convertArrayToString = exports.convertObjectValues = exports.sanitizeData = exports.mergeObjects = exports.mergeAndFlattenObjects = exports.flattenObjectKeyValue = exports.flattenObjectDotNotation = exports.extractUpdatedFields = exports.extractUpdatedAndNewFields = exports.extractNewFields = exports.isObject = exports.isEmptyObject = exports.generateQueryParams = exports.countObjectFields = exports.cloneObject = void 0;
|
|
4
|
+
exports.isReturningPromise = exports.isRegExp = exports.isPromise = exports.isObjectWithKeys = exports.isObjectEmpty = exports.isValidMap = exports.isMap = exports.isJSONObject = exports.isValidJSON = exports.isJSON = exports.isFunction = exports.isError = exports.isDate = exports.isBigInt = exports.isArrayOfType = exports.isArray = exports.isUndefined = exports.isTruthy = exports.isSymbol = exports.isString = exports.isPrimitive = exports.isPositiveInteger = exports.isNumber = exports.isNull = exports.isNonEmptyString = exports.isInteger = exports.isFalsy = exports.isBoolean = exports.throttleAction = exports.isDeepEqual = exports.debounceAction = exports.convertArrayToString = exports.convertObjectValues = exports.sanitizeData = exports.mergeObjects = exports.mergeAndFlattenObjects = exports.flattenObjectKeyValue = exports.flattenObjectDotNotation = exports.extractUpdatedFields = exports.extractUpdatedAndNewFields = exports.extractNewFields = exports.isObject = exports.isEmptyObject = exports.generateQueryParams = exports.countObjectFields = exports.cloneObject = exports.isOriginFileObj = exports.isFileUpload = exports.isCustomFileArray = exports.isCustomFile = void 0;
|
|
5
|
+
exports.isValidURL = exports.isURL = exports.isPhoneNumber = exports.isNumericString = exports.isNode = exports.isIPAddress = exports.isEnvironment = exports.isBase64 = exports.isUUID = exports.isEmailArray = exports.isValidEmail = exports.isEmail = exports.isDateString = exports.isBrowser = exports.isValidObject = exports.isValidSet = exports.isSet = void 0;
|
|
5
6
|
// ! String Utilities
|
|
6
7
|
var basics_1 = require("./string/basics");
|
|
7
8
|
Object.defineProperty(exports, "capitalizeString", { enumerable: true, get: function () { return basics_1.capitalizeString; } });
|
|
@@ -73,6 +74,11 @@ Object.defineProperty(exports, "convertIntoFormData", { enumerable: true, get: f
|
|
|
73
74
|
Object.defineProperty(exports, "isEmptyFormData", { enumerable: true, get: function () { return convert_4.isEmptyFormData; } });
|
|
74
75
|
var transform_2 = require("./form/transform");
|
|
75
76
|
Object.defineProperty(exports, "createControlledFormData", { enumerable: true, get: function () { return transform_2.createControlledFormData; } });
|
|
77
|
+
var guards_1 = require("./form/guards");
|
|
78
|
+
Object.defineProperty(exports, "isCustomFile", { enumerable: true, get: function () { return guards_1.isCustomFile; } });
|
|
79
|
+
Object.defineProperty(exports, "isCustomFileArray", { enumerable: true, get: function () { return guards_1.isCustomFileArray; } });
|
|
80
|
+
Object.defineProperty(exports, "isFileUpload", { enumerable: true, get: function () { return guards_1.isFileUpload; } });
|
|
81
|
+
Object.defineProperty(exports, "isOriginFileObj", { enumerable: true, get: function () { return guards_1.isOriginFileObj; } });
|
|
76
82
|
// ! Object Utilities
|
|
77
83
|
var basics_4 = require("./object/basics");
|
|
78
84
|
Object.defineProperty(exports, "cloneObject", { enumerable: true, get: function () { return basics_4.cloneObject; } });
|
|
@@ -98,3 +104,54 @@ Object.defineProperty(exports, "convertArrayToString", { enumerable: true, get:
|
|
|
98
104
|
Object.defineProperty(exports, "debounceAction", { enumerable: true, get: function () { return utils_1.debounceAction; } });
|
|
99
105
|
Object.defineProperty(exports, "isDeepEqual", { enumerable: true, get: function () { return utils_1.isDeepEqual; } });
|
|
100
106
|
Object.defineProperty(exports, "throttleAction", { enumerable: true, get: function () { return utils_1.throttleAction; } });
|
|
107
|
+
// ! Primitive Type Guards
|
|
108
|
+
var primitives_1 = require("./guards/primitives");
|
|
109
|
+
Object.defineProperty(exports, "isBoolean", { enumerable: true, get: function () { return primitives_1.isBoolean; } });
|
|
110
|
+
Object.defineProperty(exports, "isFalsy", { enumerable: true, get: function () { return primitives_1.isFalsy; } });
|
|
111
|
+
Object.defineProperty(exports, "isInteger", { enumerable: true, get: function () { return primitives_1.isInteger; } });
|
|
112
|
+
Object.defineProperty(exports, "isNonEmptyString", { enumerable: true, get: function () { return primitives_1.isNonEmptyString; } });
|
|
113
|
+
Object.defineProperty(exports, "isNull", { enumerable: true, get: function () { return primitives_1.isNull; } });
|
|
114
|
+
Object.defineProperty(exports, "isNumber", { enumerable: true, get: function () { return primitives_1.isNumber; } });
|
|
115
|
+
Object.defineProperty(exports, "isPositiveInteger", { enumerable: true, get: function () { return primitives_1.isPositiveInteger; } });
|
|
116
|
+
Object.defineProperty(exports, "isPrimitive", { enumerable: true, get: function () { return primitives_1.isPrimitive; } });
|
|
117
|
+
Object.defineProperty(exports, "isString", { enumerable: true, get: function () { return primitives_1.isString; } });
|
|
118
|
+
Object.defineProperty(exports, "isSymbol", { enumerable: true, get: function () { return primitives_1.isSymbol; } });
|
|
119
|
+
Object.defineProperty(exports, "isTruthy", { enumerable: true, get: function () { return primitives_1.isTruthy; } });
|
|
120
|
+
Object.defineProperty(exports, "isUndefined", { enumerable: true, get: function () { return primitives_1.isUndefined; } });
|
|
121
|
+
// ! Non-Primitive Type Guards
|
|
122
|
+
var non_primitives_1 = require("./guards/non-primitives");
|
|
123
|
+
Object.defineProperty(exports, "isArray", { enumerable: true, get: function () { return non_primitives_1.isArray; } });
|
|
124
|
+
Object.defineProperty(exports, "isArrayOfType", { enumerable: true, get: function () { return non_primitives_1.isArrayOfType; } });
|
|
125
|
+
Object.defineProperty(exports, "isBigInt", { enumerable: true, get: function () { return non_primitives_1.isBigInt; } });
|
|
126
|
+
Object.defineProperty(exports, "isDate", { enumerable: true, get: function () { return non_primitives_1.isDate; } });
|
|
127
|
+
Object.defineProperty(exports, "isError", { enumerable: true, get: function () { return non_primitives_1.isError; } });
|
|
128
|
+
Object.defineProperty(exports, "isFunction", { enumerable: true, get: function () { return non_primitives_1.isFunction; } });
|
|
129
|
+
Object.defineProperty(exports, "isJSON", { enumerable: true, get: function () { return non_primitives_1.isJSON; } });
|
|
130
|
+
Object.defineProperty(exports, "isValidJSON", { enumerable: true, get: function () { return non_primitives_1.isJSON; } });
|
|
131
|
+
Object.defineProperty(exports, "isJSONObject", { enumerable: true, get: function () { return non_primitives_1.isJSON; } });
|
|
132
|
+
Object.defineProperty(exports, "isMap", { enumerable: true, get: function () { return non_primitives_1.isMap; } });
|
|
133
|
+
Object.defineProperty(exports, "isValidMap", { enumerable: true, get: function () { return non_primitives_1.isMap; } });
|
|
134
|
+
Object.defineProperty(exports, "isObjectEmpty", { enumerable: true, get: function () { return non_primitives_1.isEmptyObject; } });
|
|
135
|
+
Object.defineProperty(exports, "isObjectWithKeys", { enumerable: true, get: function () { return non_primitives_1.isObjectWithKeys; } });
|
|
136
|
+
Object.defineProperty(exports, "isPromise", { enumerable: true, get: function () { return non_primitives_1.isPromise; } });
|
|
137
|
+
Object.defineProperty(exports, "isRegExp", { enumerable: true, get: function () { return non_primitives_1.isRegExp; } });
|
|
138
|
+
Object.defineProperty(exports, "isReturningPromise", { enumerable: true, get: function () { return non_primitives_1.isReturningPromise; } });
|
|
139
|
+
Object.defineProperty(exports, "isSet", { enumerable: true, get: function () { return non_primitives_1.isSet; } });
|
|
140
|
+
Object.defineProperty(exports, "isValidSet", { enumerable: true, get: function () { return non_primitives_1.isSet; } });
|
|
141
|
+
Object.defineProperty(exports, "isValidObject", { enumerable: true, get: function () { return non_primitives_1.isObject; } });
|
|
142
|
+
// ! Special Type Guards
|
|
143
|
+
var specials_1 = require("./guards/specials");
|
|
144
|
+
Object.defineProperty(exports, "isBrowser", { enumerable: true, get: function () { return specials_1.isBrowser; } });
|
|
145
|
+
Object.defineProperty(exports, "isDateString", { enumerable: true, get: function () { return specials_1.isDateString; } });
|
|
146
|
+
Object.defineProperty(exports, "isEmail", { enumerable: true, get: function () { return specials_1.isEmail; } });
|
|
147
|
+
Object.defineProperty(exports, "isValidEmail", { enumerable: true, get: function () { return specials_1.isEmail; } });
|
|
148
|
+
Object.defineProperty(exports, "isEmailArray", { enumerable: true, get: function () { return specials_1.isEmailArray; } });
|
|
149
|
+
Object.defineProperty(exports, "isUUID", { enumerable: true, get: function () { return specials_1.isUUID; } });
|
|
150
|
+
Object.defineProperty(exports, "isBase64", { enumerable: true, get: function () { return specials_1.isBase64; } });
|
|
151
|
+
Object.defineProperty(exports, "isEnvironment", { enumerable: true, get: function () { return specials_1.isEnvironment; } });
|
|
152
|
+
Object.defineProperty(exports, "isIPAddress", { enumerable: true, get: function () { return specials_1.isIPAddress; } });
|
|
153
|
+
Object.defineProperty(exports, "isNode", { enumerable: true, get: function () { return specials_1.isNode; } });
|
|
154
|
+
Object.defineProperty(exports, "isNumericString", { enumerable: true, get: function () { return specials_1.isNumericString; } });
|
|
155
|
+
Object.defineProperty(exports, "isPhoneNumber", { enumerable: true, get: function () { return specials_1.isPhoneNumber; } });
|
|
156
|
+
Object.defineProperty(exports, "isURL", { enumerable: true, get: function () { return specials_1.isURL; } });
|
|
157
|
+
Object.defineProperty(exports, "isValidURL", { enumerable: true, get: function () { return specials_1.isURL; } });
|
package/dist/types/index.d.ts
CHANGED
|
@@ -21,11 +21,17 @@ export type PrimitiveKey<T> = {
|
|
|
21
21
|
export type NonNullishPrimitiveKey<T> = {
|
|
22
22
|
[K in keyof T]: T[K] extends string | number | boolean ? K : never;
|
|
23
23
|
}[keyof T];
|
|
24
|
+
/** Falsy primitive type */
|
|
25
|
+
export type FalsyPrimitive = false | 0 | '' | null | undefined;
|
|
24
26
|
/** Generic function type */
|
|
25
|
-
export type GenericFn = (...args:
|
|
27
|
+
export type GenericFn = (...args: unknown[]) => unknown;
|
|
28
|
+
/** Generic function type that returns `void` */
|
|
29
|
+
export type VoidFunction = (...args: any[]) => void;
|
|
26
30
|
/** Debounced function type after certain delay */
|
|
27
|
-
export type DelayedFn<T extends
|
|
31
|
+
export type DelayedFn<T extends VoidFunction> = (...args: Parameters<T>) => void;
|
|
28
32
|
/** Throttled function type after specific delay */
|
|
29
|
-
export type ThrottledFn<T extends
|
|
33
|
+
export type ThrottledFn<T extends VoidFunction> = (...args: Parameters<T>) => void;
|
|
34
|
+
/** Asynchronous function type */
|
|
35
|
+
export type AsyncFunction<T> = (...args: unknown[]) => Promise<T>;
|
|
30
36
|
export {};
|
|
31
37
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,MAAM,MAAM,eAAe,GAAG,GAAG,CAAC;AAElC,OAAO,CAAC,MAAM,OAAO,EAAE,OAAO,MAAM,CAAC;AACrC,KAAK,KAAK,CAAC,CAAC,IAAI;IAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;CAAE,CAAC;AAEjC,6BAA6B;AAC7B,MAAM,MAAM,OAAO,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;AAEzC,2CAA2C;AAC3C,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,OAAO,CAAC;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC,CAAC;AAElE,2CAA2C;AAG3C,+BAA+B;AAC/B,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;AAErE,8CAA8C;AAC9C,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI;KAC5B,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,SAAS,GAAG,CAAC,GAAG,KAAK;CAClD,CAAC,MAAM,CAAC,CAAC,CAAC;AAEX,0EAA0E;AAC1E,MAAM,MAAM,sBAAsB,CAAC,CAAC,IAAI;KACtC,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,CAAC,GAAG,KAAK;CAClE,CAAC,MAAM,CAAC,CAAC,CAAC;AAEX,4BAA4B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,GAAG,IAAI,GAAG,SAAS,CAAC;AAE/D,4BAA4B;AAC5B,MAAM,MAAM,SAAS,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC;AAExD,gDAAgD;AAChD,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;AAEpD,kDAAkD;AAClD,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,YAAY,IAAI,CAC/C,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAClB,IAAI,CAAC;AAEV,mDAAmD;AACnD,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,YAAY,IAAI,CACjD,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAClB,IAAI,CAAC;AAEV,iCAAiC;AACjC,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC"}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DelayedFn,
|
|
1
|
+
import type { DelayedFn, ThrottledFn, VoidFunction } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* * Deeply compare two values (arrays, objects, or primitive values).
|
|
4
4
|
*
|
|
@@ -29,7 +29,7 @@ export declare const convertArrayToString: <T>(array: T[], separator?: string) =
|
|
|
29
29
|
*
|
|
30
30
|
* debouncedSearch('laptop'); // Executes after 300ms of inactivity.
|
|
31
31
|
*/
|
|
32
|
-
export declare const debounceAction: <T extends
|
|
32
|
+
export declare const debounceAction: <T extends VoidFunction>(callback: T, delay?: number) => DelayedFn<T>;
|
|
33
33
|
/**
|
|
34
34
|
* * A generic throttle function that ensures a callback is executed at most once per specified interval.
|
|
35
35
|
*
|
|
@@ -44,5 +44,5 @@ export declare const debounceAction: <T extends GenericFn>(callback: T, delay?:
|
|
|
44
44
|
*
|
|
45
45
|
* window.addEventListener('resize', throttledResize);
|
|
46
46
|
*/
|
|
47
|
-
export declare const throttleAction: <T extends
|
|
47
|
+
export declare const throttleAction: <T extends VoidFunction>(callback: T, delay?: number) => ThrottledFn<T>;
|
|
48
48
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAErE;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAG,OA6B3C,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAAI,CAAC,SAC9B,CAAC,EAAE,cACC,MAAM,KACf,MAKF,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,YAAY,YAC1C,CAAC,qBAET,SAAS,CAAC,CAAC,CAYb,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,YAAY,YAC1C,CAAC,qBAET,WAAW,CAAC,CAAC,CAWf,CAAC"}
|
package/package.json
CHANGED