@infra-blocks/types 0.5.5 → 0.5.6-alpha.1
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/README.md +1 -1
- package/lib/cjs/func.d.ts +21 -0
- package/lib/cjs/func.js +3 -0
- package/lib/cjs/func.js.map +1 -0
- package/lib/cjs/guard.d.ts +44 -0
- package/lib/cjs/guard.js +61 -0
- package/lib/cjs/guard.js.map +1 -0
- package/lib/cjs/index.d.ts +4 -65
- package/lib/cjs/index.js +16 -58
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/func.d.ts +21 -0
- package/lib/esm/func.js +2 -0
- package/lib/esm/func.js.map +1 -0
- package/lib/esm/guard.d.ts +44 -0
- package/lib/esm/guard.js +54 -0
- package/lib/esm/guard.js.map +1 -0
- package/lib/esm/index.d.ts +4 -65
- package/lib/esm/index.js +2 -53
- package/lib/esm/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
[](https://github.com/infra-blocks/ts-types/actions/workflows/build.yml)
|
|
3
3
|
[](https://github.com/infra-blocks/ts-types/actions/workflows/release.yml)
|
|
4
4
|
[](https://github.com/infra-blocks/ts-types/actions/workflows/update-from-template.yml)
|
|
5
|
-
[](https://codecov.io/gh/infra-blocks/ts-types)
|
|
6
6
|
|
|
7
7
|
Types utility library for Typescript.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convenient type to easily represent "callable" types and to avoid using
|
|
3
|
+
* "any" in client code.
|
|
4
|
+
*/
|
|
5
|
+
export type Callable = (...args: never[]) => unknown;
|
|
6
|
+
/**
|
|
7
|
+
* Convenient type alias for constructors.
|
|
8
|
+
*/
|
|
9
|
+
export type Constructor<R = object, A extends any[] = any[]> = new (...args: A) => R;
|
|
10
|
+
/**
|
|
11
|
+
* A type alias for single element predicate functions.
|
|
12
|
+
*/
|
|
13
|
+
export type Predicate<T> = (item: T) => boolean;
|
|
14
|
+
/**
|
|
15
|
+
* A type alias for functions that return a value of a given type without arguments.
|
|
16
|
+
*/
|
|
17
|
+
export type Provider<T> = () => T;
|
|
18
|
+
/**
|
|
19
|
+
* A convenient type declaration for handlers used to resolve "error" type events.
|
|
20
|
+
*/
|
|
21
|
+
export type ErrorHandler<T extends Error = Error> = (err: T) => void;
|
package/lib/cjs/func.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"func.js","sourceRoot":"","sources":["../../src/func.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A convenient Typescript type guard function to assess that a value is a string.
|
|
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
|
|
7
|
+
*
|
|
8
|
+
* @param value - The value to test.
|
|
9
|
+
* @returns Whether or not the value is a string.
|
|
10
|
+
*/
|
|
11
|
+
export declare function isString(value: unknown): value is string;
|
|
12
|
+
/**
|
|
13
|
+
* A convenient Typescript type guard function to assess that a value is a symbol.
|
|
14
|
+
*
|
|
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
|
|
18
|
+
*
|
|
19
|
+
* @param value - The value to test.
|
|
20
|
+
* @returns Whether or not the value is a symbol.
|
|
21
|
+
*/
|
|
22
|
+
export declare function isSymbol(value: unknown): value is symbol;
|
|
23
|
+
/**
|
|
24
|
+
* A convenient Typescript type guard function to assess that a value is a number.
|
|
25
|
+
*
|
|
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
|
|
29
|
+
*
|
|
30
|
+
* @param value - The value to test.
|
|
31
|
+
* @returns Whether or not the value is a number.
|
|
32
|
+
*/
|
|
33
|
+
export declare function isNumber(value: unknown): value is number;
|
|
34
|
+
/**
|
|
35
|
+
* A convenient Typescript type guard function to assess that a value is a function.
|
|
36
|
+
*
|
|
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
|
|
40
|
+
*
|
|
41
|
+
* @param value - The value to test.
|
|
42
|
+
* @returns Whether or not the value is a function.
|
|
43
|
+
*/
|
|
44
|
+
export declare function isFunction(value: unknown): value is Function;
|
package/lib/cjs/guard.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isFunction = exports.isNumber = exports.isSymbol = exports.isString = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* A convenient Typescript type guard function to assess that a value is a string.
|
|
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
|
|
10
|
+
*
|
|
11
|
+
* @param value - The value to test.
|
|
12
|
+
* @returns Whether or not the value is a string.
|
|
13
|
+
*/
|
|
14
|
+
function isString(value) {
|
|
15
|
+
return typeof value === "string";
|
|
16
|
+
}
|
|
17
|
+
exports.isString = isString;
|
|
18
|
+
/**
|
|
19
|
+
* A convenient Typescript type guard function to assess that a value is a symbol.
|
|
20
|
+
*
|
|
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
|
|
24
|
+
*
|
|
25
|
+
* @param value - The value to test.
|
|
26
|
+
* @returns Whether or not the value is a symbol.
|
|
27
|
+
*/
|
|
28
|
+
function isSymbol(value) {
|
|
29
|
+
return typeof value === "symbol";
|
|
30
|
+
}
|
|
31
|
+
exports.isSymbol = isSymbol;
|
|
32
|
+
/**
|
|
33
|
+
* A convenient Typescript type guard function to assess that a value is a number.
|
|
34
|
+
*
|
|
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
|
|
38
|
+
*
|
|
39
|
+
* @param value - The value to test.
|
|
40
|
+
* @returns Whether or not the value is a number.
|
|
41
|
+
*/
|
|
42
|
+
function isNumber(value) {
|
|
43
|
+
return typeof value === "number";
|
|
44
|
+
}
|
|
45
|
+
exports.isNumber = isNumber;
|
|
46
|
+
/**
|
|
47
|
+
* A convenient Typescript type guard function to assess that a value is a function.
|
|
48
|
+
*
|
|
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
|
|
52
|
+
*
|
|
53
|
+
* @param value - The value to test.
|
|
54
|
+
* @returns Whether or not the value is a function.
|
|
55
|
+
*/
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
57
|
+
function isFunction(value) {
|
|
58
|
+
return typeof value === "function";
|
|
59
|
+
}
|
|
60
|
+
exports.isFunction = isFunction;
|
|
61
|
+
//# sourceMappingURL=guard.js.map
|
|
@@ -0,0 +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"}
|
package/lib/cjs/index.d.ts
CHANGED
|
@@ -1,30 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
* "any" in client code.
|
|
4
|
-
*/
|
|
5
|
-
export type Callable = (...args: never[]) => unknown;
|
|
6
|
-
/**
|
|
7
|
-
* Convenient type alias for constructors.
|
|
8
|
-
*/
|
|
9
|
-
export type Constructor<R = object, A extends any[] = any[]> = new (...args: A) => R;
|
|
1
|
+
export * from "./func.js";
|
|
2
|
+
export * from "./guard.js";
|
|
10
3
|
/**
|
|
11
4
|
* Convenient type alias to regroup a type that can be T, null or undefined.
|
|
12
5
|
*
|
|
13
6
|
* Semantically the opposite of {@link NonNullable}.
|
|
14
7
|
*/
|
|
15
8
|
export type Nullable<T> = T | null | undefined;
|
|
16
|
-
/**
|
|
17
|
-
* A type alias for single element predicate functions.
|
|
18
|
-
*/
|
|
19
|
-
export type Predicate<T> = (item: T) => boolean;
|
|
20
|
-
/**
|
|
21
|
-
* A type alias for functions that return a value of a given type without arguments.
|
|
22
|
-
*/
|
|
23
|
-
export type Provider<T> = () => T;
|
|
24
|
-
/**
|
|
25
|
-
* A convenient type declaration for handlers used to resolve "error" type events.
|
|
26
|
-
*/
|
|
27
|
-
export type ErrorHandler<T extends Error = Error> = (err: T) => void;
|
|
28
9
|
/**
|
|
29
10
|
* A convenience type extractor to get the inner type of an array.
|
|
30
11
|
*
|
|
@@ -39,6 +20,8 @@ export type UnpackedArray<T> = T extends (infer U)[] ? U : never;
|
|
|
39
20
|
* It will cause compilation errors if T isn't a promise.
|
|
40
21
|
*
|
|
41
22
|
* See here: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html
|
|
23
|
+
*
|
|
24
|
+
* @deprecated Use built-in {@link Awaited} instead.
|
|
42
25
|
*/
|
|
43
26
|
export type UnpackedPromise<T> = T extends Promise<infer U> ? U : never;
|
|
44
27
|
/**
|
|
@@ -58,47 +41,3 @@ export type TransitivePartial<T> = {
|
|
|
58
41
|
export type KeyOfType<T, U> = {
|
|
59
42
|
[P in keyof T]: T[P] extends U ? P : never;
|
|
60
43
|
}[keyof T];
|
|
61
|
-
/**
|
|
62
|
-
* A convenient Typescript type guard function to assess that a value is a string.
|
|
63
|
-
*
|
|
64
|
-
* @remark
|
|
65
|
-
* This function is mostly meant as a Typescript type guard. See:
|
|
66
|
-
* https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
67
|
-
*
|
|
68
|
-
* @param value - The value to test.
|
|
69
|
-
* @returns Whether or not the value is a string.
|
|
70
|
-
*/
|
|
71
|
-
export declare function isString(value: unknown): value is string;
|
|
72
|
-
/**
|
|
73
|
-
* A convenient Typescript type guard function to assess that a value is a symbol.
|
|
74
|
-
*
|
|
75
|
-
* @remark
|
|
76
|
-
* This function is mostly meant as a Typescript type guard. See:
|
|
77
|
-
* https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
78
|
-
*
|
|
79
|
-
* @param value - The value to test.
|
|
80
|
-
* @returns Whether or not the value is a symbol.
|
|
81
|
-
*/
|
|
82
|
-
export declare function isSymbol(value: unknown): value is symbol;
|
|
83
|
-
/**
|
|
84
|
-
* A convenient Typescript type guard function to assess that a value is a number.
|
|
85
|
-
*
|
|
86
|
-
* @remark
|
|
87
|
-
* This function is mostly meant as a Typescript type guard. See:
|
|
88
|
-
* https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
89
|
-
*
|
|
90
|
-
* @param value - The value to test.
|
|
91
|
-
* @returns Whether or not the value is a number.
|
|
92
|
-
*/
|
|
93
|
-
export declare function isNumber(value: unknown): value is number;
|
|
94
|
-
/**
|
|
95
|
-
* A convenient Typescript type guard function to assess that a value is a function.
|
|
96
|
-
*
|
|
97
|
-
* @remark
|
|
98
|
-
* * This function is mostly meant as a Typescript type guard. See:
|
|
99
|
-
* https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
100
|
-
*
|
|
101
|
-
* @param value - The value to test.
|
|
102
|
-
* @returns Whether or not the value is a function.
|
|
103
|
-
*/
|
|
104
|
-
export declare function isFunction(value: unknown): value is Function;
|
package/lib/cjs/index.js
CHANGED
|
@@ -1,61 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* A convenient Typescript type guard function to assess that a value is a string.
|
|
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
|
|
10
|
-
*
|
|
11
|
-
* @param value - The value to test.
|
|
12
|
-
* @returns Whether or not the value is a string.
|
|
13
|
-
*/
|
|
14
|
-
function isString(value) {
|
|
15
|
-
return typeof value === "string";
|
|
16
|
-
}
|
|
17
|
-
exports.isString = isString;
|
|
18
|
-
/**
|
|
19
|
-
* A convenient Typescript type guard function to assess that a value is a symbol.
|
|
20
|
-
*
|
|
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
|
|
24
|
-
*
|
|
25
|
-
* @param value - The value to test.
|
|
26
|
-
* @returns Whether or not the value is a symbol.
|
|
27
|
-
*/
|
|
28
|
-
function isSymbol(value) {
|
|
29
|
-
return typeof value === "symbol";
|
|
30
|
-
}
|
|
31
|
-
exports.isSymbol = isSymbol;
|
|
32
|
-
/**
|
|
33
|
-
* A convenient Typescript type guard function to assess that a value is a number.
|
|
34
|
-
*
|
|
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
|
|
38
|
-
*
|
|
39
|
-
* @param value - The value to test.
|
|
40
|
-
* @returns Whether or not the value is a number.
|
|
41
|
-
*/
|
|
42
|
-
function isNumber(value) {
|
|
43
|
-
return typeof value === "number";
|
|
44
|
-
}
|
|
45
|
-
exports.isNumber = isNumber;
|
|
46
|
-
/**
|
|
47
|
-
* A convenient Typescript type guard function to assess that a value is a function.
|
|
48
|
-
*
|
|
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
|
|
52
|
-
*
|
|
53
|
-
* @param value - The value to test.
|
|
54
|
-
* @returns Whether or not the value is a function.
|
|
55
|
-
*/
|
|
56
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
57
|
-
function isFunction(value) {
|
|
58
|
-
return typeof value === "function";
|
|
59
|
-
}
|
|
60
|
-
exports.isFunction = isFunction;
|
|
17
|
+
__exportStar(require("./func.js"), exports);
|
|
18
|
+
__exportStar(require("./guard.js"), exports);
|
|
61
19
|
//# sourceMappingURL=index.js.map
|
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":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,6CAA2B"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convenient type to easily represent "callable" types and to avoid using
|
|
3
|
+
* "any" in client code.
|
|
4
|
+
*/
|
|
5
|
+
export type Callable = (...args: never[]) => unknown;
|
|
6
|
+
/**
|
|
7
|
+
* Convenient type alias for constructors.
|
|
8
|
+
*/
|
|
9
|
+
export type Constructor<R = object, A extends any[] = any[]> = new (...args: A) => R;
|
|
10
|
+
/**
|
|
11
|
+
* A type alias for single element predicate functions.
|
|
12
|
+
*/
|
|
13
|
+
export type Predicate<T> = (item: T) => boolean;
|
|
14
|
+
/**
|
|
15
|
+
* A type alias for functions that return a value of a given type without arguments.
|
|
16
|
+
*/
|
|
17
|
+
export type Provider<T> = () => T;
|
|
18
|
+
/**
|
|
19
|
+
* A convenient type declaration for handlers used to resolve "error" type events.
|
|
20
|
+
*/
|
|
21
|
+
export type ErrorHandler<T extends Error = Error> = (err: T) => void;
|
package/lib/esm/func.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"func.js","sourceRoot":"","sources":["../../src/func.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A convenient Typescript type guard function to assess that a value is a string.
|
|
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
|
|
7
|
+
*
|
|
8
|
+
* @param value - The value to test.
|
|
9
|
+
* @returns Whether or not the value is a string.
|
|
10
|
+
*/
|
|
11
|
+
export declare function isString(value: unknown): value is string;
|
|
12
|
+
/**
|
|
13
|
+
* A convenient Typescript type guard function to assess that a value is a symbol.
|
|
14
|
+
*
|
|
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
|
|
18
|
+
*
|
|
19
|
+
* @param value - The value to test.
|
|
20
|
+
* @returns Whether or not the value is a symbol.
|
|
21
|
+
*/
|
|
22
|
+
export declare function isSymbol(value: unknown): value is symbol;
|
|
23
|
+
/**
|
|
24
|
+
* A convenient Typescript type guard function to assess that a value is a number.
|
|
25
|
+
*
|
|
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
|
|
29
|
+
*
|
|
30
|
+
* @param value - The value to test.
|
|
31
|
+
* @returns Whether or not the value is a number.
|
|
32
|
+
*/
|
|
33
|
+
export declare function isNumber(value: unknown): value is number;
|
|
34
|
+
/**
|
|
35
|
+
* A convenient Typescript type guard function to assess that a value is a function.
|
|
36
|
+
*
|
|
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
|
|
40
|
+
*
|
|
41
|
+
* @param value - The value to test.
|
|
42
|
+
* @returns Whether or not the value is a function.
|
|
43
|
+
*/
|
|
44
|
+
export declare function isFunction(value: unknown): value is Function;
|
package/lib/esm/guard.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A convenient Typescript type guard function to assess that a value is a string.
|
|
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
|
|
7
|
+
*
|
|
8
|
+
* @param value - The value to test.
|
|
9
|
+
* @returns Whether or not the value is a string.
|
|
10
|
+
*/
|
|
11
|
+
export function isString(value) {
|
|
12
|
+
return typeof value === "string";
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A convenient Typescript type guard function to assess that a value is a symbol.
|
|
16
|
+
*
|
|
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
|
|
20
|
+
*
|
|
21
|
+
* @param value - The value to test.
|
|
22
|
+
* @returns Whether or not the value is a symbol.
|
|
23
|
+
*/
|
|
24
|
+
export function isSymbol(value) {
|
|
25
|
+
return typeof value === "symbol";
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A convenient Typescript type guard function to assess that a value is a number.
|
|
29
|
+
*
|
|
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
|
|
33
|
+
*
|
|
34
|
+
* @param value - The value to test.
|
|
35
|
+
* @returns Whether or not the value is a number.
|
|
36
|
+
*/
|
|
37
|
+
export function isNumber(value) {
|
|
38
|
+
return typeof value === "number";
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A convenient Typescript type guard function to assess that a value is a function.
|
|
42
|
+
*
|
|
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
|
|
46
|
+
*
|
|
47
|
+
* @param value - The value to test.
|
|
48
|
+
* @returns Whether or not the value is a function.
|
|
49
|
+
*/
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
51
|
+
export function isFunction(value) {
|
|
52
|
+
return typeof value === "function";
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=guard.js.map
|
|
@@ -0,0 +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"}
|
package/lib/esm/index.d.ts
CHANGED
|
@@ -1,30 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
* "any" in client code.
|
|
4
|
-
*/
|
|
5
|
-
export type Callable = (...args: never[]) => unknown;
|
|
6
|
-
/**
|
|
7
|
-
* Convenient type alias for constructors.
|
|
8
|
-
*/
|
|
9
|
-
export type Constructor<R = object, A extends any[] = any[]> = new (...args: A) => R;
|
|
1
|
+
export * from "./func.js";
|
|
2
|
+
export * from "./guard.js";
|
|
10
3
|
/**
|
|
11
4
|
* Convenient type alias to regroup a type that can be T, null or undefined.
|
|
12
5
|
*
|
|
13
6
|
* Semantically the opposite of {@link NonNullable}.
|
|
14
7
|
*/
|
|
15
8
|
export type Nullable<T> = T | null | undefined;
|
|
16
|
-
/**
|
|
17
|
-
* A type alias for single element predicate functions.
|
|
18
|
-
*/
|
|
19
|
-
export type Predicate<T> = (item: T) => boolean;
|
|
20
|
-
/**
|
|
21
|
-
* A type alias for functions that return a value of a given type without arguments.
|
|
22
|
-
*/
|
|
23
|
-
export type Provider<T> = () => T;
|
|
24
|
-
/**
|
|
25
|
-
* A convenient type declaration for handlers used to resolve "error" type events.
|
|
26
|
-
*/
|
|
27
|
-
export type ErrorHandler<T extends Error = Error> = (err: T) => void;
|
|
28
9
|
/**
|
|
29
10
|
* A convenience type extractor to get the inner type of an array.
|
|
30
11
|
*
|
|
@@ -39,6 +20,8 @@ export type UnpackedArray<T> = T extends (infer U)[] ? U : never;
|
|
|
39
20
|
* It will cause compilation errors if T isn't a promise.
|
|
40
21
|
*
|
|
41
22
|
* See here: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html
|
|
23
|
+
*
|
|
24
|
+
* @deprecated Use built-in {@link Awaited} instead.
|
|
42
25
|
*/
|
|
43
26
|
export type UnpackedPromise<T> = T extends Promise<infer U> ? U : never;
|
|
44
27
|
/**
|
|
@@ -58,47 +41,3 @@ export type TransitivePartial<T> = {
|
|
|
58
41
|
export type KeyOfType<T, U> = {
|
|
59
42
|
[P in keyof T]: T[P] extends U ? P : never;
|
|
60
43
|
}[keyof T];
|
|
61
|
-
/**
|
|
62
|
-
* A convenient Typescript type guard function to assess that a value is a string.
|
|
63
|
-
*
|
|
64
|
-
* @remark
|
|
65
|
-
* This function is mostly meant as a Typescript type guard. See:
|
|
66
|
-
* https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
67
|
-
*
|
|
68
|
-
* @param value - The value to test.
|
|
69
|
-
* @returns Whether or not the value is a string.
|
|
70
|
-
*/
|
|
71
|
-
export declare function isString(value: unknown): value is string;
|
|
72
|
-
/**
|
|
73
|
-
* A convenient Typescript type guard function to assess that a value is a symbol.
|
|
74
|
-
*
|
|
75
|
-
* @remark
|
|
76
|
-
* This function is mostly meant as a Typescript type guard. See:
|
|
77
|
-
* https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
78
|
-
*
|
|
79
|
-
* @param value - The value to test.
|
|
80
|
-
* @returns Whether or not the value is a symbol.
|
|
81
|
-
*/
|
|
82
|
-
export declare function isSymbol(value: unknown): value is symbol;
|
|
83
|
-
/**
|
|
84
|
-
* A convenient Typescript type guard function to assess that a value is a number.
|
|
85
|
-
*
|
|
86
|
-
* @remark
|
|
87
|
-
* This function is mostly meant as a Typescript type guard. See:
|
|
88
|
-
* https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
89
|
-
*
|
|
90
|
-
* @param value - The value to test.
|
|
91
|
-
* @returns Whether or not the value is a number.
|
|
92
|
-
*/
|
|
93
|
-
export declare function isNumber(value: unknown): value is number;
|
|
94
|
-
/**
|
|
95
|
-
* A convenient Typescript type guard function to assess that a value is a function.
|
|
96
|
-
*
|
|
97
|
-
* @remark
|
|
98
|
-
* * This function is mostly meant as a Typescript type guard. See:
|
|
99
|
-
* https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
100
|
-
*
|
|
101
|
-
* @param value - The value to test.
|
|
102
|
-
* @returns Whether or not the value is a function.
|
|
103
|
-
*/
|
|
104
|
-
export declare function isFunction(value: unknown): value is Function;
|
package/lib/esm/index.js
CHANGED
|
@@ -1,54 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
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
|
|
7
|
-
*
|
|
8
|
-
* @param value - The value to test.
|
|
9
|
-
* @returns Whether or not the value is a string.
|
|
10
|
-
*/
|
|
11
|
-
export function isString(value) {
|
|
12
|
-
return typeof value === "string";
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* A convenient Typescript type guard function to assess that a value is a symbol.
|
|
16
|
-
*
|
|
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
|
|
20
|
-
*
|
|
21
|
-
* @param value - The value to test.
|
|
22
|
-
* @returns Whether or not the value is a symbol.
|
|
23
|
-
*/
|
|
24
|
-
export function isSymbol(value) {
|
|
25
|
-
return typeof value === "symbol";
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* A convenient Typescript type guard function to assess that a value is a number.
|
|
29
|
-
*
|
|
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
|
|
33
|
-
*
|
|
34
|
-
* @param value - The value to test.
|
|
35
|
-
* @returns Whether or not the value is a number.
|
|
36
|
-
*/
|
|
37
|
-
export function isNumber(value) {
|
|
38
|
-
return typeof value === "number";
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* A convenient Typescript type guard function to assess that a value is a function.
|
|
42
|
-
*
|
|
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
|
|
46
|
-
*
|
|
47
|
-
* @param value - The value to test.
|
|
48
|
-
* @returns Whether or not the value is a function.
|
|
49
|
-
*/
|
|
50
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
51
|
-
export function isFunction(value) {
|
|
52
|
-
return typeof value === "function";
|
|
53
|
-
}
|
|
1
|
+
export * from "./func.js";
|
|
2
|
+
export * from "./guard.js";
|
|
54
3
|
//# sourceMappingURL=index.js.map
|
package/lib/esm/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":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC"}
|