@infra-blocks/types 0.10.0-alpha.0 → 0.11.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.
@@ -1,44 +1,123 @@
1
1
  /**
2
- * A convenient Typescript type guard function to assess that a value is a string.
2
+ * A type guard to assess that a value is a bigint.
3
3
  *
4
- * @remark
5
- * This function is mostly meant as a Typescript type guard. See:
6
- * https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
4
+ * This function uses the `typeof` operator's definition of a bigint.
7
5
  *
8
6
  * @param value - The value to test.
9
- * @returns Whether or not the value is a string.
7
+ *
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
10
11
  */
11
- export declare function isString(value: unknown): value is string;
12
+ export declare function isBigint(value: unknown): value is bigint;
12
13
  /**
13
- * A convenient Typescript type guard function to assess that a value is a symbol.
14
+ * A type guard to assess that a value is a boolean.
14
15
  *
15
- * @remark
16
- * This function is mostly meant as a Typescript type guard. See:
17
- * https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
16
+ * This function uses the `typeof` operator's definition of a boolean.
18
17
  *
19
18
  * @param value - The value to test.
20
- * @returns Whether or not the value is a symbol.
19
+ *
20
+ * @returns Whether or not the value is a boolean.
21
+ *
22
+ * @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
21
23
  */
22
- export declare function isSymbol(value: unknown): value is symbol;
24
+ export declare function isBoolean(value: unknown): value is boolean;
23
25
  /**
24
- * A convenient Typescript type guard function to assess that a value is a number.
26
+ * A type guard to assess that a value is a function.
25
27
  *
26
- * @remark
27
- * This function is mostly meant as a Typescript type guard. See:
28
- * https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
28
+ * This function uses the `typeof` operator's definition of a function.
29
29
  *
30
30
  * @param value - The value to test.
31
+ *
32
+ * @returns Whether or not the value is a function.
33
+ *
34
+ * @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
35
+ */
36
+ export declare function isFunction(value: unknown): value is Function;
37
+ /**
38
+ * A type guard to assess that a value is a number.
39
+ *
40
+ * This function uses the `typeof` operator's definition of a number.
41
+ *
42
+ * @param value - The value to test.
43
+ *
31
44
  * @returns Whether or not the value is a number.
45
+ *
46
+ * @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
32
47
  */
33
48
  export declare function isNumber(value: unknown): value is number;
34
49
  /**
35
- * A convenient Typescript type guard function to assess that a value is a function.
50
+ * A type guard to assess that a value is null.
36
51
  *
37
- * @remark
38
- * * This function is mostly meant as a Typescript type guard. See:
39
- * https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
52
+ * This function uses the `===` operator to check for null.
40
53
  *
41
54
  * @param value - The value to test.
42
- * @returns Whether or not the value is a function.
55
+ *
56
+ * @returns Whether or not the value is null.
57
+ *
58
+ * @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
43
59
  */
