type-plus 6.4.0 → 6.6.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/README.md +27 -15
- package/cjs/any/any_or_never.d.ts +0 -2
- package/cjs/any/any_or_never.d.ts.map +1 -1
- package/cjs/any/any_type.d.ts +2 -6
- package/cjs/any/any_type.d.ts.map +1 -1
- package/cjs/array/array.d.ts +0 -4
- package/cjs/array/array.d.ts.map +1 -1
- package/cjs/array/array_index.d.ts +7 -10
- package/cjs/array/array_index.d.ts.map +1 -1
- package/cjs/array/array_type.d.ts +0 -8
- package/cjs/array/array_type.d.ts.map +1 -1
- package/cjs/bigint/bigint_type.d.ts +4 -12
- package/cjs/bigint/bigint_type.d.ts.map +1 -1
- package/cjs/bigint/strict_bigint_type.d.ts +4 -12
- package/cjs/bigint/strict_bigint_type.d.ts.map +1 -1
- package/cjs/boolean/boolean_type.d.ts +0 -8
- package/cjs/boolean/boolean_type.d.ts.map +1 -1
- package/cjs/boolean/false_type.d.ts +0 -8
- package/cjs/boolean/false_type.d.ts.map +1 -1
- package/cjs/boolean/strict_boolean_type.d.ts +0 -8
- package/cjs/boolean/strict_boolean_type.d.ts.map +1 -1
- package/cjs/boolean/true_type.d.ts +0 -8
- package/cjs/boolean/true_type.d.ts.map +1 -1
- package/cjs/equal/equal.d.ts +4 -5
- package/cjs/equal/equal.d.ts.map +1 -1
- package/cjs/function/function_type.d.ts +0 -8
- package/cjs/function/function_type.d.ts.map +1 -1
- package/cjs/function/strict_function_type.d.ts +0 -8
- package/cjs/function/strict_function_type.d.ts.map +1 -1
- package/cjs/index.d.ts +3 -0
- package/cjs/index.d.ts.map +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/never/never_type.d.ts +2 -10
- package/cjs/never/never_type.d.ts.map +1 -1
- package/cjs/nominal/brand.d.ts +7 -5
- package/cjs/nominal/brand.d.ts.map +1 -1
- package/cjs/nominal/brand.js +4 -4
- package/cjs/nominal/brand.js.map +1 -1
- package/cjs/nominal/{types.d.ts → constants.d.ts} +1 -1
- package/cjs/nominal/constants.d.ts.map +1 -0
- package/cjs/nominal/{types.js → constants.js} +1 -1
- package/cjs/nominal/constants.js.map +1 -0
- package/cjs/nominal/flavor.d.ts +14 -3
- package/cjs/nominal/flavor.d.ts.map +1 -1
- package/cjs/nominal/flavor.js +2 -2
- package/cjs/nominal/flavor.js.map +1 -1
- package/cjs/nominal/nominal_match.js +2 -2
- package/cjs/nominal/nominal_match.js.map +1 -1
- package/cjs/null/null_type.d.ts +4 -12
- package/cjs/null/null_type.d.ts.map +1 -1
- package/cjs/number/integer.d.ts +1 -9
- package/cjs/number/integer.d.ts.map +1 -1
- package/cjs/number/negative.d.ts +0 -8
- package/cjs/number/negative.d.ts.map +1 -1
- package/cjs/number/number_type.d.ts +0 -8
- package/cjs/number/number_type.d.ts.map +1 -1
- package/cjs/number/numeric_type.d.ts +0 -8
- package/cjs/number/numeric_type.d.ts.map +1 -1
- package/cjs/number/positive.d.ts +1 -9
- package/cjs/number/positive.d.ts.map +1 -1
- package/cjs/number/strict_number_type.d.ts +4 -12
- package/cjs/number/strict_number_type.d.ts.map +1 -1
- package/cjs/object/object_type.d.ts +1 -9
- package/cjs/object/object_type.d.ts.map +1 -1
- package/cjs/string/strict_string_type.d.ts +14 -19
- package/cjs/string/strict_string_type.d.ts.map +1 -1
- package/cjs/string/string.d.ts +24 -0
- package/cjs/string/string.d.ts.map +1 -0
- package/cjs/string/string.js +3 -0
- package/cjs/string/string.js.map +1 -0
- package/cjs/string/string_plus.d.ts +27 -0
- package/cjs/string/string_plus.d.ts.map +1 -0
- package/cjs/string/string_plus.js +3 -0
- package/cjs/string/string_plus.js.map +1 -0
- package/cjs/string/string_type.d.ts +4 -12
- package/cjs/string/string_type.d.ts.map +1 -1
- package/cjs/symbol/symbol_type.d.ts +5 -15
- package/cjs/symbol/symbol_type.d.ts.map +1 -1
- package/cjs/tuple/tuple_type.d.ts +0 -8
- package/cjs/tuple/tuple_type.d.ts.map +1 -1
- package/cjs/type/failed.d.ts +32 -0
- package/cjs/type/failed.d.ts.map +1 -0
- package/cjs/type/failed.js +3 -0
- package/cjs/type/failed.js.map +1 -0
- package/cjs/undefined/undefined_type.d.ts +4 -12
- package/cjs/undefined/undefined_type.d.ts.map +1 -1
- package/cjs/union/union_to_intersection.d.ts.map +1 -0
- package/cjs/union/union_to_intersection.js.map +1 -0
- package/cjs/unknown/unknown_type.d.ts +4 -12
- package/cjs/unknown/unknown_type.d.ts.map +1 -1
- package/cjs/void/void_type.d.ts +0 -8
- package/cjs/void/void_type.d.ts.map +1 -1
- package/esm/any/any_or_never.d.ts +0 -2
- package/esm/any/any_or_never.d.ts.map +1 -1
- package/esm/any/any_type.d.ts +2 -6
- package/esm/any/any_type.d.ts.map +1 -1
- package/esm/array/array.d.ts +0 -4
- package/esm/array/array.d.ts.map +1 -1
- package/esm/array/array_index.d.ts +7 -10
- package/esm/array/array_index.d.ts.map +1 -1
- package/esm/array/array_type.d.ts +0 -8
- package/esm/array/array_type.d.ts.map +1 -1
- package/esm/bigint/bigint_type.d.ts +4 -12
- package/esm/bigint/bigint_type.d.ts.map +1 -1
- package/esm/bigint/strict_bigint_type.d.ts +4 -12
- package/esm/bigint/strict_bigint_type.d.ts.map +1 -1
- package/esm/boolean/boolean_type.d.ts +0 -8
- package/esm/boolean/boolean_type.d.ts.map +1 -1
- package/esm/boolean/false_type.d.ts +0 -8
- package/esm/boolean/false_type.d.ts.map +1 -1
- package/esm/boolean/strict_boolean_type.d.ts +0 -8
- package/esm/boolean/strict_boolean_type.d.ts.map +1 -1
- package/esm/boolean/true_type.d.ts +0 -8
- package/esm/boolean/true_type.d.ts.map +1 -1
- package/esm/equal/equal.d.ts +4 -5
- package/esm/equal/equal.d.ts.map +1 -1
- package/esm/function/function_type.d.ts +0 -8
- package/esm/function/function_type.d.ts.map +1 -1
- package/esm/function/strict_function_type.d.ts +0 -8
- package/esm/function/strict_function_type.d.ts.map +1 -1
- package/esm/index.d.ts +3 -0
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js.map +1 -1
- package/esm/never/never_type.d.ts +2 -10
- package/esm/never/never_type.d.ts.map +1 -1
- package/esm/nominal/brand.d.ts +7 -5
- package/esm/nominal/brand.d.ts.map +1 -1
- package/esm/nominal/brand.js +4 -4
- package/esm/nominal/brand.js.map +1 -1
- package/esm/nominal/{types.d.ts → constants.d.ts} +1 -1
- package/esm/nominal/constants.d.ts.map +1 -0
- package/esm/nominal/{types.js → constants.js} +1 -1
- package/esm/nominal/constants.js.map +1 -0
- package/esm/nominal/flavor.d.ts +14 -3
- package/esm/nominal/flavor.d.ts.map +1 -1
- package/esm/nominal/flavor.js +1 -1
- package/esm/nominal/flavor.js.map +1 -1
- package/esm/nominal/nominal_match.js +1 -1
- package/esm/nominal/nominal_match.js.map +1 -1
- package/esm/null/null_type.d.ts +4 -12
- package/esm/null/null_type.d.ts.map +1 -1
- package/esm/number/integer.d.ts +1 -9
- package/esm/number/integer.d.ts.map +1 -1
- package/esm/number/negative.d.ts +0 -8
- package/esm/number/negative.d.ts.map +1 -1
- package/esm/number/number_type.d.ts +0 -8
- package/esm/number/number_type.d.ts.map +1 -1
- package/esm/number/numeric_type.d.ts +0 -8
- package/esm/number/numeric_type.d.ts.map +1 -1
- package/esm/number/positive.d.ts +1 -9
- package/esm/number/positive.d.ts.map +1 -1
- package/esm/number/strict_number_type.d.ts +4 -12
- package/esm/number/strict_number_type.d.ts.map +1 -1
- package/esm/object/object_type.d.ts +1 -9
- package/esm/object/object_type.d.ts.map +1 -1
- package/esm/string/strict_string_type.d.ts +14 -19
- package/esm/string/strict_string_type.d.ts.map +1 -1
- package/esm/string/string.d.ts +24 -0
- package/esm/string/string.d.ts.map +1 -0
- package/esm/string/string.js +2 -0
- package/esm/string/string.js.map +1 -0
- package/esm/string/string_plus.d.ts +27 -0
- package/esm/string/string_plus.d.ts.map +1 -0
- package/esm/string/string_plus.js +2 -0
- package/esm/string/string_plus.js.map +1 -0
- package/esm/string/string_type.d.ts +4 -12
- package/esm/string/string_type.d.ts.map +1 -1
- package/esm/symbol/symbol_type.d.ts +5 -15
- package/esm/symbol/symbol_type.d.ts.map +1 -1
- package/esm/tuple/tuple_type.d.ts +0 -8
- package/esm/tuple/tuple_type.d.ts.map +1 -1
- package/esm/type/failed.d.ts +32 -0
- package/esm/type/failed.d.ts.map +1 -0
- package/esm/type/failed.js +2 -0
- package/esm/type/failed.js.map +1 -0
- package/esm/undefined/undefined_type.d.ts +4 -12
- package/esm/undefined/undefined_type.d.ts.map +1 -1
- package/esm/union/union_to_intersection.d.ts.map +1 -0
- package/esm/union/union_to_intersection.js.map +1 -0
- package/esm/unknown/unknown_type.d.ts +4 -12
- package/esm/unknown/unknown_type.d.ts.map +1 -1
- package/esm/void/void_type.d.ts +0 -8
- package/esm/void/void_type.d.ts.map +1 -1
- package/package.json +6 -6
- package/ts/any/any_or_never.ts +0 -2
- package/ts/any/any_type.ts +2 -6
- package/ts/array/array.ts +0 -4
- package/ts/array/array_index.ts +7 -10
- package/ts/array/array_type.ts +0 -8
- package/ts/assertion/readme.md +1 -2
- package/ts/bigint/bigint_type.ts +4 -12
- package/ts/bigint/strict_bigint_type.ts +4 -12
- package/ts/boolean/boolean_type.ts +0 -8
- package/ts/boolean/false_type.ts +0 -8
- package/ts/boolean/strict_boolean_type.ts +0 -8
- package/ts/boolean/true_type.ts +0 -8
- package/ts/equal/equal.ts +9 -5
- package/ts/equal/readme.md +3 -0
- package/ts/function/function_type.ts +0 -8
- package/ts/function/strict_function_type.ts +0 -8
- package/ts/index.ts +4 -0
- package/ts/never/never_type.ts +2 -10
- package/ts/nominal/brand.ts +15 -7
- package/ts/nominal/flavor.ts +17 -2
- package/ts/nominal/nominal_match.ts +1 -1
- package/ts/null/null_type.ts +4 -12
- package/ts/number/integer.ts +1 -9
- package/ts/number/negative.ts +0 -8
- package/ts/number/number_type.ts +0 -8
- package/ts/number/numeric_type.ts +0 -8
- package/ts/number/positive.ts +1 -9
- package/ts/number/strict_number_type.ts +4 -12
- package/ts/object/object_type.ts +1 -9
- package/ts/string/readme.md +5 -0
- package/ts/string/strict_string_type.ts +15 -19
- package/ts/string/string.ts +36 -0
- package/ts/string/string_plus.ts +33 -0
- package/ts/string/string_type.ts +4 -12
- package/ts/symbol/symbol_type.ts +5 -17
- package/ts/tuple/tuple_type.ts +0 -8
- package/ts/type/failed.ts +32 -0
- package/ts/type/readme.md +22 -0
- package/ts/undefined/undefined_type.ts +4 -12
- package/ts/unknown/unknown_type.ts +4 -12
- package/ts/void/void_type.ts +0 -8
- package/cjs/nominal/types.d.ts.map +0 -1
- package/cjs/nominal/types.js.map +0 -1
- package/cjs/union_to_intersection.d.ts.map +0 -1
- package/cjs/union_to_intersection.js.map +0 -1
- package/esm/nominal/types.d.ts.map +0 -1
- package/esm/nominal/types.js.map +0 -1
- package/esm/union_to_intersection.d.ts.map +0 -1
- package/esm/union_to_intersection.js.map +0 -1
- /package/cjs/{union_to_intersection.d.ts → union/union_to_intersection.d.ts} +0 -0
- /package/cjs/{union_to_intersection.js → union/union_to_intersection.js} +0 -0
- /package/esm/{union_to_intersection.d.ts → union/union_to_intersection.d.ts} +0 -0
- /package/esm/{union_to_intersection.js → union/union_to_intersection.js} +0 -0
- /package/ts/nominal/{types.ts → constants.ts} +0 -0
- /package/ts/{union_to_intersection.ts → union/union_to_intersection.ts} +0 -0
|
@@ -4,8 +4,6 @@ import type { IsAnyOrNever } from '../any/any_or_never.js'
|
|
|
4
4
|
* Check if the type `T` is exactly `boolean`.
|
|
5
5
|
*
|
|
6
6
|
* ```ts
|
|
7
|
-
* import type { StrictBooleanType } from 'type-plus'
|
|
8
|
-
*
|
|
9
7
|
* type R = StrictBooleanType<boolean> // true
|
|
10
8
|
*
|
|
11
9
|
* type R = StrictBooleanType<true> // never
|
|
@@ -23,8 +21,6 @@ export type StrictBooleanType<T, Then = T, Else = never> = IsAnyOrNever<
|
|
|
23
21
|
* Check if the type `T` is not exactly `boolean`.
|
|
24
22
|
*
|
|
25
23
|
* ```ts
|
|
26
|
-
* import type { NotStrictBooleanType } from 'type-plus'
|
|
27
|
-
*
|
|
28
24
|
* type R = NotStrictBooleanType<boolean> // never
|
|
29
25
|
*
|
|
30
26
|
* type R = NotStrictBooleanType<true> // true
|
|
@@ -38,8 +34,6 @@ export type NotStrictBooleanType<T, Then = T, Else = never> = StrictBooleanType<
|
|
|
38
34
|
* Is the type `T` exactly `boolean`.
|
|
39
35
|
*
|
|
40
36
|
* ```ts
|
|
41
|
-
* import type { IsStrictBoolean } from 'type-plus'
|
|
42
|
-
*
|
|
43
37
|
* type R = IsStrictBoolean<boolean> // true
|
|
44
38
|
*
|
|
45
39
|
* type R = IsStrictBoolean<true> // false
|
|
@@ -53,8 +47,6 @@ export type IsStrictBoolean<T, Then = true, Else = false> = StrictBooleanType<T,
|
|
|
53
47
|
* Is the type `T` not exactly `false`.
|
|
54
48
|
*
|
|
55
49
|
* ```ts
|
|
56
|
-
* import type { IsNotStrictBoolean } from 'type-plus'
|
|
57
|
-
*
|
|
58
50
|
* type R = IsNotStrictBoolean<boolean> // false
|
|
59
51
|
*
|
|
60
52
|
* type R = IsNotStrictBoolean<true> // true
|
package/ts/boolean/true_type.ts
CHANGED
|
@@ -4,8 +4,6 @@ import type { IsAnyOrNever } from '../any/any_or_never.js'
|
|
|
4
4
|
* Check if the type `T` is exactly `true`.
|
|
5
5
|
*
|
|
6
6
|
* ```ts
|
|
7
|
-
* import type { TrueType } from 'type-plus'
|
|
8
|
-
*
|
|
9
7
|
* type R = TrueType<true> // true
|
|
10
8
|
*
|
|
11
9
|
* type R = TrueType<false> // never
|
|
@@ -22,8 +20,6 @@ export type TrueType<T, Then = T, Else = never> = IsAnyOrNever<
|
|
|
22
20
|
* Check if the type `T` is not exactly `true`.
|
|
23
21
|
*
|
|
24
22
|
* ```ts
|
|
25
|
-
* import type { NotTrueType } from 'type-plus'
|
|
26
|
-
*
|
|
27
23
|
* type R = NotTrueType<true> // never
|
|
28
24
|
*
|
|
29
25
|
* type R = NotTrueType<false> // false
|
|
@@ -36,8 +32,6 @@ export type NotTrueType<T, Then = T, Else = never> = TrueType<T, Else, Then>
|
|
|
36
32
|
* Is the type `T` exactly `true`.
|
|
37
33
|
*
|
|
38
34
|
* ```ts
|
|
39
|
-
* import type { IsTrue } from 'type-plus'
|
|
40
|
-
*
|
|
41
35
|
* type R = IsTrue<true> // true
|
|
42
36
|
*
|
|
43
37
|
* type R = IsTrue<false> // false
|
|
@@ -50,8 +44,6 @@ export type IsTrue<T, Then = true, Else = false> = TrueType<T, Then, Else>
|
|
|
50
44
|
* Is the type `T` not exactly `true`.
|
|
51
45
|
*
|
|
52
46
|
* ```ts
|
|
53
|
-
* import type { IsNotTrue } from 'type-plus'
|
|
54
|
-
*
|
|
55
47
|
* type R = IsNotTrue<true> // false
|
|
56
48
|
*
|
|
57
49
|
* type R = IsNotTrue<false> // true
|
package/ts/equal/equal.ts
CHANGED
|
@@ -26,8 +26,6 @@ type IdentityEqual<A, B, Then, Else> = (<_>() => _ extends (A & _) | _ ? 1 : 2)
|
|
|
26
26
|
* Checks `A` and `B` are equal.
|
|
27
27
|
*
|
|
28
28
|
* ```ts
|
|
29
|
-
* import { type Equal } from 'type-plus'
|
|
30
|
-
*
|
|
31
29
|
* type R = Equal<1, 1> // true
|
|
32
30
|
* type R = Equal<any, any> // true
|
|
33
31
|
* type R = Equal<boolean, boolean> // true
|
|
@@ -58,8 +56,16 @@ export type Equal<A, B, Then = true, Else = false> = [A, B] extends [B, A]
|
|
|
58
56
|
And<
|
|
59
57
|
IsObject<A>,
|
|
60
58
|
IsObject<B>,
|
|
61
|
-
IdentityEqual<
|
|
59
|
+
IdentityEqual<
|
|
60
|
+
Properties<A>,
|
|
61
|
+
Properties<B>,
|
|
62
|
+
[A, B] extends [(...args: infer P1) => any, (...args: infer P2) => any]
|
|
63
|
+
? Equal<P1, P2, Then, Else>
|
|
64
|
+
: Then,
|
|
65
|
+
Else
|
|
66
|
+
>,
|
|
62
67
|
// `A` and `B` are narrowed, need to check again.
|
|
68
|
+
// This is fixed in TS 5.0.2, but keeping it to support older versions.
|
|
63
69
|
[A, B] extends [B, A] ? Then : Else
|
|
64
70
|
>
|
|
65
71
|
>
|
|
@@ -71,8 +77,6 @@ export type Equal<A, B, Then = true, Else = false> = [A, B] extends [B, A]
|
|
|
71
77
|
* Checks `A` and `B` are not equal.
|
|
72
78
|
*
|
|
73
79
|
* ```ts
|
|
74
|
-
* import { type NotEqual } from 'type-plus'
|
|
75
|
-
*
|
|
76
80
|
* type R = NotEqual<1, 1> // false
|
|
77
81
|
* type R = NotEqual<any, any> // false
|
|
78
82
|
* type R = NotEqual<boolean, boolean> // false
|
package/ts/equal/readme.md
CHANGED
|
@@ -26,6 +26,9 @@ type R = Equal<{ a: 1 }, { a: 1; b: 2 }> // false
|
|
|
26
26
|
---
|
|
27
27
|
|
|
28
28
|
[![Just Code: Equality is hard][equality-is-hard]][equality-is-hard-url]
|
|
29
|
+
[![Just Code: Equality is hard part 2][equality-is-hard-2]][equality-is-hard-2-url]
|
|
29
30
|
|
|
30
31
|
[equality-is-hard]: https://img.youtube.com/vi/VEqrFzCzo28/0.jpg
|
|
31
32
|
[equality-is-hard-url]: https://www.youtube.com/watch?v=VEqrFzCzo28
|
|
33
|
+
[equality-is-hard-2]: https://img.youtube.com/vi/l6G6Rz1n9Sw/0.jpg
|
|
34
|
+
[equality-is-hard-2-url]: https://www.youtube.com/watch?v=l6G6Rz1n9Sw
|
|
@@ -4,8 +4,6 @@ import type { IsAnyOrNever } from '../any/any_or_never.js'
|
|
|
4
4
|
* Check if `T` is a `Function`.
|
|
5
5
|
*
|
|
6
6
|
* ```ts
|
|
7
|
-
* import type { FunctionType } from 'type-plus'
|
|
8
|
-
*
|
|
9
7
|
* type R = FunctionType<Function> // Function
|
|
10
8
|
* type R = FunctionType<() => void> // () => void
|
|
11
9
|
* type R = FunctionType<(() => void) | { a: 1 }> // (() => void) | { a: 1 }
|
|
@@ -25,8 +23,6 @@ export type FunctionType<T, Then = T, Else = never> = IsAnyOrNever<
|
|
|
25
23
|
* Is `T` a `Function`.
|
|
26
24
|
*
|
|
27
25
|
* ```ts
|
|
28
|
-
* import type { IsFunction } from 'type-plus'
|
|
29
|
-
*
|
|
30
26
|
* type R = IsFunction<Function> // Function
|
|
31
27
|
* type R = IsFunction<() => void> // () => void
|
|
32
28
|
* type R = IsFunction<(() => void) | { a: 1 }> // (() => void) | { a: 1 }
|
|
@@ -42,8 +38,6 @@ export type IsFunction<T, Then = true, Else = false> = FunctionType<T, Then, Els
|
|
|
42
38
|
* Check if `T` is not a `Function`.
|
|
43
39
|
*
|
|
44
40
|
* ```ts
|
|
45
|
-
* import type { NotFunctionType } from 'type-plus'
|
|
46
|
-
*
|
|
47
41
|
* type R = NotFunctionType<Function> // never
|
|
48
42
|
* type R = NotFunctionType<() => void> // never
|
|
49
43
|
* type R = NotFunctionType<(() => void) | { a: 1 }> // never
|
|
@@ -59,8 +53,6 @@ export type NotFunctionType<T, Then = T, Else = never> = FunctionType<T, Else, T
|
|
|
59
53
|
* Is `T` not a `Function`.
|
|
60
54
|
*
|
|
61
55
|
* ```ts
|
|
62
|
-
* import type { IsNotFunction } from 'type-plus'
|
|
63
|
-
*
|
|
64
56
|
* type R = IsNotFunction<Function> // false
|
|
65
57
|
* type R = IsNotFunction<() => void> // false
|
|
66
58
|
* type R = IsNotFunction<(() => void) | { a: 1 }> // false
|
|
@@ -4,8 +4,6 @@ import type { IsAnyOrNever } from '../any/any_or_never.js'
|
|
|
4
4
|
* Check if `T` is exactly `Function`.
|
|
5
5
|
*
|
|
6
6
|
* ```ts
|
|
7
|
-
* import type { StrictFunctionType } from 'type-plus'
|
|
8
|
-
*
|
|
9
7
|
* type R = StrictFunctionType<Function> // Function
|
|
10
8
|
*
|
|
11
9
|
* type R = StrictFunctionType<() => void> // never
|
|
@@ -22,8 +20,6 @@ export type StrictFunctionType<T, Then = T, Else = never> = IsAnyOrNever<
|
|
|
22
20
|
* Check if `T` is not exactly `Function`.
|
|
23
21
|
*
|
|
24
22
|
* ```ts
|
|
25
|
-
* import type { NotStrictFunctionType } from 'type-plus'
|
|
26
|
-
*
|
|
27
23
|
* type R = NotStrictFunctionType<Function> // never
|
|
28
24
|
* type R = NotStrictFunctionType<() => void> // () => void
|
|
29
25
|
*
|
|
@@ -36,8 +32,6 @@ export type NotStrictFunctionType<T, Then = T, Else = never> = StrictFunctionTyp
|
|
|
36
32
|
* Is `T` exactly `Function`.
|
|
37
33
|
*
|
|
38
34
|
* ```ts
|
|
39
|
-
* import type { IsStrictFunction } from 'type-plus'
|
|
40
|
-
*
|
|
41
35
|
* type R = IsStrictFunction<Function> // true
|
|
42
36
|
*
|
|
43
37
|
* type R = IsStrictFunction<() => void> // false
|
|
@@ -50,8 +44,6 @@ export type IsStrictFunction<T, Then = true, Else = false> = StrictFunctionType<
|
|
|
50
44
|
* Is `T` not exactly `Function`.
|
|
51
45
|
*
|
|
52
46
|
* ```ts
|
|
53
|
-
* import type { IsNotStrictFunction } from 'type-plus'
|
|
54
|
-
*
|
|
55
47
|
* type R = IsNotStrictFunction<Function> // false
|
|
56
48
|
*
|
|
57
49
|
* type R = IsNotStrictFunction<() => void> // true
|
package/ts/index.ts
CHANGED
|
@@ -81,11 +81,14 @@ export type {
|
|
|
81
81
|
NotStrictStringType,
|
|
82
82
|
StrictStringType
|
|
83
83
|
} from './string/strict_string_type.js'
|
|
84
|
+
export type { StringIncludes, StringSplit } from './string/string.js'
|
|
85
|
+
export type { StringPlus } from './string/string_plus.js'
|
|
84
86
|
export type { IsNotString, IsString, NotStringType, StringType } from './string/string_type.js'
|
|
85
87
|
export type { IsNotSymbol, IsSymbol, NotSymbolType, SymbolType } from './symbol/symbol_type.js'
|
|
86
88
|
export * from './testing/stub.js'
|
|
87
89
|
export * from './testing/test_type.js'
|
|
88
90
|
export type { IsNotTuple, IsTuple, NotTupleType, TupleType } from './tuple/tuple_type.js'
|
|
91
|
+
export type { Failed, FailedT } from './type/failed.js'
|
|
89
92
|
export type {
|
|
90
93
|
IsNotUndefined,
|
|
91
94
|
IsUndefined,
|
|
@@ -96,3 +99,4 @@ export type { UnionKeys } from './union_keys.js'
|
|
|
96
99
|
export type { IsNotUnknown, IsUnknown, NotUnknownType, UnknownType } from './unknown/unknown_type.js'
|
|
97
100
|
export * from './utils/index.js'
|
|
98
101
|
export type { IsNotVoid, IsVoid, NotVoidType, VoidType } from './void/void_type.js'
|
|
102
|
+
|
package/ts/never/never_type.ts
CHANGED
|
@@ -16,8 +16,6 @@ export type Is_Never = Brand<'is_never', symbol>
|
|
|
16
16
|
* If it is not, returns `Not_Never`.
|
|
17
17
|
*
|
|
18
18
|
* ```ts
|
|
19
|
-
* import type { NeverType } from 'type-plus'
|
|
20
|
-
*
|
|
21
19
|
* type R = NeverType<never> // never
|
|
22
20
|
*
|
|
23
21
|
* type R = NeverType<1> // 'not never'
|
|
@@ -30,8 +28,6 @@ export type NeverType<T, Then = T, Else = Not_Never> = [T, never] extends [never
|
|
|
30
28
|
* If it is not, returns `Is_Never`.
|
|
31
29
|
*
|
|
32
30
|
* ```ts
|
|
33
|
-
* import type { NotNeverType } from 'type-plus'
|
|
34
|
-
*
|
|
35
31
|
* type R = NotNeverType<1> // 1
|
|
36
32
|
*
|
|
37
33
|
* type R = NotNeverType<never> // 'is_never'
|
|
@@ -42,9 +38,7 @@ export type NotNeverType<T, Then = T, Else = Is_Never> = NeverType<T, Else, Then
|
|
|
42
38
|
/**
|
|
43
39
|
* Is `T` `never`.
|
|
44
40
|
*
|
|
45
|
-
* ```
|
|
46
|
-
* import type { IsNever } from 'type-plus'
|
|
47
|
-
*
|
|
41
|
+
* ```ts
|
|
48
42
|
* type R = IsNever<never> // true
|
|
49
43
|
*
|
|
50
44
|
* type R = IsNever<1> // false
|
|
@@ -55,9 +49,7 @@ export type IsNever<T, Then = true, Else = false> = NeverType<T, Then, Else>
|
|
|
55
49
|
/**
|
|
56
50
|
* Is `T` not `never`.
|
|
57
51
|
*
|
|
58
|
-
* ```
|
|
59
|
-
* import type { IsNotNever } from 'type-plus'
|
|
60
|
-
*
|
|
52
|
+
* ```ts
|
|
61
53
|
* type R = IsNotNever<1> // true
|
|
62
54
|
*
|
|
63
55
|
* type R = IsNotNever<never> // false
|
package/ts/nominal/brand.ts
CHANGED
|
@@ -3,15 +3,23 @@
|
|
|
3
3
|
|
|
4
4
|
import { isType } from '../predicates/isType.js'
|
|
5
5
|
import type { Widen } from '../utils/index.js'
|
|
6
|
-
import { typeSym, valueSym } from './
|
|
6
|
+
import { typeSym, valueSym } from './constants.js'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Create a "branded" version of a type.
|
|
10
10
|
* TypeScript won't allow implicit conversion to this type
|
|
11
11
|
*/
|
|
12
|
-
export type Brand<B extends string, T> = T extends
|
|
13
|
-
?
|
|
14
|
-
:
|
|
12
|
+
export type Brand<B extends string, T = never> = [T] extends [null] | [undefined] | [symbol] | [void]
|
|
13
|
+
? Branded<B, T>
|
|
14
|
+
: Branded<B, T> & T
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* A branded type of `B` with value of `T`.
|
|
18
|
+
*/
|
|
19
|
+
export interface Branded<B extends string, T> {
|
|
20
|
+
[typeSym]: B
|
|
21
|
+
[valueSym]: T
|
|
22
|
+
}
|
|
15
23
|
|
|
16
24
|
/**
|
|
17
25
|
* Creates a brand creator with the specified type.
|
|
@@ -21,15 +29,15 @@ export function brand<B extends string>(type: B): <T>(subject: T) => Brand<B, Wi
|
|
|
21
29
|
* Creates a branded value of specified type.
|
|
22
30
|
*/
|
|
23
31
|
export function brand<B extends string, T>(type: B, subject: T): Brand<B, Widen<T>>
|
|
24
|
-
export function brand(
|
|
32
|
+
export function brand(typeInput: string, subject?: unknown) {
|
|
25
33
|
if (subject === undefined)
|
|
26
34
|
return function <T>(subject: T) {
|
|
27
|
-
return brand(
|
|
35
|
+
return brand(typeInput, subject)
|
|
28
36
|
}
|
|
29
37
|
|
|
30
38
|
if (isType<{ [typeSym]: string }>(subject, s => typeof s === 'object' && s !== null)) {
|
|
31
39
|
// if subject is not an object, the branding will exist only in type-level.
|
|
32
|
-
subject[typeSym] =
|
|
40
|
+
subject[typeSym] = typeInput
|
|
33
41
|
}
|
|
34
42
|
return subject
|
|
35
43
|
}
|
package/ts/nominal/flavor.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import { isType } from '../predicates/isType.js'
|
|
5
5
|
import type { Widen } from '../utils/index.js'
|
|
6
|
-
import { typeSym } from './
|
|
6
|
+
import { typeSym, valueSym } from './constants.js'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Create a "flavored" version of a type.
|
|
@@ -11,8 +11,23 @@ import { typeSym } from './types.js'
|
|
|
11
11
|
* but will allow unflavored values of that type to be passed in where a flavored version is expected.
|
|
12
12
|
* This is a less restrictive form of branding.
|
|
13
13
|
*/
|
|
14
|
-
export type Flavor<F extends string, T> = T
|
|
14
|
+
export type Flavor<F extends string, T> = [T] extends [null] | [undefined] | [symbol] | [void]
|
|
15
|
+
? FlavoredUnit<F, T>
|
|
16
|
+
: Flavored<F> & T
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A flavored type of `F`
|
|
20
|
+
*/
|
|
21
|
+
export interface Flavored<F extends string> {
|
|
22
|
+
[typeSym]?: F
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* A special flavored type for special types.
|
|
27
|
+
*/
|
|
28
|
+
export interface FlavoredUnit<F extends string, T> {
|
|
15
29
|
[typeSym]?: F
|
|
30
|
+
[valueSym]: T
|
|
16
31
|
}
|
|
17
32
|
|
|
18
33
|
/**
|
package/ts/null/null_type.ts
CHANGED
|
@@ -3,9 +3,7 @@ import type { IsAny } from '../any/any_type.js'
|
|
|
3
3
|
/**
|
|
4
4
|
* Check if the type `T` is exactly `null`.
|
|
5
5
|
*
|
|
6
|
-
* ```
|
|
7
|
-
* import type { NullType } from 'type-plus'
|
|
8
|
-
*
|
|
6
|
+
* ```ts
|
|
9
7
|
* type R = NullType<null> // null
|
|
10
8
|
*
|
|
11
9
|
* type R = NullType<never> // never
|
|
@@ -18,9 +16,7 @@ export type NullType<T, Then = T, Else = never> = IsAny<T, Else, [T, null] exten
|
|
|
18
16
|
/**
|
|
19
17
|
* Is the type `T` exactly `null`.
|
|
20
18
|
*
|
|
21
|
-
* ```
|
|
22
|
-
* import type { IsNull } from 'type-plus'
|
|
23
|
-
*
|
|
19
|
+
* ```ts
|
|
24
20
|
* type R = IsNull<null> // true
|
|
25
21
|
*
|
|
26
22
|
* type R = IsNull<never> // false
|
|
@@ -33,9 +29,7 @@ export type IsNull<T, Then = true, Else = false> = NullType<T, Then, Else>
|
|
|
33
29
|
/**
|
|
34
30
|
* Check if the type `T` is not exactly `null`.
|
|
35
31
|
*
|
|
36
|
-
* ```
|
|
37
|
-
* import type { NotNullType } from 'type-plus'
|
|
38
|
-
*
|
|
32
|
+
* ```ts
|
|
39
33
|
* type R = NotNullType<null> // never
|
|
40
34
|
*
|
|
41
35
|
* type R = NotNullType<never> // never
|
|
@@ -48,9 +42,7 @@ export type NotNullType<T, Then = T, Else = never> = NullType<T, Else, Then>
|
|
|
48
42
|
/**
|
|
49
43
|
* Is the type `T` not exactly `null`.
|
|
50
44
|
*
|
|
51
|
-
* ```
|
|
52
|
-
* import type { IsNotNull } from 'type-plus'
|
|
53
|
-
*
|
|
45
|
+
* ```ts
|
|
54
46
|
* type R = IsNotNull<null> // false
|
|
55
47
|
*
|
|
56
48
|
* type R = IsNotNull<never> // true
|
package/ts/number/integer.ts
CHANGED
|
@@ -5,8 +5,6 @@ import type { Numeric } from './numeric_type.js'
|
|
|
5
5
|
* Check if T is an integer, including bigint.
|
|
6
6
|
*
|
|
7
7
|
* ```ts
|
|
8
|
-
* import type { Integer } from 'type-plus'
|
|
9
|
-
*
|
|
10
8
|
* type R = Integer<0> // 0
|
|
11
9
|
* type R = Integer<1n> // 1n
|
|
12
10
|
*
|
|
@@ -24,8 +22,6 @@ export type Integer<T, Then = T, Else = never> = IsAnyOrNever<
|
|
|
24
22
|
* Is T an integer, including bigint.
|
|
25
23
|
*
|
|
26
24
|
* ```ts
|
|
27
|
-
* import type { IsInteger } from 'type-plus'
|
|
28
|
-
*
|
|
29
25
|
* type R = IsInteger<0> // true
|
|
30
26
|
* type R = IsInteger<1n> // true
|
|
31
27
|
*
|
|
@@ -39,8 +35,6 @@ export type IsInteger<T, Then = true, Else = false> = Integer<T, Then, Else>
|
|
|
39
35
|
* Check if T is not an integer, including bigint.
|
|
40
36
|
*
|
|
41
37
|
* ```ts
|
|
42
|
-
* import type { NotInteger } from 'type-plus'
|
|
43
|
-
*
|
|
44
38
|
* type R = NotInteger<1.1> // 1.1
|
|
45
39
|
* type R = NotInteger<number> // number as it contains non-integer
|
|
46
40
|
*
|
|
@@ -68,9 +62,7 @@ export type IsNotInteger<T, Then = true, Else = false> = NotInteger<T, Else, The
|
|
|
68
62
|
/**
|
|
69
63
|
* Check if T is an integer, including bigint.
|
|
70
64
|
*
|
|
71
|
-
* ```
|
|
72
|
-
* import type { IsWhole } from 'type-plus'
|
|
73
|
-
*
|
|
65
|
+
* ```ts
|
|
74
66
|
* type R = IsWhole<0> // 0
|
|
75
67
|
* type R = IsWhole<1n> // 1n
|
|
76
68
|
*
|
package/ts/number/negative.ts
CHANGED
|
@@ -6,8 +6,6 @@ import type { Zero } from './numeric_type.js'
|
|
|
6
6
|
* Check if 'T' is a negative numeric type.
|
|
7
7
|
*
|
|
8
8
|
* ```ts
|
|
9
|
-
* import type { Negative } from 'type-plus'
|
|
10
|
-
*
|
|
11
9
|
* type R = Negative<-1> // -1
|
|
12
10
|
* type R = Negative<-1n> // -1n
|
|
13
11
|
*
|
|
@@ -42,8 +40,6 @@ export type Negative<T, Then = T, Else = never> = IsAny<
|
|
|
42
40
|
* Is 'T' a negative numeric type.
|
|
43
41
|
*
|
|
44
42
|
* ```ts
|
|
45
|
-
* import type { IsNegative } from 'type-plus'
|
|
46
|
-
*
|
|
47
43
|
* type R = IsNegative<-1> // true
|
|
48
44
|
* type R = IsNegative<-1n> // true
|
|
49
45
|
*
|
|
@@ -60,8 +56,6 @@ export type IsNegative<T, Then = true, Else = false> = Negative<T, Then, Else>
|
|
|
60
56
|
* Check if 'T' is not a negative numeric type.
|
|
61
57
|
*
|
|
62
58
|
* ```ts
|
|
63
|
-
* import type { NotNegative } from 'type-plus'
|
|
64
|
-
*
|
|
65
59
|
* type R = NotNegative<-1> // never
|
|
66
60
|
* type R = NotNegative<-1n> // never
|
|
67
61
|
*
|
|
@@ -94,8 +88,6 @@ export type NotNegative<T, Then = T, Else = never> = IsAny<
|
|
|
94
88
|
* Is 'T' not a negative numeric type.
|
|
95
89
|
*
|
|
96
90
|
* ```ts
|
|
97
|
-
* import type { IsNotNegative } from 'type-plus'
|
|
98
|
-
*
|
|
99
91
|
* type R = IsNotNegative<-1> // false
|
|
100
92
|
* type R = IsNotNegative<-1n> // false
|
|
101
93
|
*
|
package/ts/number/number_type.ts
CHANGED
|
@@ -4,8 +4,6 @@ import type { IsAnyOrNever } from '../any/any_or_never.js'
|
|
|
4
4
|
* Check if the type `T` is `number`.
|
|
5
5
|
*
|
|
6
6
|
* ```ts
|
|
7
|
-
* import type { NumberType } from 'type-plus'
|
|
8
|
-
*
|
|
9
7
|
* type R = NumberType<number> // true
|
|
10
8
|
* type R = NumberType<1> // true
|
|
11
9
|
*
|
|
@@ -19,8 +17,6 @@ export type NumberType<T, Then = T, Else = never> = IsAnyOrNever<T, Else, [T] ex
|
|
|
19
17
|
* Is the type `T` is `number`.
|
|
20
18
|
*
|
|
21
19
|
* ```ts
|
|
22
|
-
* import type { IsNumber } from 'type-plus'
|
|
23
|
-
*
|
|
24
20
|
* type R = IsNumber<number> // true
|
|
25
21
|
* type R = IsNumber<1> // true
|
|
26
22
|
*
|
|
@@ -34,8 +30,6 @@ export type IsNumber<T, Then = true, Else = false> = NumberType<T, Then, Else>
|
|
|
34
30
|
* Check if the type `T` is not `number`.
|
|
35
31
|
*
|
|
36
32
|
* ```ts
|
|
37
|
-
* import type { NotNumberType } from 'type-plus'
|
|
38
|
-
*
|
|
39
33
|
* type R = NotNumberType<number> // false
|
|
40
34
|
* type R = NotNumberType<1> // false
|
|
41
35
|
*
|
|
@@ -49,8 +43,6 @@ export type NotNumberType<T, Then = T, Else = never> = NumberType<T, Else, Then>
|
|
|
49
43
|
* Is the type `T` not `number`.
|
|
50
44
|
*
|
|
51
45
|
* ```ts
|
|
52
|
-
* import type { IsNotNumber } from 'type-plus'
|
|
53
|
-
*
|
|
54
46
|
* type R = IsNotNumber<number> // false
|
|
55
47
|
* type R = IsNotNumber<1> // false
|
|
56
48
|
*
|
|
@@ -15,8 +15,6 @@ export type Zero = 0 | 0n
|
|
|
15
15
|
* Meaning it is either a `number` or a `bigint`.
|
|
16
16
|
*
|
|
17
17
|
* ```ts
|
|
18
|
-
* import type { NumericType } from 'type-plus'
|
|
19
|
-
*
|
|
20
18
|
* type R = NumericType<1> // 1
|
|
21
19
|
* type R = NumericType<1.1> // 1.1
|
|
22
20
|
*
|
|
@@ -30,8 +28,6 @@ export type NumericType<T, Then = T, Else = never> = IsAnyOrNever<T, Else, [T] e
|
|
|
30
28
|
* Is `T` numeric.
|
|
31
29
|
*
|
|
32
30
|
* ```ts
|
|
33
|
-
* import type { IsNumeric } from 'type-plus'
|
|
34
|
-
*
|
|
35
31
|
* type R = IsNumeric<1> // true
|
|
36
32
|
* type R = IsNumeric<1.1> // true
|
|
37
33
|
*
|
|
@@ -45,8 +41,6 @@ export type IsNumeric<T, Then = true, Else = false> = NumericType<T, Then, Else>
|
|
|
45
41
|
* Check if `T` is not numeric.
|
|
46
42
|
*
|
|
47
43
|
* ```ts
|
|
48
|
-
* import type { NotNumericType } from 'type-plus'
|
|
49
|
-
*
|
|
50
44
|
* type R = NotNumericType<1> // never
|
|
51
45
|
* type R = NotNumericType<1.1> // never
|
|
52
46
|
*
|
|
@@ -60,8 +54,6 @@ export type NotNumericType<T, Then = T, Else = never> = NumericType<T, Else, The
|
|
|
60
54
|
* Is `T` not numeric.
|
|
61
55
|
*
|
|
62
56
|
* ```ts
|
|
63
|
-
* import type { IsNotNumeric } from 'type-plus'
|
|
64
|
-
*
|
|
65
57
|
* type R = IsNotNumeric<1> // false
|
|
66
58
|
* type R = IsNotNumeric<1.1> // false
|
|
67
59
|
*
|
package/ts/number/positive.ts
CHANGED
|
@@ -5,8 +5,6 @@ import { IsNever } from '../index.js'
|
|
|
5
5
|
* Check if `T` is a positive numeric type.
|
|
6
6
|
*
|
|
7
7
|
* ```ts
|
|
8
|
-
* import type { Positive } from 'type-plus'
|
|
9
|
-
*
|
|
10
8
|
* type R = Positive<1> // 1
|
|
11
9
|
* type R = Positive<0> // 0
|
|
12
10
|
* type R = Positive<1n> // 1n
|
|
@@ -24,15 +22,13 @@ export type Positive<T, Then = T, Else = never> = IsAny<
|
|
|
24
22
|
* Is `T` a positive numeric type.
|
|
25
23
|
*
|
|
26
24
|
* ```ts
|
|
27
|
-
* import type { IsPositive } from 'type-plus'
|
|
28
|
-
*
|
|
29
25
|
* type R = IsPositive<1> // true
|
|
30
26
|
* type R = IsPositive<0> // true
|
|
31
27
|
* type R = IsPositive<1n> // true
|
|
32
28
|
*
|
|
33
29
|
* type R = IsPositive<number> // boolean
|
|
34
30
|
* type R = IsPositive<bigint> // boolean
|
|
35
|
-
* type R =
|
|
31
|
+
* type R = IsPositive<any> // boolean
|
|
36
32
|
*
|
|
37
33
|
* type R = IsPositive<-1> // false
|
|
38
34
|
* ```
|
|
@@ -43,8 +39,6 @@ export type IsPositive<T, Then = true, Else = false> = Positive<T, Then, Else>
|
|
|
43
39
|
* Check if `T` is not a positive numeric type.
|
|
44
40
|
*
|
|
45
41
|
* ```ts
|
|
46
|
-
* import type { NonPositive } from 'type-plus'
|
|
47
|
-
*
|
|
48
42
|
* type R = NonPositive<-1> // -1
|
|
49
43
|
*
|
|
50
44
|
* type R = NonPositive<0> // never
|
|
@@ -57,8 +51,6 @@ export type NonPositive<T, Then = T, Else = never> = Positive<T, Else, Then>
|
|
|
57
51
|
* Is `T` not a positive numeric type.
|
|
58
52
|
*
|
|
59
53
|
* ```ts
|
|
60
|
-
* import type { IsNotPositive } from 'type-plus'
|
|
61
|
-
*
|
|
62
54
|
* type R = IsNotPositive<-1> // true
|
|
63
55
|
*
|
|
64
56
|
* type R = IsNotPositive<0> // false
|
|
@@ -4,8 +4,6 @@ import type { IsAny } from '../any/any_type.js'
|
|
|
4
4
|
* Check if the type `T` is exactly the type `number` and not numeric literals.
|
|
5
5
|
*
|
|
6
6
|
* ```ts
|
|
7
|
-
* import type { StrictNumberType } from 'type-plus'
|
|
8
|
-
*
|
|
9
7
|
* type R = StrictNumberType<number> // true
|
|
10
8
|
* type R = StrictNumberType<1> // false
|
|
11
9
|
*
|
|
@@ -23,8 +21,6 @@ export type StrictNumberType<T, Then = T, Else = never> = IsAny<
|
|
|
23
21
|
* Is the type `T` exactly the type `number` and not numeric literals.
|
|
24
22
|
*
|
|
25
23
|
* ```ts
|
|
26
|
-
* import type { IsStrictNumber } from 'type-plus'
|
|
27
|
-
*
|
|
28
24
|
* type R = IsStrictNumber<number> // true
|
|
29
25
|
* type R = IsStrictNumber<1> // false
|
|
30
26
|
*
|
|
@@ -38,13 +34,11 @@ export type IsStrictNumber<T, Then = true, Else = false> = StrictNumberType<T, T
|
|
|
38
34
|
* Check if the type `T` is not the type `number` or numeric literals.
|
|
39
35
|
*
|
|
40
36
|
* ```ts
|
|
41
|
-
*
|
|
37
|
+
* type R = NotStrictNumberType<number> // false
|
|
38
|
+
* type R = NotStrictNumberType<1> // true
|
|
42
39
|
*
|
|
43
|
-
* type R =
|
|
44
|
-
* type R =
|
|
45
|
-
*
|
|
46
|
-
* type R = NotStictNumberType<never> // true
|
|
47
|
-
* type R = NotStictNumberType<unknown> // true
|
|
40
|
+
* type R = NotStrictNumberType<never> // true
|
|
41
|
+
* type R = NotStrictNumberType<unknown> // true
|
|
48
42
|
* ```
|
|
49
43
|
*/
|
|
50
44
|
export type NotStrictNumberType<T, Then = T, Else = never> = StrictNumberType<T, Else, Then>
|
|
@@ -53,8 +47,6 @@ export type NotStrictNumberType<T, Then = T, Else = never> = StrictNumberType<T,
|
|
|
53
47
|
* Is the type `T` not the type `number` or numeric literals.
|
|
54
48
|
*
|
|
55
49
|
* ```ts
|
|
56
|
-
* import type { IsNotStrictNumber } from 'type-plus'
|
|
57
|
-
*
|
|
58
50
|
* type R = IsNotStrictNumber<number> // false
|
|
59
51
|
* type R = IsNotStrictNumber<1> // true
|
|
60
52
|
*
|
package/ts/object/object_type.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { IsAnyOrNever } from '../any/any_or_never.js'
|
|
1
|
+
import type { IsAnyOrNever } from '../any/any_or_never.js'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Check if `T` is an `object`.
|
|
5
5
|
*
|
|
6
6
|
* ```ts
|
|
7
|
-
* import { type ObjectType } from 'type-plus'
|
|
8
|
-
*
|
|
9
7
|
* type R = ObjectType<{}> // {}
|
|
10
8
|
* type R = ObjectType<{ a: 1 }> // { a: 1 }
|
|
11
9
|
* type R = ObjectType<Function> // Function
|
|
@@ -21,8 +19,6 @@ export type ObjectType<T, Then = T, Else = never> = IsAnyOrNever<T, Else, [T] ex
|
|
|
21
19
|
* Note that `Function` is also an `object`.
|
|
22
20
|
*
|
|
23
21
|
* ```ts
|
|
24
|
-
* import { type IsObject } from 'type-plus'
|
|
25
|
-
*
|
|
26
22
|
* type R = IsObject<{}> // true
|
|
27
23
|
* type R = IsObject<{ a: 1 }> // true
|
|
28
24
|
* type R = IsObject<Function> // true
|
|
@@ -36,8 +32,6 @@ export type IsObject<T, Then = true, Else = false> = ObjectType<T, Then, Else>
|
|
|
36
32
|
* Check if `T` is not an `object`.
|
|
37
33
|
*
|
|
38
34
|
* ```ts
|
|
39
|
-
* import { type NotObjectType } from 'type-plus'
|
|
40
|
-
*
|
|
41
35
|
* type R = NotObjectType<{}> // never
|
|
42
36
|
* type R = NotObjectType<{ a: 1 }> // never
|
|
43
37
|
* type R = NotObjectType<Function> // never
|
|
@@ -53,8 +47,6 @@ export type NotObjectType<T, Then = T, Else = never> = ObjectType<T, Else, Then>
|
|
|
53
47
|
* Note that `Function` is also an `object`.
|
|
54
48
|
*
|
|
55
49
|
* ```ts
|
|
56
|
-
* import { type IsNotObject } from 'type-plus'
|
|
57
|
-
*
|
|
58
50
|
* type R = IsNotObject<{}> // false
|
|
59
51
|
* type R = IsNotObject<{ a: 1 }> // false
|
|
60
52
|
* type R = IsNotObject<Function> // false
|
package/ts/string/readme.md
CHANGED
|
@@ -36,6 +36,11 @@ type R = StrictStringType<1> // never
|
|
|
36
36
|
- [`NotStrictStringType<T, Then = T, Else = never>`](strict_string_type.ts#L52): check if `T` is not exactly `string`.
|
|
37
37
|
- [`IsNotStrictString<T, Then = true, Else = false>`](strict_string_type.ts#L69): is `T` not exactly `string`.
|
|
38
38
|
|
|
39
|
+
## String Utilities
|
|
40
|
+
|
|
41
|
+
- [`StringIncludes<Subject, Search, Then = true, Else = false>`](./string.ts): check if `Subject` includes `Search`.
|
|
42
|
+
- [`StringSplit<Subject, Separater>`](./string.ts): split `Subject` by `Separater`.
|
|
43
|
+
|
|
39
44
|
## References
|
|
40
45
|
|
|
41
46
|
- [Handbook]
|