@infra-blocks/types 0.34.0-alpha.0 → 0.35.0-alpha.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 +3 -125
- package/lib/cjs/guard.js +4 -165
- package/lib/cjs/guard.js.map +1 -1
- package/lib/cjs/index.d.ts +0 -1
- package/lib/cjs/index.js +0 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/guard.d.ts +3 -125
- package/lib/esm/guard.js +4 -154
- package/lib/esm/guard.js.map +1 -1
- package/lib/esm/index.d.ts +0 -1
- package/lib/esm/index.js +0 -1
- package/lib/esm/index.js.map +1 -1
- package/package.json +1 -1
- package/lib/cjs/predicates.d.ts +0 -11
- package/lib/cjs/predicates.js +0 -18
- package/lib/cjs/predicates.js.map +0 -1
- package/lib/esm/predicates.d.ts +0 -11
- package/lib/esm/predicates.js +0 -15
- package/lib/esm/predicates.js.map +0 -1
package/lib/cjs/guard.d.ts
CHANGED
|
@@ -1,80 +1,9 @@
|
|
|
1
|
-
import type { Primitive } from "./types.js";
|
|
2
|
-
/**
|
|
3
|
-
* A type guard to assess that a value is a bigint.
|
|
4
|
-
*
|
|
5
|
-
* This function uses the `typeof` operator's definition of a bigint.
|
|
6
|
-
*
|
|
7
|
-
* @param value - The value to test.
|
|
8
|
-
*
|
|
9
|
-
* @returns Whether or not the value is a bigint.
|
|
10
|
-
*/
|
|
11
|
-
export declare function isBigint(value: unknown): value is bigint;
|
|
12
|
-
/**
|
|
13
|
-
* A type guard to assess that a value is a boolean.
|
|
14
|
-
*
|
|
15
|
-
* This function uses the `typeof` operator's definition of a boolean.
|
|
16
|
-
*
|
|
17
|
-
* @param value - The value to test.
|
|
18
|
-
*
|
|
19
|
-
* @returns Whether or not the value is a boolean.
|
|
20
|
-
*/
|
|
21
|
-
export declare function isBoolean(value: unknown): value is boolean;
|
|
22
|
-
/**
|
|
23
|
-
* A type guard to assess that a value is a function.
|
|
24
|
-
*
|
|
25
|
-
* This function uses the `typeof` operator's definition of a function.
|
|
26
|
-
*
|
|
27
|
-
* @param value - The value to test.
|
|
28
|
-
*
|
|
29
|
-
* @returns Whether or not the value is a function.
|
|
30
|
-
*/
|
|
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>;
|
|
42
|
-
/**
|
|
43
|
-
* A type guard to assess that a value is a number.
|
|
44
|
-
*
|
|
45
|
-
* This function uses the `typeof` operator's definition of a number.
|
|
46
|
-
*
|
|
47
|
-
* @param value - The value to test.
|
|
48
|
-
*
|
|
49
|
-
* @returns Whether or not the value is a number.
|
|
50
|
-
*/
|
|
51
|
-
export declare function isNumber(value: unknown): value is number;
|
|
52
|
-
/**
|
|
53
|
-
* A type guard to assess that a value is null.
|
|
54
|
-
*
|
|
55
|
-
* This function uses the `===` operator to check for null.
|
|
56
|
-
*
|
|
57
|
-
* @param value - The value to test.
|
|
58
|
-
*
|
|
59
|
-
* @returns Whether or not the value is null.
|
|
60
|
-
*/
|
|
61
|
-
export declare function isNull(value: unknown): value is null;
|
|
62
|
-
/**
|
|
63
|
-
* A type guard to assess that a value is an object.
|
|
64
|
-
*
|
|
65
|
-
* This function uses the `typeof` operator's definition of an object.
|
|
66
|
-
* If you need to exclude null, you can use the {@link isObjectNotNull} function instead.
|
|
67
|
-
*
|
|
68
|
-
* @param value - The value to test.
|
|
69
|
-
*
|
|
70
|
-
* @returns Whether or not the value is an object.
|
|
71
|
-
*/
|
|
72
|
-
export declare function isObject(value: unknown): value is object | null;
|
|
73
1
|
/**
|
|
74
2
|
* A type guard to assess that a value is an object and not null.
|
|
75
3
|
*
|
|
76
|
-
* This function
|
|
77
|
-
* is
|
|
4
|
+
* This function exists because {@link isObject} will return `true` for `null`.
|
|
5
|
+
* This is because `typeof null === "object"`. This function validates
|
|
6
|
+
* that `typeof value === "object" && value !== null`.
|
|
78
7
|
*
|
|
79
8
|
* @param value - The value to test.
|
|
80
9
|
*
|
|
@@ -83,54 +12,3 @@ export declare function isObject(value: unknown): value is object | null;
|
|
|
83
12
|
* @see isObject
|
|
84
13
|
*/
|
|
85
14
|
export declare function isObjectNotNull(value: unknown): value is object;
|
|
86
|
-
/**
|
|
87
|
-
* A type guard to assess that a value is a primitive.
|
|
88
|
-
*
|
|
89
|
-
* This function checks if the value is one of the primitive types:
|
|
90
|
-
* bigint, boolean, null, number, string, symbol, or undefined.
|
|
91
|
-
*
|
|
92
|
-
* Sometimes those checks are made with the `typeof` operator, sometimes with strict equality checks.
|
|
93
|
-
*
|
|
94
|
-
* @param value - The value to test.
|
|
95
|
-
*
|
|
96
|
-
* @returns Whether or not the value is a primitive.
|
|
97
|
-
*
|
|
98
|
-
* @see isBigint
|
|
99
|
-
* @see isBoolean
|
|
100
|
-
* @see isNull
|
|
101
|
-
* @see isNumber
|
|
102
|
-
* @see isString
|
|
103
|
-
* @see isSymbol
|
|
104
|
-
* @see isUndefined
|
|
105
|
-
*/
|
|
106
|
-
export declare function isPrimitive(value: unknown): value is Primitive;
|
|
107
|
-
/**
|
|
108
|
-
* A type guard to assess that a value is a string.
|
|
109
|
-
*
|
|
110
|
-
* This function uses the `typeof` operator's definition of a string.
|
|
111
|
-
*
|
|
112
|
-
* @param value - The value to test.
|
|
113
|
-
*
|
|
114
|
-
* @returns Whether or not the value is a string.
|
|
115
|
-
*/
|
|
116
|
-
export declare function isString(value: unknown): value is string;
|
|
117
|
-
/**
|
|
118
|
-
* A type guard to assess that a value is a symbol.
|
|
119
|
-
*
|
|
120
|
-
* This function uses the `typeof` operator's definition of a symbol.
|
|
121
|
-
*
|
|
122
|
-
* @param value - The value to test.
|
|
123
|
-
*
|
|
124
|
-
* @returns Whether or not the value is a symbol.
|
|
125
|
-
*/
|
|
126
|
-
export declare function isSymbol(value: unknown): value is symbol;
|
|
127
|
-
/**
|
|
128
|
-
* A type guard to assess that a value is undefined.
|
|
129
|
-
*
|
|
130
|
-
* This function uses the `typeof` operator's definition of undefined.
|
|
131
|
-
*
|
|
132
|
-
* @param value - The value to test.
|
|
133
|
-
*
|
|
134
|
-
* @returns Whether or not the value is undefined.
|
|
135
|
-
*/
|
|
136
|
-
export declare function isUndefined(value: unknown): value is undefined;
|
package/lib/cjs/guard.js
CHANGED
|
@@ -1,108 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isBigint = isBigint;
|
|
4
|
-
exports.isBoolean = isBoolean;
|
|
5
|
-
exports.isFunction = isFunction;
|
|
6
|
-
exports.isNonNullable = isNonNullable;
|
|
7
|
-
exports.isNumber = isNumber;
|
|
8
|
-
exports.isNull = isNull;
|
|
9
|
-
exports.isObject = isObject;
|
|
10
3
|
exports.isObjectNotNull = isObjectNotNull;
|
|
11
|
-
exports.isPrimitive = isPrimitive;
|
|
12
|
-
exports.isString = isString;
|
|
13
|
-
exports.isSymbol = isSymbol;
|
|
14
|
-
exports.isUndefined = isUndefined;
|
|
15
|
-
/**
|
|
16
|
-
* A type guard to assess that a value is a bigint.
|
|
17
|
-
*
|
|
18
|
-
* This function uses the `typeof` operator's definition of a bigint.
|
|
19
|
-
*
|
|
20
|
-
* @param value - The value to test.
|
|
21
|
-
*
|
|
22
|
-
* @returns Whether or not the value is a bigint.
|
|
23
|
-
*/
|
|
24
|
-
function isBigint(value) {
|
|
25
|
-
return typeof value === "bigint";
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* A type guard to assess that a value is a boolean.
|
|
29
|
-
*
|
|
30
|
-
* This function uses the `typeof` operator's definition of a boolean.
|
|
31
|
-
*
|
|
32
|
-
* @param value - The value to test.
|
|
33
|
-
*
|
|
34
|
-
* @returns Whether or not the value is a boolean.
|
|
35
|
-
*/
|
|
36
|
-
function isBoolean(value) {
|
|
37
|
-
return typeof value === "boolean";
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* A type guard to assess that a value is a function.
|
|
41
|
-
*
|
|
42
|
-
* This function uses the `typeof` operator's definition of a function.
|
|
43
|
-
*
|
|
44
|
-
* @param value - The value to test.
|
|
45
|
-
*
|
|
46
|
-
* @returns Whether or not the value is a function.
|
|
47
|
-
*/
|
|
48
|
-
// biome-ignore lint/complexity/noBannedTypes: Function is the correct type here.
|
|
49
|
-
function isFunction(value) {
|
|
50
|
-
return typeof value === "function";
|
|
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
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* A type guard to assess that a value is a number.
|
|
66
|
-
*
|
|
67
|
-
* This function uses the `typeof` operator's definition of a number.
|
|
68
|
-
*
|
|
69
|
-
* @param value - The value to test.
|
|
70
|
-
*
|
|
71
|
-
* @returns Whether or not the value is a number.
|
|
72
|
-
*/
|
|
73
|
-
function isNumber(value) {
|
|
74
|
-
return typeof value === "number";
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* A type guard to assess that a value is null.
|
|
78
|
-
*
|
|
79
|
-
* This function uses the `===` operator to check for null.
|
|
80
|
-
*
|
|
81
|
-
* @param value - The value to test.
|
|
82
|
-
*
|
|
83
|
-
* @returns Whether or not the value is null.
|
|
84
|
-
*/
|
|
85
|
-
function isNull(value) {
|
|
86
|
-
return value === null;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* A type guard to assess that a value is an object.
|
|
90
|
-
*
|
|
91
|
-
* This function uses the `typeof` operator's definition of an object.
|
|
92
|
-
* If you need to exclude null, you can use the {@link isObjectNotNull} function instead.
|
|
93
|
-
*
|
|
94
|
-
* @param value - The value to test.
|
|
95
|
-
*
|
|
96
|
-
* @returns Whether or not the value is an object.
|
|
97
|
-
*/
|
|
98
|
-
function isObject(value) {
|
|
99
|
-
return typeof value === "object";
|
|
100
|
-
}
|
|
101
4
|
/**
|
|
102
5
|
* A type guard to assess that a value is an object and not null.
|
|
103
6
|
*
|
|
104
|
-
* This function
|
|
105
|
-
* is
|
|
7
|
+
* This function exists because {@link isObject} will return `true` for `null`.
|
|
8
|
+
* This is because `typeof null === "object"`. This function validates
|
|
9
|
+
* that `typeof value === "object" && value !== null`.
|
|
106
10
|
*
|
|
107
11
|
* @param value - The value to test.
|
|
108
12
|
*
|
|
@@ -111,71 +15,6 @@ function isObject(value) {
|
|
|
111
15
|
* @see isObject
|
|
112
16
|
*/
|
|
113
17
|
function isObjectNotNull(value) {
|
|
114
|
-
return
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* A type guard to assess that a value is a primitive.
|
|
118
|
-
*
|
|
119
|
-
* This function checks if the value is one of the primitive types:
|
|
120
|
-
* bigint, boolean, null, number, string, symbol, or undefined.
|
|
121
|
-
*
|
|
122
|
-
* Sometimes those checks are made with the `typeof` operator, sometimes with strict equality checks.
|
|
123
|
-
*
|
|
124
|
-
* @param value - The value to test.
|
|
125
|
-
*
|
|
126
|
-
* @returns Whether or not the value is a primitive.
|
|
127
|
-
*
|
|
128
|
-
* @see isBigint
|
|
129
|
-
* @see isBoolean
|
|
130
|
-
* @see isNull
|
|
131
|
-
* @see isNumber
|
|
132
|
-
* @see isString
|
|
133
|
-
* @see isSymbol
|
|
134
|
-
* @see isUndefined
|
|
135
|
-
*/
|
|
136
|
-
function isPrimitive(value) {
|
|
137
|
-
return (isBigint(value) ||
|
|
138
|
-
isBoolean(value) ||
|
|
139
|
-
isNull(value) ||
|
|
140
|
-
isNumber(value) ||
|
|
141
|
-
isString(value) ||
|
|
142
|
-
isSymbol(value) ||
|
|
143
|
-
isUndefined(value));
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* A type guard to assess that a value is a string.
|
|
147
|
-
*
|
|
148
|
-
* This function uses the `typeof` operator's definition of a string.
|
|
149
|
-
*
|
|
150
|
-
* @param value - The value to test.
|
|
151
|
-
*
|
|
152
|
-
* @returns Whether or not the value is a string.
|
|
153
|
-
*/
|
|
154
|
-
function isString(value) {
|
|
155
|
-
return typeof value === "string";
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* A type guard to assess that a value is a symbol.
|
|
159
|
-
*
|
|
160
|
-
* This function uses the `typeof` operator's definition of a symbol.
|
|
161
|
-
*
|
|
162
|
-
* @param value - The value to test.
|
|
163
|
-
*
|
|
164
|
-
* @returns Whether or not the value is a symbol.
|
|
165
|
-
*/
|
|
166
|
-
function isSymbol(value) {
|
|
167
|
-
return typeof value === "symbol";
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* A type guard to assess that a value is undefined.
|
|
171
|
-
*
|
|
172
|
-
* This function uses the `typeof` operator's definition of undefined.
|
|
173
|
-
*
|
|
174
|
-
* @param value - The value to test.
|
|
175
|
-
*
|
|
176
|
-
* @returns Whether or not the value is undefined.
|
|
177
|
-
*/
|
|
178
|
-
function isUndefined(value) {
|
|
179
|
-
return typeof value === "undefined";
|
|
18
|
+
return typeof value === "object" && value !== null;
|
|
180
19
|
}
|
|
181
20
|
//# sourceMappingURL=guard.js.map
|
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":";;AAaA,0CAEC;AAfD;;;;;;;;;;;;GAYG;AACH,SAAgB,eAAe,CAAC,KAAc;IAC5C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACrD,CAAC"}
|
package/lib/cjs/index.d.ts
CHANGED
package/lib/cjs/index.js
CHANGED
|
@@ -20,7 +20,6 @@ const node_assert_1 = require("node:assert");
|
|
|
20
20
|
__exportStar(require("./func.js"), exports);
|
|
21
21
|
__exportStar(require("./guard.js"), exports);
|
|
22
22
|
__exportStar(require("./keys.js"), exports);
|
|
23
|
-
__exportStar(require("./predicates.js"), exports);
|
|
24
23
|
__exportStar(require("./types.js"), exports);
|
|
25
24
|
// TODO: Message type, that is either: undefined, a string, a string followed by format args or a function returning a string.
|
|
26
25
|
/**
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AA+BA,kCAEC;AAsBD,0BAEC;AAzDD,6CAAmC;AAEnC,4CAA0B;AAC1B,6CAA2B;AAC3B,4CAA0B;AAC1B,6CAA2B;AAE3B,8HAA8H;AAC9H;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,SAAgB,WAAW,CAAC,CAAQ,EAAE,OAAgB;IACpD,IAAA,kBAAI,EAAC,OAAO,IAAI,2BAA2B,CAAC,CAAC;AAC/C,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,OAAO,CAAI,KAAc;IACvC,OAAO,KAAU,CAAC;AACpB,CAAC"}
|
package/lib/esm/guard.d.ts
CHANGED
|
@@ -1,80 +1,9 @@
|
|
|
1
|
-
import type { Primitive } from "./types.js";
|
|
2
|
-
/**
|
|
3
|
-
* A type guard to assess that a value is a bigint.
|
|
4
|
-
*
|
|
5
|
-
* This function uses the `typeof` operator's definition of a bigint.
|
|
6
|
-
*
|
|
7
|
-
* @param value - The value to test.
|
|
8
|
-
*
|
|
9
|
-
* @returns Whether or not the value is a bigint.
|
|
10
|
-
*/
|
|
11
|
-
export declare function isBigint(value: unknown): value is bigint;
|
|
12
|
-
/**
|
|
13
|
-
* A type guard to assess that a value is a boolean.
|
|
14
|
-
*
|
|
15
|
-
* This function uses the `typeof` operator's definition of a boolean.
|
|
16
|
-
*
|
|
17
|
-
* @param value - The value to test.
|
|
18
|
-
*
|
|
19
|
-
* @returns Whether or not the value is a boolean.
|
|
20
|
-
*/
|
|
21
|
-
export declare function isBoolean(value: unknown): value is boolean;
|
|
22
|
-
/**
|
|
23
|
-
* A type guard to assess that a value is a function.
|
|
24
|
-
*
|
|
25
|
-
* This function uses the `typeof` operator's definition of a function.
|
|
26
|
-
*
|
|
27
|
-
* @param value - The value to test.
|
|
28
|
-
*
|
|
29
|
-
* @returns Whether or not the value is a function.
|
|
30
|
-
*/
|
|
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>;
|
|
42
|
-
/**
|
|
43
|
-
* A type guard to assess that a value is a number.
|
|
44
|
-
*
|
|
45
|
-
* This function uses the `typeof` operator's definition of a number.
|
|
46
|
-
*
|
|
47
|
-
* @param value - The value to test.
|
|
48
|
-
*
|
|
49
|
-
* @returns Whether or not the value is a number.
|
|
50
|
-
*/
|
|
51
|
-
export declare function isNumber(value: unknown): value is number;
|
|
52
|
-
/**
|
|
53
|
-
* A type guard to assess that a value is null.
|
|
54
|
-
*
|
|
55
|
-
* This function uses the `===` operator to check for null.
|
|
56
|
-
*
|
|
57
|
-
* @param value - The value to test.
|
|
58
|
-
*
|
|
59
|
-
* @returns Whether or not the value is null.
|
|
60
|
-
*/
|
|
61
|
-
export declare function isNull(value: unknown): value is null;
|
|
62
|
-
/**
|
|
63
|
-
* A type guard to assess that a value is an object.
|
|
64
|
-
*
|
|
65
|
-
* This function uses the `typeof` operator's definition of an object.
|
|
66
|
-
* If you need to exclude null, you can use the {@link isObjectNotNull} function instead.
|
|
67
|
-
*
|
|
68
|
-
* @param value - The value to test.
|
|
69
|
-
*
|
|
70
|
-
* @returns Whether or not the value is an object.
|
|
71
|
-
*/
|
|
72
|
-
export declare function isObject(value: unknown): value is object | null;
|
|
73
1
|
/**
|
|
74
2
|
* A type guard to assess that a value is an object and not null.
|
|
75
3
|
*
|
|
76
|
-
* This function
|
|
77
|
-
* is
|
|
4
|
+
* This function exists because {@link isObject} will return `true` for `null`.
|
|
5
|
+
* This is because `typeof null === "object"`. This function validates
|
|
6
|
+
* that `typeof value === "object" && value !== null`.
|
|
78
7
|
*
|
|
79
8
|
* @param value - The value to test.
|
|
80
9
|
*
|
|
@@ -83,54 +12,3 @@ export declare function isObject(value: unknown): value is object | null;
|
|
|
83
12
|
* @see isObject
|
|
84
13
|
*/
|
|
85
14
|
export declare function isObjectNotNull(value: unknown): value is object;
|
|
86
|
-
/**
|
|
87
|
-
* A type guard to assess that a value is a primitive.
|
|
88
|
-
*
|
|
89
|
-
* This function checks if the value is one of the primitive types:
|
|
90
|
-
* bigint, boolean, null, number, string, symbol, or undefined.
|
|
91
|
-
*
|
|
92
|
-
* Sometimes those checks are made with the `typeof` operator, sometimes with strict equality checks.
|
|
93
|
-
*
|
|
94
|
-
* @param value - The value to test.
|
|
95
|
-
*
|
|
96
|
-
* @returns Whether or not the value is a primitive.
|
|
97
|
-
*
|
|
98
|
-
* @see isBigint
|
|
99
|
-
* @see isBoolean
|
|
100
|
-
* @see isNull
|
|
101
|
-
* @see isNumber
|
|
102
|
-
* @see isString
|
|
103
|
-
* @see isSymbol
|
|
104
|
-
* @see isUndefined
|
|
105
|
-
*/
|
|
106
|
-
export declare function isPrimitive(value: unknown): value is Primitive;
|
|
107
|
-
/**
|
|
108
|
-
* A type guard to assess that a value is a string.
|
|
109
|
-
*
|
|
110
|
-
* This function uses the `typeof` operator's definition of a string.
|
|
111
|
-
*
|
|
112
|
-
* @param value - The value to test.
|
|
113
|
-
*
|
|
114
|
-
* @returns Whether or not the value is a string.
|
|
115
|
-
*/
|
|
116
|
-
export declare function isString(value: unknown): value is string;
|
|
117
|
-
/**
|
|
118
|
-
* A type guard to assess that a value is a symbol.
|
|
119
|
-
*
|
|
120
|
-
* This function uses the `typeof` operator's definition of a symbol.
|
|
121
|
-
*
|
|
122
|
-
* @param value - The value to test.
|
|
123
|
-
*
|
|
124
|
-
* @returns Whether or not the value is a symbol.
|
|
125
|
-
*/
|
|
126
|
-
export declare function isSymbol(value: unknown): value is symbol;
|
|
127
|
-
/**
|
|
128
|
-
* A type guard to assess that a value is undefined.
|
|
129
|
-
*
|
|
130
|
-
* This function uses the `typeof` operator's definition of undefined.
|
|
131
|
-
*
|
|
132
|
-
* @param value - The value to test.
|
|
133
|
-
*
|
|
134
|
-
* @returns Whether or not the value is undefined.
|
|
135
|
-
*/
|
|
136
|
-
export declare function isUndefined(value: unknown): value is undefined;
|
package/lib/esm/guard.js
CHANGED
|
@@ -1,94 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A type guard to assess that a value is a bigint.
|
|
3
|
-
*
|
|
4
|
-
* This function uses the `typeof` operator's definition of a bigint.
|
|
5
|
-
*
|
|
6
|
-
* @param value - The value to test.
|
|
7
|
-
*
|
|
8
|
-
* @returns Whether or not the value is a bigint.
|
|
9
|
-
*/
|
|
10
|
-
export function isBigint(value) {
|
|
11
|
-
return typeof value === "bigint";
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* A type guard to assess that a value is a boolean.
|
|
15
|
-
*
|
|
16
|
-
* This function uses the `typeof` operator's definition of a boolean.
|
|
17
|
-
*
|
|
18
|
-
* @param value - The value to test.
|
|
19
|
-
*
|
|
20
|
-
* @returns Whether or not the value is a boolean.
|
|
21
|
-
*/
|
|
22
|
-
export function isBoolean(value) {
|
|
23
|
-
return typeof value === "boolean";
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* A type guard to assess that a value is a function.
|
|
27
|
-
*
|
|
28
|
-
* This function uses the `typeof` operator's definition of a function.
|
|
29
|
-
*
|
|
30
|
-
* @param value - The value to test.
|
|
31
|
-
*
|
|
32
|
-
* @returns Whether or not the value is a function.
|
|
33
|
-
*/
|
|
34
|
-
// biome-ignore lint/complexity/noBannedTypes: Function is the correct type here.
|
|
35
|
-
export function isFunction(value) {
|
|
36
|
-
return typeof value === "function";
|
|
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
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* A type guard to assess that a value is a number.
|
|
52
|
-
*
|
|
53
|
-
* This function uses the `typeof` operator's definition of a number.
|
|
54
|
-
*
|
|
55
|
-
* @param value - The value to test.
|
|
56
|
-
*
|
|
57
|
-
* @returns Whether or not the value is a number.
|
|
58
|
-
*/
|
|
59
|
-
export function isNumber(value) {
|
|
60
|
-
return typeof value === "number";
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* A type guard to assess that a value is null.
|
|
64
|
-
*
|
|
65
|
-
* This function uses the `===` operator to check for null.
|
|
66
|
-
*
|
|
67
|
-
* @param value - The value to test.
|
|
68
|
-
*
|
|
69
|
-
* @returns Whether or not the value is null.
|
|
70
|
-
*/
|
|
71
|
-
export function isNull(value) {
|
|
72
|
-
return value === null;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* A type guard to assess that a value is an object.
|
|
76
|
-
*
|
|
77
|
-
* This function uses the `typeof` operator's definition of an object.
|
|
78
|
-
* If you need to exclude null, you can use the {@link isObjectNotNull} function instead.
|
|
79
|
-
*
|
|
80
|
-
* @param value - The value to test.
|
|
81
|
-
*
|
|
82
|
-
* @returns Whether or not the value is an object.
|
|
83
|
-
*/
|
|
84
|
-
export function isObject(value) {
|
|
85
|
-
return typeof value === "object";
|
|
86
|
-
}
|
|
87
1
|
/**
|
|
88
2
|
* A type guard to assess that a value is an object and not null.
|
|
89
3
|
*
|
|
90
|
-
* This function
|
|
91
|
-
* is
|
|
4
|
+
* This function exists because {@link isObject} will return `true` for `null`.
|
|
5
|
+
* This is because `typeof null === "object"`. This function validates
|
|
6
|
+
* that `typeof value === "object" && value !== null`.
|
|
92
7
|
*
|
|
93
8
|
* @param value - The value to test.
|
|
94
9
|
*
|
|
@@ -97,71 +12,6 @@ export function isObject(value) {
|
|
|
97
12
|
* @see isObject
|
|
98
13
|
*/
|
|
99
14
|
export function isObjectNotNull(value) {
|
|
100
|
-
return
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* A type guard to assess that a value is a primitive.
|
|
104
|
-
*
|
|
105
|
-
* This function checks if the value is one of the primitive types:
|
|
106
|
-
* bigint, boolean, null, number, string, symbol, or undefined.
|
|
107
|
-
*
|
|
108
|
-
* Sometimes those checks are made with the `typeof` operator, sometimes with strict equality checks.
|
|
109
|
-
*
|
|
110
|
-
* @param value - The value to test.
|
|
111
|
-
*
|
|
112
|
-
* @returns Whether or not the value is a primitive.
|
|
113
|
-
*
|
|
114
|
-
* @see isBigint
|
|
115
|
-
* @see isBoolean
|
|
116
|
-
* @see isNull
|
|
117
|
-
* @see isNumber
|
|
118
|
-
* @see isString
|
|
119
|
-
* @see isSymbol
|
|
120
|
-
* @see isUndefined
|
|
121
|
-
*/
|
|
122
|
-
export function isPrimitive(value) {
|
|
123
|
-
return (isBigint(value) ||
|
|
124
|
-
isBoolean(value) ||
|
|
125
|
-
isNull(value) ||
|
|
126
|
-
isNumber(value) ||
|
|
127
|
-
isString(value) ||
|
|
128
|
-
isSymbol(value) ||
|
|
129
|
-
isUndefined(value));
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* A type guard to assess that a value is a string.
|
|
133
|
-
*
|
|
134
|
-
* This function uses the `typeof` operator's definition of a string.
|
|
135
|
-
*
|
|
136
|
-
* @param value - The value to test.
|
|
137
|
-
*
|
|
138
|
-
* @returns Whether or not the value is a string.
|
|
139
|
-
*/
|
|
140
|
-
export function isString(value) {
|
|
141
|
-
return typeof value === "string";
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* A type guard to assess that a value is a symbol.
|
|
145
|
-
*
|
|
146
|
-
* This function uses the `typeof` operator's definition of a symbol.
|
|
147
|
-
*
|
|
148
|
-
* @param value - The value to test.
|
|
149
|
-
*
|
|
150
|
-
* @returns Whether or not the value is a symbol.
|
|
151
|
-
*/
|
|
152
|
-
export function isSymbol(value) {
|
|
153
|
-
return typeof value === "symbol";
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* A type guard to assess that a value is undefined.
|
|
157
|
-
*
|
|
158
|
-
* This function uses the `typeof` operator's definition of undefined.
|
|
159
|
-
*
|
|
160
|
-
* @param value - The value to test.
|
|
161
|
-
*
|
|
162
|
-
* @returns Whether or not the value is undefined.
|
|
163
|
-
*/
|
|
164
|
-
export function isUndefined(value) {
|
|
165
|
-
return typeof value === "undefined";
|
|
15
|
+
return typeof value === "object" && value !== null;
|
|
166
16
|
}
|
|
167
17
|
//# sourceMappingURL=guard.js.map
|
package/lib/esm/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":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACrD,CAAC"}
|
package/lib/esm/index.d.ts
CHANGED
package/lib/esm/index.js
CHANGED
|
@@ -2,7 +2,6 @@ import { fail } from "node:assert";
|
|
|
2
2
|
export * from "./func.js";
|
|
3
3
|
export * from "./guard.js";
|
|
4
4
|
export * from "./keys.js";
|
|
5
|
-
export * from "./predicates.js";
|
|
6
5
|
export * from "./types.js";
|
|
7
6
|
// TODO: Message type, that is either: undefined, a string, a string followed by format args or a function returning a string.
|
|
8
7
|
/**
|
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEnC,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEnC,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAE3B,8HAA8H;AAC9H;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,WAAW,CAAC,CAAQ,EAAE,OAAgB;IACpD,IAAI,CAAC,OAAO,IAAI,2BAA2B,CAAC,CAAC;AAC/C,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,OAAO,CAAI,KAAc;IACvC,OAAO,KAAU,CAAC;AACpB,CAAC"}
|
package/package.json
CHANGED
package/lib/cjs/predicates.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A type predicate to determine if a value is a plain object.
|
|
3
|
-
*
|
|
4
|
-
* A plain object is created either with the object literal syntax or with the Object constructor.
|
|
5
|
-
* Any other type of object will not satisfy this predicate.
|
|
6
|
-
*
|
|
7
|
-
* @param value - The value to test.
|
|
8
|
-
*
|
|
9
|
-
* @returns Whether or not the value is a plain object.
|
|
10
|
-
*/
|
|
11
|
-
export declare function isPlainObject(value: unknown): boolean;
|
package/lib/cjs/predicates.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isPlainObject = isPlainObject;
|
|
4
|
-
const guard_js_1 = require("./guard.js");
|
|
5
|
-
/**
|
|
6
|
-
* A type predicate to determine if a value is a plain object.
|
|
7
|
-
*
|
|
8
|
-
* A plain object is created either with the object literal syntax or with the Object constructor.
|
|
9
|
-
* Any other type of object will not satisfy this predicate.
|
|
10
|
-
*
|
|
11
|
-
* @param value - The value to test.
|
|
12
|
-
*
|
|
13
|
-
* @returns Whether or not the value is a plain object.
|
|
14
|
-
*/
|
|
15
|
-
function isPlainObject(value) {
|
|
16
|
-
return (0, guard_js_1.isObjectNotNull)(value) && value.constructor === Object;
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=predicates.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"predicates.js","sourceRoot":"","sources":["../../src/predicates.ts"],"names":[],"mappings":";;AAYA,sCAEC;AAdD,yCAA6C;AAE7C;;;;;;;;;GASG;AACH,SAAgB,aAAa,CAAC,KAAc;IAC1C,OAAO,IAAA,0BAAe,EAAC,KAAK,CAAC,IAAI,KAAK,CAAC,WAAW,KAAK,MAAM,CAAC;AAChE,CAAC"}
|
package/lib/esm/predicates.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A type predicate to determine if a value is a plain object.
|
|
3
|
-
*
|
|
4
|
-
* A plain object is created either with the object literal syntax or with the Object constructor.
|
|
5
|
-
* Any other type of object will not satisfy this predicate.
|
|
6
|
-
*
|
|
7
|
-
* @param value - The value to test.
|
|
8
|
-
*
|
|
9
|
-
* @returns Whether or not the value is a plain object.
|
|
10
|
-
*/
|
|
11
|
-
export declare function isPlainObject(value: unknown): boolean;
|
package/lib/esm/predicates.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { isObjectNotNull } from "./guard.js";
|
|
2
|
-
/**
|
|
3
|
-
* A type predicate to determine if a value is a plain object.
|
|
4
|
-
*
|
|
5
|
-
* A plain object is created either with the object literal syntax or with the Object constructor.
|
|
6
|
-
* Any other type of object will not satisfy this predicate.
|
|
7
|
-
*
|
|
8
|
-
* @param value - The value to test.
|
|
9
|
-
*
|
|
10
|
-
* @returns Whether or not the value is a plain object.
|
|
11
|
-
*/
|
|
12
|
-
export function isPlainObject(value) {
|
|
13
|
-
return isObjectNotNull(value) && value.constructor === Object;
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=predicates.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"predicates.js","sourceRoot":"","sources":["../../src/predicates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;;;;;;GASG;AACH,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,OAAO,eAAe,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,WAAW,KAAK,MAAM,CAAC;AAChE,CAAC"}
|