44
- export declare function isFunction(value: unknown): value is Function;
60
+ export declare function isNull(value: unknown): value is null;
61
+ /**
62
+ * A type guard to assess that a value is an object.
63
+ *
64
+ * This function uses the `typeof` operator's definition of an object.
65
+ * If you need to exclude null, you can use the {@link isObjectNotNull} function instead.
66
+ *
67
+ * @param value - The value to test.
68
+ *
69
+ * @returns Whether or not the value is an object.
70
+ *
71
+ * @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
72
+ */
73
+ export declare function isObject(value: unknown): value is object;
74
+ /**
75
+ * A type guard to assess that a value is an object and not null.
76
+ *
77
+ * This function uses {@link isObject} and {@link isNull} to determine if the value
78
+ * is an object that is not null.
79
+ *
80
+ * @param value - The value to test.
81
+ *
82
+ * @returns Whether or not the value is an object and not null.
83
+ *
84
+ * @see isObject
85
+ * @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
86
+ */
87
+ export declare function isObjectNotNull(value: unknown): value is object;
88
+ /**
89
+ * A type guard to assess that a value is a string.
90
+ *
91
+ * This function uses the `typeof` operator's definition of a string.
92
+ *
93
+ * @param value - The value to test.
94
+ *
95
+ * @returns Whether or not the value is a string.
96
+ *
97
+ * @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
98
+ */
99
+ export declare function isString(value: unknown): value is string;
100
+ /**
101
+ * A type guard to assess that a value is a symbol.
102
+ *
103
+ * This function uses the `typeof` operator's definition of a symbol.
104
+ *
105
+ * @param value - The value to test.
106
+ *
107
+ * @returns Whether or not the value is a symbol.
108
+ *
109
+ * @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
110
+ */
111
+ export declare function isSymbol(value: unknown): value is symbol;
112
+ /**
113
+ * A type guard to assess that a value is undefined.
114
+ *
115
+ * This function uses the `typeof` operator's definition of undefined.
116
+ *
117
+ * @param value - The value to test.
118
+ *
119
+ * @returns Whether or not the value is undefined.
120
+ *
121
+ * @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
122
+ */
123
+ export declare function isUndefined(value: unknown): value is undefined;
package/lib/cjs/guard.js CHANGED
@@ -1,61 +1,158 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isFunction = exports.isNumber = exports.isSymbol = exports.isString = void 0;
3
+ exports.isUndefined = exports.isSymbol = exports.isString = exports.isObjectNotNull = exports.isObject = exports.isNull = exports.isNumber = exports.isFunction = exports.isBoolean = exports.isBigint = void 0;
4
4
  /**
5
- * A convenient Typescript type guard function to assess that a value is a string.
5
+ * A type guard to assess that a value is a bigint.
6
6
  *
7
- * @remark
8
- * This function is mostly meant as a Typescript type guard. See:
9
- * https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
7
+ * This function uses the `typeof` operator's definition of a bigint.
10
8
  *
11
9
  * @param value - The value to test.
12
- * @returns Whether or not the value is a string.
10
+ *
11
+ * @returns Whether or not the value is a bigint.
12
+ *
13
+ * @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
13
14
  */
