@infra-blocks/types 0.27.0 → 0.28.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/lib/cjs/guard.d.ts +10 -20
- package/lib/cjs/guard.js +13 -20
- package/lib/cjs/guard.js.map +1 -1
- package/lib/esm/guard.d.ts +10 -20
- package/lib/esm/guard.js +12 -20
- package/lib/esm/guard.js.map +1 -1
- package/package.json +4 -6
package/lib/cjs/guard.d.ts
CHANGED
|
@@ -7,8 +7,6 @@ import type { Primitive } from "./types.js";
|
|
|
7
7
|
* @param value - The value to test.
|
|
8
8
|
*
|
|
9
9
|
* @returns Whether or not the value is a bigint.
|
|
10
|
-
*
|
|
11
|
-
* @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
12
10
|
*/
|
|
13
11
|
export declare function isBigint(value: unknown): value is bigint;
|
|
14
12
|
/**
|
|
@@ -19,8 +17,6 @@ export declare function isBigint(value: unknown): value is bigint;
|
|
|
19
17
|
* @param value - The value to test.
|
|
20
18
|
*
|
|
21
19
|
* @returns Whether or not the value is a boolean.
|
|
22
|
-
*
|
|
23
|
-
* @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
24
20
|
*/
|
|
25
21
|
export declare function isBoolean(value: unknown): value is boolean;
|
|
26
22
|
/**
|
|
@@ -31,10 +27,18 @@ export declare function isBoolean(value: unknown): value is boolean;
|
|
|
31
27
|
* @param value - The value to test.
|
|
32
28
|
*
|
|
33
29
|
* @returns Whether or not the value is a function.
|
|
34
|
-
*
|
|
35
|
-
* @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
36
30
|
*/
|
|
37
31
|
export declare function isFunction(value: unknown): value is Function;
|
|
32
|
+
/**
|
|
33
|
+
* A type guard to assess that a value is {@link NonNullable}.
|
|
34
|
+
*
|
|
35
|
+
* The function uses `!= null` to validate the input, conforming to the {@link NonNullable} type.
|
|
36
|
+
*
|
|
37
|
+
* @param value - The value to test.
|
|
38
|
+
*
|
|
39
|
+
* @returns Whether or not the value is non nullable.
|
|
40
|
+
*/
|
|
41
|
+
export declare function isNonNullable<T>(value: T): value is NonNullable<T>;
|
|
38
42
|
/**
|
|
39
43
|
* A type guard to assess that a value is a number.
|
|
40
44
|
*
|
|
@@ -43,8 +47,6 @@ export declare function isFunction(value: unknown): value is Function;
|
|
|
43
47
|
* @param value - The value to test.
|
|
44
48
|
*
|
|
45
49
|
* @returns Whether or not the value is a number.
|
|
46
|
-
*
|
|
47
|
-
* @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
48
50
|
*/
|
|
49
51
|
export declare function isNumber(value: unknown): value is number;
|
|
50
52
|
/**
|
|
@@ -55,8 +57,6 @@ export declare function isNumber(value: unknown): value is number;
|
|
|
55
57
|
* @param value - The value to test.
|
|
56
58
|
*
|
|
57
59
|
* @returns Whether or not the value is null.
|
|
58
|
-
*
|
|
59
|
-
* @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
60
60
|
*/
|
|
61
61
|
export declare function isNull(value: unknown): value is null;
|
|
62
62
|
/**
|
|
@@ -68,8 +68,6 @@ export declare function isNull(value: unknown): value is null;
|
|
|
68
68
|
* @param value - The value to test.
|
|
69
69
|
*
|
|
70
70
|
* @returns Whether or not the value is an object.
|
|
71
|
-
*
|
|
72
|
-
* @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
73
71
|
*/
|
|
74
72
|
export declare function isObject(value: unknown): value is object | null;
|
|
75
73
|
/**
|
|
@@ -83,7 +81,6 @@ export declare function isObject(value: unknown): value is object | null;
|
|
|
83
81
|
* @returns Whether or not the value is an object and not null.
|
|
84
82
|
*
|
|
85
83
|
* @see isObject
|
|
86
|
-
* @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
87
84
|
*/
|
|
88
85
|
export declare function isObjectNotNull(value: unknown): value is object;
|
|
89
86
|
/**
|
|
@@ -105,7 +102,6 @@ export declare function isObjectNotNull(value: unknown): value is object;
|
|
|
105
102
|
* @see isString
|
|
106
103
|
* @see isSymbol
|
|
107
104
|
* @see isUndefined
|
|
108
|
-
* @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
109
105
|
*/
|
|
110
106
|
export declare function isPrimitive(value: unknown): value is Primitive;
|
|
111
107
|
/**
|
|
@@ -116,8 +112,6 @@ export declare function isPrimitive(value: unknown): value is Primitive;
|
|
|
116
112
|
* @param value - The value to test.
|
|
117
113
|
*
|
|
118
114
|
* @returns Whether or not the value is a string.
|
|
119
|
-
*
|
|
120
|
-
* @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
121
115
|
*/
|
|
122
116
|
export declare function isString(value: unknown): value is string;
|
|
123
117
|
/**
|
|
@@ -128,8 +122,6 @@ export declare function isString(value: unknown): value is string;
|
|
|
128
122
|
* @param value - The value to test.
|
|
129
123
|
*
|
|
130
124
|
* @returns Whether or not the value is a symbol.
|
|
131
|
-
*
|
|
132
|
-
* @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
133
125
|
*/
|
|
134
126
|
export declare function isSymbol(value: unknown): value is symbol;
|
|
135
127
|
/**
|
|
@@ -140,7 +132,5 @@ export declare function isSymbol(value: unknown): value is symbol;
|
|
|
140
132
|
* @param value - The value to test.
|
|
141
133
|
*
|
|
142
134
|
* @returns Whether or not the value is undefined.
|
|
143
|
-
*
|
|
144
|
-
* @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
145
135
|
*/
|
|
146
136
|
export declare function isUndefined(value: unknown): value is undefined;
|
package/lib/cjs/guard.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.isBigint = isBigint;
|
|
4
4
|
exports.isBoolean = isBoolean;
|
|
5
5
|
exports.isFunction = isFunction;
|
|
6
|
+
exports.isNonNullable = isNonNullable;
|
|
6
7
|
exports.isNumber = isNumber;
|
|
7
8
|
exports.isNull = isNull;
|
|
8
9
|
exports.isObject = isObject;
|
|
@@ -19,8 +20,6 @@ exports.isUndefined = isUndefined;
|
|
|
19
20
|
* @param value - The value to test.
|
|
20
21
|
*
|
|
21
22
|
* @returns Whether or not the value is a bigint.
|
|
22
|
-
*
|
|
23
|
-
* @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
24
23
|
*/
|
|
25
24
|
function isBigint(value) {
|
|
26
25
|
return typeof value === "bigint";
|
|
@@ -33,8 +32,6 @@ function isBigint(value) {
|
|
|
33
32
|
* @param value - The value to test.
|
|
34
33
|
*
|
|
35
34
|
* @returns Whether or not the value is a boolean.
|
|
36
|
-
*
|
|
37
|
-
* @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
38
35
|
*/
|
|
39
36
|
function isBoolean(value) {
|
|
40
37
|
return typeof value === "boolean";
|
|
@@ -47,13 +44,23 @@ function isBoolean(value) {
|
|
|
47
44
|
* @param value - The value to test.
|
|
48
45
|
*
|
|
49
46
|
* @returns Whether or not the value is a function.
|
|
50
|
-
*
|
|
51
|
-
* @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
52
47
|
*/
|
|
53
48
|
// biome-ignore lint/complexity/noBannedTypes: Function is the correct type here.
|
|
54
49
|
function isFunction(value) {
|
|
55
50
|
return typeof value === "function";
|
|
56
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* A type guard to assess that a value is {@link NonNullable}.
|
|
54
|
+
*
|
|
55
|
+
* The function uses `!= null` to validate the input, conforming to the {@link NonNullable} type.
|
|
56
|
+
*
|
|
57
|
+
* @param value - The value to test.
|
|
58
|
+
*
|
|
59
|
+
* @returns Whether or not the value is non nullable.
|
|
60
|
+
*/
|
|
61
|
+
function isNonNullable(value) {
|
|
62
|
+
return value != null;
|
|
63
|
+
}
|
|
57
64
|
/**
|
|
58
65
|
* A type guard to assess that a value is a number.
|
|
59
66
|
*
|
|
@@ -62,8 +69,6 @@ function isFunction(value) {
|
|
|
62
69
|
* @param value - The value to test.
|
|
63
70
|
*
|
|
64
71
|
* @returns Whether or not the value is a number.
|
|
65
|
-
*
|
|
66
|
-
* @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
67
72
|
*/
|
|
68
73
|
function isNumber(value) {
|
|
69
74
|
return typeof value === "number";
|
|
@@ -76,8 +81,6 @@ function isNumber(value) {
|
|
|
76
81
|
* @param value - The value to test.
|
|
77
82
|
*
|
|
78
83
|
* @returns Whether or not the value is null.
|
|
79
|
-
*
|
|
80
|
-
* @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
81
84
|
*/
|
|
82
85
|
function isNull(value) {
|
|
83
86
|
return value === null;
|
|
@@ -91,8 +94,6 @@ function isNull(value) {
|
|
|
91
94
|
* @param value - The value to test.
|
|
92
95
|
*
|
|
93
96
|
* @returns Whether or not the value is an object.
|
|
94
|
-
*
|
|
95
|
-
* @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
96
97
|
*/
|
|
97
98
|
function isObject(value) {
|
|
98
99
|
return typeof value === "object";
|
|
@@ -108,7 +109,6 @@ function isObject(value) {
|
|
|
108
109
|
* @returns Whether or not the value is an object and not null.
|
|
109
110
|
*
|
|
110
111
|
* @see isObject
|
|
111
|
-
* @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
112
112
|
*/
|
|
113
113
|
function isObjectNotNull(value) {
|
|
114
114
|
return !isNull(value) && typeof value === "object";
|
|
@@ -132,7 +132,6 @@ function isObjectNotNull(value) {
|
|
|
132
132
|
* @see isString
|
|
133
133
|
* @see isSymbol
|
|
134
134
|
* @see isUndefined
|
|
135
|
-
* @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
136
135
|
*/
|
|
137
136
|
function isPrimitive(value) {
|
|
138
137
|
return (isBigint(value) ||
|
|
@@ -151,8 +150,6 @@ function isPrimitive(value) {
|
|
|
151
150
|
* @param value - The value to test.
|
|
152
151
|
*
|
|
153
152
|
* @returns Whether or not the value is a string.
|
|
154
|
-
*
|
|
155
|
-
* @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
156
153
|
*/
|
|
157
154
|
function isString(value) {
|
|
158
155
|
return typeof value === "string";
|
|
@@ -165,8 +162,6 @@ function isString(value) {
|
|
|
165
162
|
* @param value - The value to test.
|
|
166
163
|
*
|
|
167
164
|
* @returns Whether or not the value is a symbol.
|
|
168
|
-
*
|
|
169
|
-
* @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
170
165
|
*/
|
|
171
166
|
function isSymbol(value) {
|
|
172
167
|
return typeof value === "symbol";
|
|
@@ -179,8 +174,6 @@ function isSymbol(value) {
|
|
|
179
174
|
* @param value - The value to test.
|
|
180
175
|
*
|
|
181
176
|
* @returns Whether or not the value is undefined.
|
|
182
|
-
*
|
|
183
|
-
* @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
184
177
|
*/
|
|
185
178
|
function isUndefined(value) {
|
|
186
179
|
return typeof value === "undefined";
|
package/lib/cjs/guard.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guard.js","sourceRoot":"","sources":["../../src/guard.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"guard.js","sourceRoot":"","sources":["../../src/guard.ts"],"names":[],"mappings":";;AAWA,4BAEC;AAWD,8BAEC;AAYD,gCAEC;AAWD,sCAEC;AAWD,4BAEC;AAWD,wBAEC;AAYD,4BAEC;AAcD,0CAEC;AAsBD,kCAUC;AAWD,4BAEC;AAWD,4BAEC;AAWD,kCAEC;AAlLD;;;;;;;;GAQG;AACH,SAAgB,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,SAAS,CAAC,KAAc;IACtC,OAAO,OAAO,KAAK,KAAK,SAAS,CAAC;AACpC,CAAC;AAED;;;;;;;;GAQG;AACH,iFAAiF;AACjF,SAAgB,UAAU,CAAC,KAAc;IACvC,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC;AACrC,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,aAAa,CAAI,KAAQ;IACvC,OAAO,KAAK,IAAI,IAAI,CAAC;AACvB,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,MAAM,CAAC,KAAc;IACnC,OAAO,KAAK,KAAK,IAAI,CAAC;AACxB,CAAC;AAED;;;;;;;;;GASG;AACH,SAAgB,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,eAAe,CAAC,KAAc;IAC5C,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC;AACrD,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,WAAW,CAAC,KAAc;IACxC,OAAO,CACL,QAAQ,CAAC,KAAK,CAAC;QACf,SAAS,CAAC,KAAK,CAAC;QAChB,MAAM,CAAC,KAAK,CAAC;QACb,QAAQ,CAAC,KAAK,CAAC;QACf,QAAQ,CAAC,KAAK,CAAC;QACf,QAAQ,CAAC,KAAK,CAAC;QACf,WAAW,CAAC,KAAK,CAAC,CACnB,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,WAAW,CAAC,KAAc;IACxC,OAAO,OAAO,KAAK,KAAK,WAAW,CAAC;AACtC,CAAC"}
|
package/lib/esm/guard.d.ts
CHANGED
|
@@ -7,8 +7,6 @@ import type { Primitive } from "./types.js";
|
|
|
7
7
|
* @param value - The value to test.
|
|
8
8
|
*
|
|
9
9
|
* @returns Whether or not the value is a bigint.
|
|
10
|
-
*
|
|
11
|
-
* @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
12
10
|
*/
|
|
13
11
|
export declare function isBigint(value: unknown): value is bigint;
|
|
14
12
|
/**
|
|
@@ -19,8 +17,6 @@ export declare function isBigint(value: unknown): value is bigint;
|
|
|
19
17
|
* @param value - The value to test.
|
|
20
18
|
*
|
|
21
19
|
* @returns Whether or not the value is a boolean.
|
|
22
|
-
*
|
|
23
|
-
* @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
24
20
|
*/
|
|
25
21
|
export declare function isBoolean(value: unknown): value is boolean;
|
|
26
22
|
/**
|
|
@@ -31,10 +27,18 @@ export declare function isBoolean(value: unknown): value is boolean;
|
|
|
31
27
|
* @param value - The value to test.
|
|
32
28
|
*
|
|
33
29
|
* @returns Whether or not the value is a function.
|
|
34
|
-
*
|
|
35
|
-
* @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
36
30
|
*/
|
|
37
31
|
export declare function isFunction(value: unknown): value is Function;
|
|
32
|
+
/**
|
|
33
|
+
* A type guard to assess that a value is {@link NonNullable}.
|
|
34
|
+
*
|
|
35
|
+
* The function uses `!= null` to validate the input, conforming to the {@link NonNullable} type.
|
|
36
|
+
*
|
|
37
|
+
* @param value - The value to test.
|
|
38
|
+
*
|
|
39
|
+
* @returns Whether or not the value is non nullable.
|
|
40
|
+
*/
|
|
41
|
+
export declare function isNonNullable<T>(value: T): value is NonNullable<T>;
|
|
38
42
|
/**
|
|
39
43
|
* A type guard to assess that a value is a number.
|
|
40
44
|
*
|
|
@@ -43,8 +47,6 @@ export declare function isFunction(value: unknown): value is Function;
|
|
|
43
47
|
* @param value - The value to test.
|
|
44
48
|
*
|
|
45
49
|
* @returns Whether or not the value is a number.
|
|
46
|
-
*
|
|
47
|
-
* @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
48
50
|
*/
|
|
49
51
|
export declare function isNumber(value: unknown): value is number;
|
|
50
52
|
/**
|
|
@@ -55,8 +57,6 @@ export declare function isNumber(value: unknown): value is number;
|
|
|
55
57
|
* @param value - The value to test.
|
|
56
58
|
*
|
|
57
59
|
* @returns Whether or not the value is null.
|
|
58
|
-
*
|
|
59
|
-
* @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
60
60
|
*/
|
|
61
61
|
export declare function isNull(value: unknown): value is null;
|
|
62
62
|
/**
|
|
@@ -68,8 +68,6 @@ export declare function isNull(value: unknown): value is null;
|
|
|
68
68
|
* @param value - The value to test.
|
|
69
69
|
*
|
|
70
70
|
* @returns Whether or not the value is an object.
|
|
71
|
-
*
|
|
72
|
-
* @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
73
71
|
*/
|
|
74
72
|
export declare function isObject(value: unknown): value is object | null;
|
|
75
73
|
/**
|
|
@@ -83,7 +81,6 @@ export declare function isObject(value: unknown): value is object | null;
|
|
|
83
81
|
* @returns Whether or not the value is an object and not null.
|
|
84
82
|
*
|
|
85
83
|
* @see isObject
|
|
86
|
-
* @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
87
84
|
*/
|
|
88
85
|
export declare function isObjectNotNull(value: unknown): value is object;
|
|
89
86
|
/**
|
|
@@ -105,7 +102,6 @@ export declare function isObjectNotNull(value: unknown): value is object;
|
|
|
105
102
|
* @see isString
|
|
106
103
|
* @see isSymbol
|
|
107
104
|
* @see isUndefined
|
|
108
|
-
* @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
109
105
|
*/
|
|
110
106
|
export declare function isPrimitive(value: unknown): value is Primitive;
|
|
111
107
|
/**
|
|
@@ -116,8 +112,6 @@ export declare function isPrimitive(value: unknown): value is Primitive;
|
|
|
116
112
|
* @param value - The value to test.
|
|
117
113
|
*
|
|
118
114
|
* @returns Whether or not the value is a string.
|
|
119
|
-
*
|
|
120
|
-
* @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
121
115
|
*/
|
|
122
116
|
export declare function isString(value: unknown): value is string;
|
|
123
117
|
/**
|
|
@@ -128,8 +122,6 @@ export declare function isString(value: unknown): value is string;
|
|
|
128
122
|
* @param value - The value to test.
|
|
129
123
|
*
|
|
130
124
|
* @returns Whether or not the value is a symbol.
|
|
131
|
-
*
|
|
132
|
-
* @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
133
125
|
*/
|
|
134
126
|
export declare function isSymbol(value: unknown): value is symbol;
|
|
135
127
|
/**
|
|
@@ -140,7 +132,5 @@ export declare function isSymbol(value: unknown): value is symbol;
|
|
|
140
132
|
* @param value - The value to test.
|
|
141
133
|
*
|
|
142
134
|
* @returns Whether or not the value is undefined.
|
|
143
|
-
*
|
|
144
|
-
* @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
145
135
|
*/
|
|
146
136
|
export declare function isUndefined(value: unknown): value is undefined;
|
package/lib/esm/guard.js
CHANGED
|
@@ -6,8 +6,6 @@
|
|
|
6
6
|
* @param value - The value to test.
|
|
7
7
|
*
|
|
8
8
|
* @returns Whether or not the value is a bigint.
|
|
9
|
-
*
|
|
10
|
-
* @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
11
9
|
*/
|
|
12
10
|
export function isBigint(value) {
|
|
13
11
|
return typeof value === "bigint";
|
|
@@ -20,8 +18,6 @@ export function isBigint(value) {
|
|
|
20
18
|
* @param value - The value to test.
|
|
21
19
|
*
|
|
22
20
|
* @returns Whether or not the value is a boolean.
|
|
23
|
-
*
|
|
24
|
-
* @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
25
21
|
*/
|
|
26
22
|
export function isBoolean(value) {
|
|
27
23
|
return typeof value === "boolean";
|
|
@@ -34,13 +30,23 @@ export function isBoolean(value) {
|
|
|
34
30
|
* @param value - The value to test.
|
|
35
31
|
*
|
|
36
32
|
* @returns Whether or not the value is a function.
|
|
37
|
-
*
|
|
38
|
-
* @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
39
33
|
*/
|
|
40
34
|
// biome-ignore lint/complexity/noBannedTypes: Function is the correct type here.
|
|
41
35
|
export function isFunction(value) {
|
|
42
36
|
return typeof value === "function";
|
|
43
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* A type guard to assess that a value is {@link NonNullable}.
|
|
40
|
+
*
|
|
41
|
+
* The function uses `!= null` to validate the input, conforming to the {@link NonNullable} type.
|
|
42
|
+
*
|
|
43
|
+
* @param value - The value to test.
|
|
44
|
+
*
|
|
45
|
+
* @returns Whether or not the value is non nullable.
|
|
46
|
+
*/
|
|
47
|
+
export function isNonNullable(value) {
|
|
48
|
+
return value != null;
|
|
49
|
+
}
|
|
44
50
|
/**
|
|
45
51
|
* A type guard to assess that a value is a number.
|
|
46
52
|
*
|
|
@@ -49,8 +55,6 @@ export function isFunction(value) {
|
|
|
49
55
|
* @param value - The value to test.
|
|
50
56
|
*
|
|
51
57
|
* @returns Whether or not the value is a number.
|
|
52
|
-
*
|
|
53
|
-
* @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
54
58
|
*/
|
|
55
59
|
export function isNumber(value) {
|
|
56
60
|
return typeof value === "number";
|
|
@@ -63,8 +67,6 @@ export function isNumber(value) {
|
|
|
63
67
|
* @param value - The value to test.
|
|
64
68
|
*
|
|
65
69
|
* @returns Whether or not the value is null.
|
|
66
|
-
*
|
|
67
|
-
* @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
68
70
|
*/
|
|
69
71
|
export function isNull(value) {
|
|
70
72
|
return value === null;
|
|
@@ -78,8 +80,6 @@ export function isNull(value) {
|
|
|
78
80
|
* @param value - The value to test.
|
|
79
81
|
*
|
|
80
82
|
* @returns Whether or not the value is an object.
|
|
81
|
-
*
|
|
82
|
-
* @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
83
83
|
*/
|
|
84
84
|
export function isObject(value) {
|
|
85
85
|
return typeof value === "object";
|
|
@@ -95,7 +95,6 @@ export function isObject(value) {
|
|
|
95
95
|
* @returns Whether or not the value is an object and not null.
|
|
96
96
|
*
|
|
97
97
|
* @see isObject
|
|
98
|
-
* @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
99
98
|
*/
|
|
100
99
|
export function isObjectNotNull(value) {
|
|
101
100
|
return !isNull(value) && typeof value === "object";
|
|
@@ -119,7 +118,6 @@ export function isObjectNotNull(value) {
|
|
|
119
118
|
* @see isString
|
|
120
119
|
* @see isSymbol
|
|
121
120
|
* @see isUndefined
|
|
122
|
-
* @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
123
121
|
*/
|
|
124
122
|
export function isPrimitive(value) {
|
|
125
123
|
return (isBigint(value) ||
|
|
@@ -138,8 +136,6 @@ export function isPrimitive(value) {
|
|
|
138
136
|
* @param value - The value to test.
|
|
139
137
|
*
|
|
140
138
|
* @returns Whether or not the value is a string.
|
|
141
|
-
*
|
|
142
|
-
* @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
143
139
|
*/
|
|
144
140
|
export function isString(value) {
|
|
145
141
|
return typeof value === "string";
|
|
@@ -152,8 +148,6 @@ export function isString(value) {
|
|
|
152
148
|
* @param value - The value to test.
|
|
153
149
|
*
|
|
154
150
|
* @returns Whether or not the value is a symbol.
|
|
155
|
-
*
|
|
156
|
-
* @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
157
151
|
*/
|
|
158
152
|
export function isSymbol(value) {
|
|
159
153
|
return typeof value === "symbol";
|
|
@@ -166,8 +160,6 @@ export function isSymbol(value) {
|
|
|
166
160
|
* @param value - The value to test.
|
|
167
161
|
*
|
|
168
162
|
* @returns Whether or not the value is undefined.
|
|
169
|
-
*
|
|
170
|
-
* @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
171
163
|
*/
|
|
172
164
|
export function isUndefined(value) {
|
|
173
165
|
return typeof value === "undefined";
|
package/lib/esm/guard.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guard.js","sourceRoot":"","sources":["../../src/guard.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"guard.js","sourceRoot":"","sources":["../../src/guard.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,SAAS,CAAC,KAAc;IACtC,OAAO,OAAO,KAAK,KAAK,SAAS,CAAC;AACpC,CAAC;AAED;;;;;;;;GAQG;AACH,iFAAiF;AACjF,MAAM,UAAU,UAAU,CAAC,KAAc;IACvC,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC;AACrC,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,aAAa,CAAI,KAAQ;IACvC,OAAO,KAAK,IAAI,IAAI,CAAC;AACvB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,MAAM,CAAC,KAAc;IACnC,OAAO,KAAK,KAAK,IAAI,CAAC;AACxB,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC;AACrD,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,OAAO,CACL,QAAQ,CAAC,KAAK,CAAC;QACf,SAAS,CAAC,KAAK,CAAC;QAChB,MAAM,CAAC,KAAK,CAAC;QACb,QAAQ,CAAC,KAAK,CAAC;QACf,QAAQ,CAAC,KAAK,CAAC;QACf,QAAQ,CAAC,KAAK,CAAC;QACf,WAAW,CAAC,KAAK,CAAC,CACnB,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,OAAO,OAAO,KAAK,KAAK,WAAW,CAAC;AACtC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@infra-blocks/types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"description": "Typescript types utility package.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"type",
|
|
@@ -34,21 +34,19 @@
|
|
|
34
34
|
"test": "npm run test:unit",
|
|
35
35
|
"test:coverage": "c8 npm run test",
|
|
36
36
|
"test:coverage:lcov": "c8 --reporter=lcov npm run test",
|
|
37
|
-
"test:integration": "
|
|
38
|
-
"test:unit": "
|
|
37
|
+
"test:integration": "node --import tsx --test 'test/integration/**/*.spec.ts'",
|
|
38
|
+
"test:unit": "node --import tsx --test 'test/unit/**/*.spec.ts'"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@biomejs/biome": "^2.3.8",
|
|
42
42
|
"@infra-blocks/test": "^0.6.0",
|
|
43
|
-
"@types/mocha": "^10.0.1",
|
|
44
43
|
"@types/node": "^24.10.1",
|
|
45
44
|
"@typescript-eslint/eslint-plugin": "^5.59.8",
|
|
46
45
|
"@typescript-eslint/parser": "^5.59.8",
|
|
47
46
|
"c8": "^8.0.0",
|
|
48
47
|
"expect-type": "^1.3.0",
|
|
49
48
|
"lefthook": "^2.0.8",
|
|
50
|
-
"
|
|
51
|
-
"ts-node": "^10.9.1",
|
|
49
|
+
"tsx": "^4.21.0",
|
|
52
50
|
"typescript": "^5.9.3"
|
|
53
51
|
},
|
|
54
52
|
"engines": {
|