14
- function isString(value) {
15
- return typeof value === "string";
15
+ function isBigint(value) {
16
+ return typeof value === "bigint";
16
17
  }
17
- exports.isString = isString;
18
+ exports.isBigint = isBigint;
18
19
  /**
19
- * A convenient Typescript type guard function to assess that a value is a symbol.
20
+ * A type guard to assess that a value is a boolean.
20
21
  *
21
- * @remark
22
- * This function is mostly meant as a Typescript type guard. See:
23
- * https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
22
+ * This function uses the `typeof` operator's definition of a boolean.
24
23
  *
25
24
  * @param value - The value to test.
26
- * @returns Whether or not the value is a symbol.
25
+ *
26
+ * @returns Whether or not the value is a boolean.
27
+ *
28
+ * @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
27
29
  */
28
- function isSymbol(value) {
29
- return typeof value === "symbol";
30
+ function isBoolean(value) {
31
+ return typeof value === "boolean";
30
32
  }
31
- exports.isSymbol = isSymbol;
33
+ exports.isBoolean = isBoolean;
32
34
  /**
33
- * A convenient Typescript type guard function to assess that a value is a number.
35
+ * A type guard to assess that a value is a function.
34
36
  *
35
- * @remark
36
- * This function is mostly meant as a Typescript type guard. See:
37
- * https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
37
+ * This function uses the `typeof` operator's definition of a function.
38
38
  *
39
39
  * @param value - The value to test.
40
+ *
41
+ * @returns Whether or not the value is a function.
42
+ *
43
+ * @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
44
+ */
45
+ // eslint-disable-next-line @typescript-eslint/ban-types
46
+ function isFunction(value) {
47
+ return typeof value === "function";
48
+ }
49
+ exports.isFunction = isFunction;
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
+ *
40
57
  * @returns Whether or not the value is a number.
58
+ *
59
+ * @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
41
60
  */
42
61
  function isNumber(value) {
43
62
  return typeof value === "number";
44
63
  }
45
64
  exports.isNumber = isNumber;
46
65
  /**
47
- * A convenient Typescript type guard function to assess that a value is a function.
66
+ * A type guard to assess that a value is null.
48
67
  *
49
- * @remark
50
- * * This function is mostly meant as a Typescript type guard. See:
51
- * https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
68
+ * This function uses the `===` operator to check for null.
52
69
  *
53
70
  * @param value - The value to test.
54
- * @returns Whether or not the value is a function.
71
+ *
72
+ * @returns Whether or not the value is null.
73
+ *
74
+ * @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
55
75
  */
56
- // eslint-disable-next-line @typescript-eslint/ban-types
57
- function isFunction(value) {
58
- return typeof value === "function";
76
+ function isNull(value) {
77
+ return value === null;
59
78
  }
60
- exports.isFunction = isFunction;
79
+ exports.isNull = isNull;
80
+ /**
81
+ * A type guard to assess that a value is an object.
82
+ *
83
+ * This function uses the `typeof` operator's definition of an object.
84
+ * If you need to exclude null, you can use the {@link isObjectNotNull} function instead.
85
+ *
86
+ * @param value - The value to test.
87
+ *
88
+ * @returns Whether or not the value is an object.
89
+ *
90
+ * @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
91
+ */
92
+ function isObject(value) {
93
+ return typeof value === "object";
94
+ }
95
+ exports.isObject = isObject;
96
+ /**
97
+ * A type guard to assess that a value is an object and not null.
98
+ *
99
+ * This function uses {@link isObject} and {@link isNull} to determine if the value
100
+ * is an object that is not null.
101
+ *
102
+ * @param value - The value to test.
103
+ *
104
+ * @returns Whether or not the value is an object and not null.
105
+ *
106
+ * @see isObject
107
+ * @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
108
+ */
109
+ function isObjectNotNull(value) {
110
+ return !isNull(value) && typeof value === "object";
111
+ }
112
+ exports.isObjectNotNull = isObjectNotNull;
113
+ /**
114
+ * A type guard to assess that a value is a string.
115
+ *
116
+ * This function uses the `typeof` operator's definition of a string.
117
+ *
118
+ * @param value - The value to test.
119
+ *
120
+ * @returns Whether or not the value is a string.
121
+ *
122
+ * @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
123
+ */
124
+ function isString(value) {
125
+ return typeof value === "string";
126
+ }
127
+ exports.isString = isString;
128
+ /**
129
+ * A type guard to assess that a value is a symbol.
130
+ *
131
+ * This function uses the `typeof` operator's definition of a symbol.
132
+ *
133
+ * @param value - The value to test.
134
+ *
135
+ * @returns Whether or not the value is a symbol.
136
+ *
137
+ * @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
138
+ */
139
+ function isSymbol(value) {
140
+ return typeof value === "symbol";
141
+ }
142
+ exports.isSymbol = isSymbol;
143
+ /**
144
+ * A type guard to assess that a value is undefined.
145
+ *
146
+ * This function uses the `typeof` operator's definition of undefined.
147
+ *
148
+ * @param value - The value to test.
149
+ *
150
+ * @returns Whether or not the value is undefined.
151
+ *
152
+ * @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
153
+ */
154
+ function isUndefined(value) {
155
+ return typeof value === "undefined";
156
+ }
157
+ exports.isUndefined = isUndefined;
61
158
  //# sourceMappingURL=guard.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"guard.js","sourceRoot":"","sources":["../../src/guard.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;GASG;AACH,SAAgB,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC;AAFD,4BAEC;AAED;;;;;;;;;GASG;AACH,SAAgB,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC;AAFD,4BAEC;AAED;;;;;;;;;GASG;AACH,SAAgB,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC;AAFD,4BAEC;AAED;;;;;;;;;GASG;AACH,wDAAwD;AACxD,SAAgB,UAAU,CAAC,KAAc;IACvC,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC;AACrC,CAAC;AAFD,gCAEC"}
1
+ {"version":3,"file":"guard.js","sourceRoot":"","sources":["../../src/guard.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;GAUG;AACH,SAAgB,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC;AAFD,4BAEC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,SAAS,CAAC,KAAc;IACtC,OAAO,OAAO,KAAK,KAAK,SAAS,CAAC;AACpC,CAAC;AAFD,8BAEC;AAED;;;;;;;;;;GAUG;AACH,wDAAwD;AACxD,SAAgB,UAAU,CAAC,KAAc;IACvC,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC;AACrC,CAAC;AAFD,gCAEC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC;AAFD,4BAEC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,MAAM,CAAC,KAAc;IACnC,OAAO,KAAK,KAAK,IAAI,CAAC;AACxB,CAAC;AAFD,wBAEC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC;AAFD,4BAEC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,eAAe,CAAC,KAAc;IAC5C,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC;AACrD,CAAC;AAFD,0CAEC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC;AAFD,4BAEC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC;AAFD,4BAEC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,WAAW,CAAC,KAAc;IACxC,OAAO,OAAO,KAAK,KAAK,WAAW,CAAC;AACtC,CAAC;AAFD,kCAEC"}
@@ -1,44 +1,123 @@
1
1
  /**
2
- * A convenient Typescript type guard function to assess that a value is a string.
2
+ * A type guard to assess that a value is a bigint.
3
3
  *
4
- * @remark
5
- * This function is mostly meant as a Typescript type guard. See:
6
- * https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
4
+ * This function uses the `typeof` operator's definition of a bigint.
7
5
  *
8
6
  * @param value - The value to test.
9
- * @returns Whether or not the value is a string.
7
+ *
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
10
11
  */
11
- export declare function isString(value: unknown): value is string;
12
+ export declare function isBigint(value: unknown): value is bigint;
12
13
  /**
13
- * A convenient Typescript type guard function to assess that a value is a symbol.
14
+ * A type guard to assess that a value is a boolean.
14
15
  *
15
- * @remark
16
- * This function is mostly meant as a Typescript type guard. See:
17
- * https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
16
+ * This function uses the `typeof` operator's definition of a boolean.
18
17
  *
19
18
  * @param value - The value to test.
20
- * @returns Whether or not the value is a symbol.
19
+ *
20
+ * @returns Whether or not the value is a boolean.
21
+ *
22
+ * @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
21
23
  */
22
- export declare function isSymbol(value: unknown): value is symbol;
24
+ export declare function isBoolean(value: unknown): value is boolean;
23
25
  /**
24
- * A convenient Typescript type guard function to assess that a value is a number.
26
+ * A type guard to assess that a value is a function.
25
27
  *
26
- * @remark
27
- * This function is mostly meant as a Typescript type guard. See:
28
- * https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
28
+ * This function uses the `typeof` operator's definition of a function.
29
29
  *
30
30
  * @param value - The value to test.
31
+ *
32
+ * @returns Whether or not the value is a function.
33
+ *
34
+ * @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
35
+ */
36
+ export declare function isFunction(value: unknown): value is Function;
37
+ /**
38
+ * A type guard to assess that a value is a number.
39
+ *
40
+ * This function uses the `typeof` operator's definition of a number.
41
+ *
42
+ * @param value - The value to test.
43
+ *
31
44
  * @returns Whether or not the value is a number.
45
+ *
46
+ * @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
32
47
  */
33
48
  export declare function isNumber(value: unknown): value is number;
34
49
  /**
35
- * A convenient Typescript type guard function to assess that a value is a function.
50
+ * A type guard to assess that a value is null.
36
51
  *
37
- * @remark
38
- * * This function is mostly meant as a Typescript type guard. See:
39
- * https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
52
+ * This function uses the `===` operator to check for null.
40
53
  *
41
54
  * @param value - The value to test.
42
- * @returns Whether or not the value is a function.
55
+ *
56
+ * @returns Whether or not the value is null.
57
+ *
58
+ * @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
43
59
  */
44
- export declare function isFunction(value: unknown): value is Function;
60
+ export declare function isNull(value: unknown): value is null;
61
+ /**
62
+ * A type guard to assess that a value is an object.
63
+ *
64
+ * This function uses the `typeof` operator's definition of an object.
65
+ * If you need to exclude null, you can use the {@link isObjectNotNull} function instead.
66
+ *
67
+ * @param value - The value to test.
68
+ *
69
+ * @returns Whether or not the value is an object.
70
+ *
71
+ * @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
72
+ */
73
+ export declare function isObject(value: unknown): value is object;
74
+ /**
75
+ * A type guard to assess that a value is an object and not null.
76
+ *
77
+ * This function uses {@link isObject} and {@link isNull} to determine if the value
78
+ * is an object that is not null.
79
+ *
80
+ * @param value - The value to test.
81
+ *
82
+ * @returns Whether or not the value is an object and not null.
83
+ *
84
+ * @see isObject
85
+ * @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
86
+ */
87
+ export declare function isObjectNotNull(value: unknown): value is object;
88
+ /**
89
+ * A type guard to assess that a value is a string.
90
+ *
91
+ * This function uses the `typeof` operator's definition of a string.
92
+ *
93
+ * @param value - The value to test.
94
+ *
95
+ * @returns Whether or not the value is a string.
96
+ *
97
+ * @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
98
+ */
99
+ export declare function isString(value: unknown): value is string;
100
+ /**
101
+ * A type guard to assess that a value is a symbol.
102
+ *
103
+ * This function uses the `typeof` operator's definition of a symbol.
104
+ *
105
+ * @param value - The value to test.
106
+ *
107
+ * @returns Whether or not the value is a symbol.
108
+ *
109
+ * @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
110
+ */
111
+ export declare function isSymbol(value: unknown): value is symbol;
112
+ /**
113
+ * A type guard to assess that a value is undefined.
114
+ *
115
+ * This function uses the `typeof` operator's definition of undefined.
116
+ *
117
+ * @param value - The value to test.
118
+ *
119
+ * @returns Whether or not the value is undefined.
120
+ *
121
+ * @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
122
+ */
123
+ export declare function isUndefined(value: unknown): value is undefined;
package/lib/esm/guard.js CHANGED
@@ -1,54 +1,145 @@
1
1
  /**
2
- * A convenient Typescript type guard function to assess that a value is a string.
2
+ * A type guard to assess that a value is a bigint.
3
3
  *
4
- * @remark
5
- * This function is mostly meant as a Typescript type guard. See:
6
- * https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
4
+ * This function uses the `typeof` operator's definition of a bigint.
7
5
  *
8
6
  * @param value - The value to test.
9
- * @returns Whether or not the value is a string.
7
+ *
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
10
11
  */
11
- export function isString(value) {
12
- return typeof value === "string";
12
+ export function isBigint(value) {
13
+ return typeof value === "bigint";
13
14
  }
14
15
  /**
15
- * A convenient Typescript type guard function to assess that a value is a symbol.
16
+ * A type guard to assess that a value is a boolean.
16
17
  *
17
- * @remark
18
- * This function is mostly meant as a Typescript type guard. See:
19
- * https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
18
+ * This function uses the `typeof` operator's definition of a boolean.
20
19
  *
21
20
  * @param value - The value to test.
22
- * @returns Whether or not the value is a symbol.
21
+ *
22
+ * @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
23
25
  */
24
- export function isSymbol(value) {
25
- return typeof value === "symbol";
26
+ export function isBoolean(value) {
27
+ return typeof value === "boolean";
28
+ }
29
+ /**
30
+ * A type guard to assess that a value is a function.
31
+ *
32
+ * This function uses the `typeof` operator's definition of a function.
33
+ *
34
+ * @param value - The value to test.
35
+ *
36
+ * @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
+ */
40
+ // eslint-disable-next-line @typescript-eslint/ban-types
41
+ export function isFunction(value) {
42
+ return typeof value === "function";
26
43
  }
27
44
  /**
28
- * A convenient Typescript type guard function to assess that a value is a number.
45
+ * A type guard to assess that a value is a number.
29
46
  *
30
- * @remark
31
- * This function is mostly meant as a Typescript type guard. See:
32
- * https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
47
+ * This function uses the `typeof` operator's definition of a number.
33
48
  *
34
49
  * @param value - The value to test.
50
+ *
35
51
  * @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
36
54
  */
37
55
  export function isNumber(value) {
38
56
  return typeof value === "number";
39
57
  }
40
58
  /**
41
- * A convenient Typescript type guard function to assess that a value is a function.
59
+ * A type guard to assess that a value is null.
42
60
  *
43
- * @remark
44
- * * This function is mostly meant as a Typescript type guard. See:
45
- * https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
61
+ * This function uses the `===` operator to check for null.
46
62
  *
47
63
  * @param value - The value to test.
48
- * @returns Whether or not the value is a function.
64
+ *
65
+ * @returns Whether or not the value is null.
66
+ *
67
+ * @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
49
68
  */
50
- // eslint-disable-next-line @typescript-eslint/ban-types
51
- export function isFunction(value) {
52
- return typeof value === "function";
69
+ export function isNull(value) {
70
+ return value === null;
71
+ }
72
+ /**
73
+ * A type guard to assess that a value is an object.
74
+ *
75
+ * This function uses the `typeof` operator's definition of an object.
76
+ * If you need to exclude null, you can use the {@link isObjectNotNull} function instead.
77
+ *
78
+ * @param value - The value to test.
79
+ *
80
+ * @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
+ */
84
+ export function isObject(value) {
85
+ return typeof value === "object";
86
+ }
87
+ /**
88
+ * A type guard to assess that a value is an object and not null.
89
+ *
90
+ * This function uses {@link isObject} and {@link isNull} to determine if the value
91
+ * is an object that is not null.
92
+ *
93
+ * @param value - The value to test.
94
+ *
95
+ * @returns Whether or not the value is an object and not null.
96
+ *
97
+ * @see isObject
98
+ * @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
99
+ */
100
+ export function isObjectNotNull(value) {
101
+ return !isNull(value) && typeof value === "object";
102
+ }
103
+ /**
104
+ * A type guard to assess that a value is a string.
105
+ *
106
+ * This function uses the `typeof` operator's definition of a string.
107
+ *
108
+ * @param value - The value to test.
109
+ *
110
+ * @returns Whether or not the value is a string.
111
+ *
112
+ * @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
113
+ */
114
+ export function isString(value) {
115
+ return typeof value === "string";
116
+ }
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
+ * @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
127
+ */
128
+ export function isSymbol(value) {
129
+ return typeof value === "symbol";
130
+ }
131
+ /**
132
+ * A type guard to assess that a value is undefined.
133
+ *
134
+ * This function uses the `typeof` operator's definition of undefined.
135
+ *
136
+ * @param value - The value to test.
137
+ *
138
+ * @returns Whether or not the value is undefined.
139
+ *
140
+ * @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
141
+ */
142
+ export function isUndefined(value) {
143
+ return typeof value === "undefined";
53
144
  }
54
145
  //# sourceMappingURL=guard.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"guard.js","sourceRoot":"","sources":["../../src/guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC;AAED;;;;;;;;;GASG;AACH,wDAAwD;AACxD,MAAM,UAAU,UAAU,CAAC,KAAc;IACvC,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC;AACrC,CAAC"}
1
+ {"version":3,"file":"guard.js","sourceRoot":"","sources":["../../src/guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,SAAS,CAAC,KAAc;IACtC,OAAO,OAAO,KAAK,KAAK,SAAS,CAAC;AACpC,CAAC;AAED;;;;;;;;;;GAUG;AACH,wDAAwD;AACxD,MAAM,UAAU,UAAU,CAAC,KAAc;IACvC,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC;AACrC,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,MAAM,CAAC,KAAc;IACnC,OAAO,KAAK,KAAK,IAAI,CAAC;AACxB,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC;AACrD,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC;AAED;;;;;;;;;;GAUG;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.10.0-alpha.0",
3
+ "version": "0.11.0-alpha.0",
4
4
  "description": "Typescript types utility package.",
5
5
  "keywords": [
6
6
  "type",