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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string_type.d.ts","sourceRoot":"","sources":["../../ts/string/string_type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAE1D
|
|
1
|
+
{"version":3,"file":"string_type.d.ts","sourceRoot":"","sources":["../../ts/string/string_type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAE1D;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,KAAK,IAAI,YAAY,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC,CAAA;AAE7G;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,KAAK,IAAI,UAAU,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;AAE9E;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,KAAK,IAAI,UAAU,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;AAEhF;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,KAAK,IAAI,UAAU,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA"}
|
|
@@ -2,9 +2,7 @@ import type { IsAnyOrNever } from '../any/any_or_never.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* Check if the type `T` is exactly `symbol`.
|
|
4
4
|
*
|
|
5
|
-
* ```
|
|
6
|
-
* import type { SymbolType } from 'type-plus'
|
|
7
|
-
*
|
|
5
|
+
* ```ts
|
|
8
6
|
* type R = SymbolType<symbol> // symbol
|
|
9
7
|
*
|
|
10
8
|
* type R = SymbolType<never> // never
|
|
@@ -12,15 +10,11 @@ import type { IsAnyOrNever } from '../any/any_or_never.js';
|
|
|
12
10
|
* type R = SymbolType<symbol | boolean> // never
|
|
13
11
|
* ```
|
|
14
12
|
*/
|
|
15
|
-
export type SymbolType<T, Then = T, Else = never> = IsAnyOrNever<T, Else, [
|
|
16
|
-
T
|
|
17
|
-
] extends [symbol] ? Then : Else>;
|
|
13
|
+
export type SymbolType<T, Then = T, Else = never> = IsAnyOrNever<T, Else, [T] extends [symbol] ? Then : Else>;
|
|
18
14
|
/**
|
|
19
15
|
* Is the type `T` exactly `symbol`.
|
|
20
16
|
*
|
|
21
|
-
* ```
|
|
22
|
-
* import type { IsSymbol } from 'type-plus'
|
|
23
|
-
*
|
|
17
|
+
* ```ts
|
|
24
18
|
* type R = IsSymbol<symbol> // true
|
|
25
19
|
*
|
|
26
20
|
* type R = IsSymbol<never> // false
|
|
@@ -32,9 +26,7 @@ export type IsSymbol<T, Then = true, Else = false> = SymbolType<T, Then, Else>;
|
|
|
32
26
|
/**
|
|
33
27
|
* Check if the type `T` is not `symbol`.
|
|
34
28
|
*
|
|
35
|
-
* ```
|
|
36
|
-
* import type { NotSymbolType } from 'type-plus'
|
|
37
|
-
*
|
|
29
|
+
* ```ts
|
|
38
30
|
* type R = NotSymbolType<symbol> // never
|
|
39
31
|
*
|
|
40
32
|
* type R = NotSymbolType<never> // never
|
|
@@ -46,9 +38,7 @@ export type NotSymbolType<T, Then = T, Else = never> = SymbolType<T, Else, Then>
|
|
|
46
38
|
/**
|
|
47
39
|
* Is the type `T` not `symbol`.
|
|
48
40
|
*
|
|
49
|
-
* ```
|
|
50
|
-
* import type { IsNotSymbol } from 'type-plus'
|
|
51
|
-
*
|
|
41
|
+
* ```ts
|
|
52
42
|
* type R = IsNotSymbol<symbol> // false
|
|
53
43
|
*
|
|
54
44
|
* type R = IsNotSymbol<never> // true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"symbol_type.d.ts","sourceRoot":"","sources":["../../ts/symbol/symbol_type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAE1D
|
|
1
|
+
{"version":3,"file":"symbol_type.d.ts","sourceRoot":"","sources":["../../ts/symbol/symbol_type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAE1D;;;;;;;;;;GAUG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,KAAK,IAAI,YAAY,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC,CAAA;AAE7G;;;;;;;;;;GAUG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,KAAK,IAAI,UAAU,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;AAE9E;;;;;;;;;;GAUG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,KAAK,IAAI,UAAU,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;AAEhF;;;;;;;;;;GAUG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,KAAK,IAAI,UAAU,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA"}
|
|
@@ -3,8 +3,6 @@ import type { IsNever } from '../never/never_type.js';
|
|
|
3
3
|
* Check if `T` is a tuple and not an array.
|
|
4
4
|
*
|
|
5
5
|
* ```ts
|
|
6
|
-
* import type { TupleType } from 'type-plus'
|
|
7
|
-
*
|
|
8
6
|
* type R = TupleType<[]> // []
|
|
9
7
|
* type R = TupleType<[1]> // [1]
|
|
10
8
|
*
|
|
@@ -21,8 +19,6 @@ export type TupleType<T, Then = T, Else = never> = IsNever<T, Else, [
|
|
|
21
19
|
* Check if `T` is not a tuple.
|
|
22
20
|
*
|
|
23
21
|
* ```ts
|
|
24
|
-
* import type { NotTupleType } from 'type-plus'
|
|
25
|
-
*
|
|
26
22
|
* type R = NotTupleType<[]> // never
|
|
27
23
|
* type R = NotTupleType<[1]> // never
|
|
28
24
|
*
|
|
@@ -37,8 +33,6 @@ export type NotTupleType<T, Then = T, Else = never> = TupleType<T, Else, Then>;
|
|
|
37
33
|
* Is `T` a tuple and not an array.
|
|
38
34
|
*
|
|
39
35
|
* ```ts
|
|
40
|
-
* import type { IsTuple } from 'type-plus'
|
|
41
|
-
*
|
|
42
36
|
* type R = IsTuple<[]> // true
|
|
43
37
|
*
|
|
44
38
|
* type R = IsTuple<number[]> // false
|
|
@@ -52,8 +46,6 @@ export type IsTuple<T, Then = true, Else = false> = TupleType<T, Then, Else>;
|
|
|
52
46
|
* Is `T` not a tuple.
|
|
53
47
|
*
|
|
54
48
|
* ```ts
|
|
55
|
-
* import type { IsNotTuple } from 'type-plus'
|
|
56
|
-
*
|
|
57
49
|
* type R = IsNotTuple<[]> // false
|
|
58
50
|
* type R = IsNotTuple<[1]> // false
|
|
59
51
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tuple_type.d.ts","sourceRoot":"","sources":["../../ts/tuple/tuple_type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAErD
|
|
1
|
+
{"version":3,"file":"tuple_type.d.ts","sourceRoot":"","sources":["../../ts/tuple/tuple_type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAErD;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,KAAK,IAAI,OAAO,CACzD,CAAC,EACD,IAAI,EACJ;IAAC,CAAC;CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,MAAM,SAAS,CAAC,CAAC,QAAQ,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC,GAAG,IAAI,CACvE,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,KAAK,IAAI,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;AAE9E;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,KAAK,IAAI,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;AAE5E;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,KAAK,IAAI,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
declare const uniSym: unique symbol;
|
|
2
|
+
/**
|
|
3
|
+
* A failed type with message.
|
|
4
|
+
*
|
|
5
|
+
* This is analogous to the `Error` class in JavaScript.
|
|
6
|
+
*
|
|
7
|
+
* It can be used in type-level programming to failed an error message.
|
|
8
|
+
*
|
|
9
|
+
* If you want to add additional type information,
|
|
10
|
+
* use `FailedT` or create your own failed type instead.
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* type T = Failed<'error message'>
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export interface Failed<Msg extends string> {
|
|
17
|
+
[uniSym]: Msg;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A failed type with message and one additional type.
|
|
21
|
+
*
|
|
22
|
+
* Use this to add a generic type to the failed type.
|
|
23
|
+
*
|
|
24
|
+
* e.g. `FailedT<'missing', number | string>`
|
|
25
|
+
*
|
|
26
|
+
* It's recommended to create custom failed types instead of using this to provide better message.
|
|
27
|
+
*/
|
|
28
|
+
export interface FailedT<Msg extends string, T> {
|
|
29
|
+
[uniSym]: Msg;
|
|
30
|
+
}
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=failed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"failed.d.ts","sourceRoot":"","sources":["../../ts/type/failed.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,MAAM,EAAE,OAAO,MAAM,CAAA;AAEnC;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,MAAM,CAAC,GAAG,SAAS,MAAM;IACzC,CAAC,MAAM,CAAC,EAAE,GAAG,CAAA;CACb;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,OAAO,CAAC,GAAG,SAAS,MAAM,EAAE,CAAC;IAC7C,CAAC,MAAM,CAAC,EAAE,GAAG,CAAA;CACb"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"failed.js","sourceRoot":"","sources":["../../ts/type/failed.ts"],"names":[],"mappings":""}
|
|
@@ -2,9 +2,7 @@ import type { IsAny } from '../any/any_type.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* Check if the type `T` is exactly `undefined`.
|
|
4
4
|
*
|
|
5
|
-
* ```
|
|
6
|
-
* import type { UndefinedType } from 'type-plus'
|
|
7
|
-
*
|
|
5
|
+
* ```ts
|
|
8
6
|
* type R = UndefinedType<undefined> // undefined
|
|
9
7
|
*
|
|
10
8
|
* type R = UndefinedType<never> // never
|
|
@@ -19,9 +17,7 @@ export type UndefinedType<T, Then = T, Else = never> = IsAny<T, Else, [
|
|
|
19
17
|
/**
|
|
20
18
|
* Is the type `T` exactly `undefined`.
|
|
21
19
|
*
|
|
22
|
-
* ```
|
|
23
|
-
* import type { IsUndefined } from 'type-plus'
|
|
24
|
-
*
|
|
20
|
+
* ```ts
|
|
25
21
|
* type R = IsUndefined<undefined> // true
|
|
26
22
|
*
|
|
27
23
|
* type R = IsUndefined<never> // false
|
|
@@ -33,9 +29,7 @@ export type IsUndefined<T, Then = true, Else = false> = UndefinedType<T, Then, E
|
|
|
33
29
|
/**
|
|
34
30
|
* Check if the type `T` is not `undefined`.
|
|
35
31
|
*
|
|
36
|
-
* ```
|
|
37
|
-
* import type { NotUndefinedType } from 'type-plus'
|
|
38
|
-
*
|
|
32
|
+
* ```ts
|
|
39
33
|
* type R = NotUndefinedType<undefined> // never
|
|
40
34
|
*
|
|
41
35
|
* type R = NotUndefinedType<never> // never
|
|
@@ -47,9 +41,7 @@ export type NotUndefinedType<T, Then = T, Else = never> = UndefinedType<T, Else,
|
|
|
47
41
|
/**
|
|
48
42
|
* Is the type `T` not `undefined`.
|
|
49
43
|
*
|
|
50
|
-
* ```
|
|
51
|
-
* import type { IsNotUndefined } from 'type-plus'
|
|
52
|
-
*
|
|
44
|
+
* ```ts
|
|
53
45
|
* type R = IsNotUndefined<undefined> // false
|
|
54
46
|
*
|
|
55
47
|
* type R = IsNotUndefined<never> // true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"undefined_type.d.ts","sourceRoot":"","sources":["../../ts/undefined/undefined_type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE/C
|
|
1
|
+
{"version":3,"file":"undefined_type.d.ts","sourceRoot":"","sources":["../../ts/undefined/undefined_type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE/C;;;;;;;;;;GAUG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,KAAK,IAAI,KAAK,CAC3D,CAAC,EACD,IAAI,EACJ;IAAC,CAAC;IAAE,SAAS;CAAC,SAAS,CAAC,SAAS,EAAE,CAAC,CAAC,GAAG,IAAI,GAAG,IAAI,CACnD,CAAA;AAED;;;;;;;;;;GAUG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,KAAK,IAAI,aAAa,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;AAEpF;;;;;;;;;;GAUG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,KAAK,IAAI,aAAa,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;AAEtF;;;;;;;;;;GAUG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,KAAK,IAAI,aAAa,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"union_to_intersection.d.ts","sourceRoot":"","sources":["../../ts/union/union_to_intersection.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC,KAAK,IAAI,GACvG,CAAC,GACD,KAAK,CAAA;AAER,wBAAgB,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAElE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"union_to_intersection.js","sourceRoot":"","sources":["../../ts/union/union_to_intersection.ts"],"names":[],"mappings":"AAMA,MAAM,UAAU,cAAc,CAAI,KAAQ;IACzC,OAAO,KAAsC,CAAA;AAC9C,CAAC"}
|
|
@@ -2,9 +2,7 @@ import type { IsAny } from '../any/any_type.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* Check if the type `T` is exactly `unknown`.
|
|
4
4
|
*
|
|
5
|
-
* ```
|
|
6
|
-
* import type { UnknownType } from 'type-plus'
|
|
7
|
-
*
|
|
5
|
+
* ```ts
|
|
8
6
|
* type R = UnknownType<unknown> // unknown
|
|
9
7
|
*
|
|
10
8
|
* type R = UnknownType<number> // never
|
|
@@ -18,9 +16,7 @@ export type UnknownType<T, Then = T, Else = never> = IsAny<T, Else, [
|
|
|
18
16
|
/**
|
|
19
17
|
* Is the type `T` exactly `unknown`.
|
|
20
18
|
*
|
|
21
|
-
* ```
|
|
22
|
-
* import type { IsUnknown } from 'type-plus'
|
|
23
|
-
*
|
|
19
|
+
* ```ts
|
|
24
20
|
* type R = IsUnknown<unknown> // true
|
|
25
21
|
*
|
|
26
22
|
* type R = IsUnknown<number> // false
|
|
@@ -31,9 +27,7 @@ export type IsUnknown<T, Then = true, Else = false> = UnknownType<T, Then, Else>
|
|
|
31
27
|
/**
|
|
32
28
|
* Check if the type `T` is not `unknown`.
|
|
33
29
|
*
|
|
34
|
-
* ```
|
|
35
|
-
* import type { NotUnknownType } from 'type-plus'
|
|
36
|
-
*
|
|
30
|
+
* ```ts
|
|
37
31
|
* type R = NotUnknownType<unknown> // never
|
|
38
32
|
*
|
|
39
33
|
* type R = NotUnknownType<never> // never
|
|
@@ -45,9 +39,7 @@ export type NotUnknownType<T, Then = T, Else = never> = UnknownType<T, Else, The
|
|
|
45
39
|
/**
|
|
46
40
|
* Is the type `T` not exactly `unknown`.
|
|
47
41
|
*
|
|
48
|
-
* ```
|
|
49
|
-
* import type { IsNotUnknown } from 'type-plus'
|
|
50
|
-
*
|
|
42
|
+
* ```ts
|
|
51
43
|
* type R = IsNotUnknown<unknown> // false
|
|
52
44
|
*
|
|
53
45
|
* type R = IsNotUnknown<never> // true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unknown_type.d.ts","sourceRoot":"","sources":["../../ts/unknown/unknown_type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE/C
|
|
1
|
+
{"version":3,"file":"unknown_type.d.ts","sourceRoot":"","sources":["../../ts/unknown/unknown_type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE/C;;;;;;;;;GASG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,KAAK,IAAI,KAAK,CACzD,CAAC,EACD,IAAI,EACJ;IAAC,CAAC;IAAE,OAAO;CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC,GAAG,IAAI,GAAG,IAAI,CAC/C,CAAA;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,KAAK,IAAI,WAAW,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;AAEhF;;;;;;;;;;GAUG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,KAAK,IAAI,WAAW,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;AAElF;;;;;;;;;;GAUG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,KAAK,IAAI,WAAW,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA"}
|
package/esm/void/void_type.d.ts
CHANGED
|
@@ -4,8 +4,6 @@ import type { IsUndefined } from '../undefined/undefined_type.js';
|
|
|
4
4
|
* Check if `T` is `void`.
|
|
5
5
|
*
|
|
6
6
|
* ```ts
|
|
7
|
-
* import type { VoidType } from 'type-plus'
|
|
8
|
-
*
|
|
9
7
|
* type R = VoidType<void> // void
|
|
10
8
|
*
|
|
11
9
|
* type R = VoidType<1> // never
|
|
@@ -16,8 +14,6 @@ export type VoidType<T, Then = T, Else = never> = IsAnyOrNever<T, Else, IsUndefi
|
|
|
16
14
|
* Check if `T` is not `void`.
|
|
17
15
|
*
|
|
18
16
|
* ```ts
|
|
19
|
-
* import type { VoidType } from 'type-plus'
|
|
20
|
-
*
|
|
21
17
|
* type R = VoidType<void> // never
|
|
22
18
|
*
|
|
23
19
|
* type R = VoidType<1> // 1
|
|
@@ -28,8 +24,6 @@ export type NotVoidType<T, Then = T, Else = never> = VoidType<T, Else, Then>;
|
|
|
28
24
|
* Is `T` `void`.
|
|
29
25
|
*
|
|
30
26
|
* ```ts
|
|
31
|
-
* import type { IsVoid } from 'type-plus'
|
|
32
|
-
*
|
|
33
27
|
* type R = IsVoid<void> // true
|
|
34
28
|
*
|
|
35
29
|
* type R = IsVoid<1> // false
|
|
@@ -40,8 +34,6 @@ export type IsVoid<T, Then = true, Else = false> = VoidType<T, Then, Else>;
|
|
|
40
34
|
* Is `T` not `void`.
|
|
41
35
|
*
|
|
42
36
|
* ```ts
|
|
43
|
-
* import type { IsNotVoid } from 'type-plus'
|
|
44
|
-
*
|
|
45
37
|
* type R = IsNotVoid<void> // false
|
|
46
38
|
*
|
|
47
39
|
* type R = IsNotVoid<1> // true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"void_type.d.ts","sourceRoot":"","sources":["../../ts/void/void_type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAA;AAEjE
|
|
1
|
+
{"version":3,"file":"void_type.d.ts","sourceRoot":"","sources":["../../ts/void/void_type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAA;AAEjE;;;;;;;;GAQG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,KAAK,IAAI,YAAY,CAC7D,CAAC,EACD,IAAI,EACJ,WAAW,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC,CACtD,CAAA;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,KAAK,IAAI,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;AAE5E;;;;;;;;GAQG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,KAAK,IAAI,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;AAE1E;;;;;;;;GAQG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,KAAK,IAAI,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "type-plus",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.6.0",
|
|
4
4
|
"description": "Provides additional types for TypeScript.",
|
|
5
5
|
"homepage": "https://github.com/unional/type-plus",
|
|
6
6
|
"bugs": {
|
|
@@ -62,22 +62,22 @@
|
|
|
62
62
|
"ncp": "^2.0.0",
|
|
63
63
|
"npm-run-all": "^4.1.5",
|
|
64
64
|
"pinst": "^3.0.0",
|
|
65
|
-
"rimraf": "^
|
|
65
|
+
"rimraf": "^5.0.0",
|
|
66
66
|
"satisfier": "^5.2.2",
|
|
67
67
|
"size-limit": "^8.2.4",
|
|
68
68
|
"ts-jest": "^29.1.0",
|
|
69
69
|
"tslib": "^2.4.0",
|
|
70
|
-
"typedoc": "^0.
|
|
71
|
-
"typedoc-plugin-extras": "^2.2
|
|
70
|
+
"typedoc": "^0.24.1",
|
|
71
|
+
"typedoc-plugin-extras": "^2.3.2",
|
|
72
72
|
"typescript": "^5.0.2"
|
|
73
73
|
},
|
|
74
|
-
"packageManager": "pnpm@8.
|
|
74
|
+
"packageManager": "pnpm@8.2.0",
|
|
75
75
|
"scripts": {
|
|
76
76
|
"build": "run-p build:cjs build:esm build:tslib",
|
|
77
77
|
"build:cjs": "tsc -p tsconfig.cjs.json && ncp package.cjs.json cjs/package.json",
|
|
78
78
|
"build:esm": "tsc -p tsconfig.esm.json",
|
|
79
79
|
"build:tslib": "tsc -p tsconfig.tslib.json && ncp package.cjs.json tslib/package.json",
|
|
80
|
-
"build:doc": "typedoc",
|
|
80
|
+
"build:doc": "typedoc --plugin typedoc-plugin-extras",
|
|
81
81
|
"clean": "rimraf cjs coverage esm lib libm tslib",
|
|
82
82
|
"coverage": "cross-env NODE_OPTIONS=--experimental-vm-modules NODE_NO_WARNINGS=1 jest --coverage",
|
|
83
83
|
"cs": "changeset",
|
package/ts/any/any_or_never.ts
CHANGED
package/ts/any/any_type.ts
CHANGED
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Check if the type `T` is exactly `any`.
|
|
4
4
|
*
|
|
5
|
-
* ```
|
|
6
|
-
* import type { AnyType } from 'type-plus'
|
|
7
|
-
*
|
|
5
|
+
* ```ts
|
|
8
6
|
* type R = AnyType<any> // any
|
|
9
7
|
*
|
|
10
8
|
* type R = AnyType<never> // never
|
|
@@ -17,9 +15,7 @@ export type AnyType<T, Then = T, Else = never> = 0 extends 1 & T ? Then : Else
|
|
|
17
15
|
/**
|
|
18
16
|
* Is the type `T` exactly `any`.
|
|
19
17
|
*
|
|
20
|
-
* ```
|
|
21
|
-
* import type { IsAny } from 'type-plus'
|
|
22
|
-
*
|
|
18
|
+
* ```ts
|
|
23
19
|
* type R = IsAny<any> // true
|
|
24
20
|
*
|
|
25
21
|
* type R = IsAny<never> // false
|
package/ts/array/array.ts
CHANGED
|
@@ -9,8 +9,6 @@ import type { IndexAt } from './array_index.js'
|
|
|
9
9
|
* @see https://github.com/microsoft/TypeScript/issues/53345#issuecomment-1477138167
|
|
10
10
|
*
|
|
11
11
|
* ```ts
|
|
12
|
-
* import type { At } from 'type-plus'
|
|
13
|
-
*
|
|
14
12
|
* type R = At<[1, 2, 3], 2> // 3
|
|
15
13
|
* type R = At<[1, 2, 3], -1> // 3
|
|
16
14
|
* ```
|
|
@@ -29,8 +27,6 @@ export type At<A extends unknown[], N extends number, Fail = never> = IndexAt<A,
|
|
|
29
27
|
* @alias ArrayPlus.Concat
|
|
30
28
|
*
|
|
31
29
|
* ```ts
|
|
32
|
-
* import type { Concat } form 'type-plus'
|
|
33
|
-
*
|
|
34
30
|
* type R = Concat<[1], [2, 3]> // [1, 2, 3]
|
|
35
31
|
* ```
|
|
36
32
|
*/
|
package/ts/array/array_index.ts
CHANGED
|
@@ -11,14 +11,12 @@ import type { StrictNumberType } from '../number/strict_number_type.js'
|
|
|
11
11
|
/**
|
|
12
12
|
* Gets the normalized index to access the element of an array or tuple.
|
|
13
13
|
*
|
|
14
|
-
* ```
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* type R = ArrayPlus.IndexAt<['a', 'b', 'c'], 2> // 2
|
|
18
|
-
* type R = ArrayPlus.IndexAt<['a', 'b', 'c'], -2> // 1
|
|
14
|
+
* ```ts
|
|
15
|
+
* type R = IndexAt<['a', 'b', 'c'], 2> // 2
|
|
16
|
+
* type R = IndexAt<['a', 'b', 'c'], -2> // 1
|
|
19
17
|
*
|
|
20
|
-
* type R =
|
|
21
|
-
* type R =
|
|
18
|
+
* type R = IndexAt<['a', 'b', 'c'], 3> // never
|
|
19
|
+
* type R = IndexAt<['a', 'b', 'c'], -4> // never
|
|
22
20
|
* ```
|
|
23
21
|
*/
|
|
24
22
|
export type IndexAt<A extends Array<unknown>, N extends number, Fail = never> = Equal<
|
|
@@ -54,14 +52,13 @@ export type IndexAt<A extends Array<unknown>, N extends number, Fail = never> =
|
|
|
54
52
|
/**
|
|
55
53
|
* Is N an out of bound index of A.
|
|
56
54
|
*
|
|
57
|
-
* ```
|
|
58
|
-
* import { IsIndexOutOfBound } from 'type-plus'
|
|
59
|
-
*
|
|
55
|
+
* ```ts
|
|
60
56
|
* type R = IsIndexOutOfBound<[1], 0> // false
|
|
61
57
|
* type R = IsIndexOutOfBound<[1], -1> // false
|
|
62
58
|
|
|
63
59
|
* type R = IsIndexOutOfBound<[1], 1> // true
|
|
64
60
|
* type R = IsIndexOutOfBound<[1], -2> // true
|
|
61
|
+
* ```
|
|
65
62
|
*/
|
|
66
63
|
export type IsIndexOutOfBound<A extends unknown[], N extends number, Then = true, Else = false> = IsNever<
|
|
67
64
|
IndexAt<A, N>,
|
package/ts/array/array_type.ts
CHANGED
|
@@ -5,8 +5,6 @@ import type { StrictNumberType } from '../number/strict_number_type.js'
|
|
|
5
5
|
* Check if the type `T` is an array and not a tuple.
|
|
6
6
|
*
|
|
7
7
|
* ```ts
|
|
8
|
-
* import type { ArrayType } from 'type-plus'
|
|
9
|
-
*
|
|
10
8
|
* type R = ArrayType<number[]> // number[]
|
|
11
9
|
*
|
|
12
10
|
* type R = ArrayType<[1]> // never
|
|
@@ -22,8 +20,6 @@ export type ArrayType<T, Then = T, Else = never> = IsNever<
|
|
|
22
20
|
* Check if the type `T` is not an array.
|
|
23
21
|
*
|
|
24
22
|
* ```ts
|
|
25
|
-
* import type { NotArrayType } from 'type-plus'
|
|
26
|
-
*
|
|
27
23
|
* type R = NotArrayType<number[]> // never
|
|
28
24
|
*
|
|
29
25
|
* type R = NotArrayType<number> // number
|
|
@@ -36,8 +32,6 @@ export type NotArrayType<T, Then = T, Else = never> = ArrayType<T, Else, Then>
|
|
|
36
32
|
* Is `T` an array?
|
|
37
33
|
*
|
|
38
34
|
* ```ts
|
|
39
|
-
* import type { IsArray } from 'type-plus'
|
|
40
|
-
*
|
|
41
35
|
* type R = IsArray<number[]> // true
|
|
42
36
|
*
|
|
43
37
|
* type R = IsArray<number> // false
|
|
@@ -50,8 +44,6 @@ export type IsArray<T, Then = true, Else = false> = ArrayType<T, Then, Else>
|
|
|
50
44
|
* Is `T` not an array?
|
|
51
45
|
*
|
|
52
46
|
* ```ts
|
|
53
|
-
* import type { IsNotArray } from 'type-plus'
|
|
54
|
-
*
|
|
55
47
|
* type R = IsNotArray<number[]> // false
|
|
56
48
|
*
|
|
57
49
|
* type R = IsNotArray<number> // true
|
package/ts/assertion/readme.md
CHANGED
|
@@ -11,5 +11,4 @@ so that that type of the value can be narrowed down.
|
|
|
11
11
|
|
|
12
12
|
- [Handbook][assertion_functions]
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
[assertion_functions]: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#assertion-functions
|
|
14
|
+
[assertion_functions]: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#assertion-functions
|
package/ts/bigint/bigint_type.ts
CHANGED
|
@@ -3,9 +3,7 @@ import type { IsAnyOrNever } from '../any/any_or_never.js'
|
|
|
3
3
|
/**
|
|
4
4
|
* Check if the type `T` is exactly `bigint`.
|
|
5
5
|
*
|
|
6
|
-
* ```
|
|
7
|
-
* import type { BigintType } from 'type-plus'
|
|
8
|
-
*
|
|
6
|
+
* ```ts
|
|
9
7
|
* type R = BigintType<bigint> // bigint
|
|
10
8
|
*
|
|
11
9
|
* type R = BigintType<1n> // never
|
|
@@ -19,9 +17,7 @@ export type BigintType<T, Then = T, Else = never> = IsAnyOrNever<T, Else, [T] ex
|
|
|
19
17
|
/**
|
|
20
18
|
* Is the type `T` exactly `bigint`.
|
|
21
19
|
*
|
|
22
|
-
* ```
|
|
23
|
-
* import type { IsBigint } from 'type-plus'
|
|
24
|
-
*
|
|
20
|
+
* ```ts
|
|
25
21
|
* type R = IsBigint<bigint> // true
|
|
26
22
|
*
|
|
27
23
|
* type R = IsBigint<1n> // false
|
|
@@ -35,9 +31,7 @@ export type IsBigint<T, Then = true, Else = false> = BigintType<T, Then, Else>
|
|
|
35
31
|
/**
|
|
36
32
|
* Check if the type `T` is not exactly `null`.
|
|
37
33
|
*
|
|
38
|
-
* ```
|
|
39
|
-
* import type { NotBigintType } from 'type-plus'
|
|
40
|
-
*
|
|
34
|
+
* ```ts
|
|
41
35
|
* type R = NotBigintType<bigint> // never
|
|
42
36
|
*
|
|
43
37
|
* type R = NotBigintType<1n> // 1n
|
|
@@ -51,9 +45,7 @@ export type NotBigintType<T, Then = T, Else = never> = BigintType<T, Else, Then>
|
|
|
51
45
|
/**
|
|
52
46
|
* Is the type `T` not exactly `null`.
|
|
53
47
|
*
|
|
54
|
-
* ```
|
|
55
|
-
* import type { IsNotBigint } from 'type-plus'
|
|
56
|
-
*
|
|
48
|
+
* ```ts
|
|
57
49
|
* type R = IsNotBigint<bigint> // false
|
|
58
50
|
*
|
|
59
51
|
* type R = IsNotBigint<1n> // true
|
|
@@ -3,9 +3,7 @@ import type { IsAnyOrNever } from '../any/any_or_never.js'
|
|
|
3
3
|
/**
|
|
4
4
|
* Check if the type `T` is exactly `bigint`.
|
|
5
5
|
*
|
|
6
|
-
* ```
|
|
7
|
-
* import type { StrictBigintType } from 'type-plus'
|
|
8
|
-
*
|
|
6
|
+
* ```ts
|
|
9
7
|
* type R = StrictBigintType<bigint> // bigint
|
|
10
8
|
*
|
|
11
9
|
* type R = StrictBigintType<1n> // never
|
|
@@ -23,9 +21,7 @@ export type StrictBigintType<T, Then = T, Else = never> = IsAnyOrNever<
|
|
|
23
21
|
/**
|
|
24
22
|
* Is the type `T` exactly `bigint`.
|
|
25
23
|
*
|
|
26
|
-
* ```
|
|
27
|
-
* import type { IsStrictBigint } from 'type-plus'
|
|
28
|
-
*
|
|
24
|
+
* ```ts
|
|
29
25
|
* type R = IsStrictBigint<bigint> // true
|
|
30
26
|
*
|
|
31
27
|
* type R = IsStrictBigint<1n> // false
|
|
@@ -39,9 +35,7 @@ export type IsStrictBigint<T, Then = true, Else = false> = StrictBigintType<T, T
|
|
|
39
35
|
/**
|
|
40
36
|
* Check if the type `T` is not exactly `bigint`.
|
|
41
37
|
*
|
|
42
|
-
* ```
|
|
43
|
-
* import type { NotStrictBigintType } from 'type-plus'
|
|
44
|
-
*
|
|
38
|
+
* ```ts
|
|
45
39
|
* type R = NotStrictBigintType<bigint> // never
|
|
46
40
|
*
|
|
47
41
|
* type R = NotStrictBigintType<1n> // 1n
|
|
@@ -55,9 +49,7 @@ export type NotStrictBigintType<T, Then = T, Else = never> = StrictBigintType<T,
|
|
|
55
49
|
/**
|
|
56
50
|
* Is the type `T` not exactly `bigint`.
|
|
57
51
|
*
|
|
58
|
-
* ```
|
|
59
|
-
* import type { IsNotStrictBigint } from 'type-plus'
|
|
60
|
-
*
|
|
52
|
+
* ```ts
|
|
61
53
|
* type R = IsNotStrictBigint<bigint> // false
|
|
62
54
|
*
|
|
63
55
|
* type R = IsNotStrictBigint<1n> // true
|
|
@@ -4,8 +4,6 @@ import type { IsAnyOrNever } from '../any/any_or_never.js'
|
|
|
4
4
|
* Check if the type `T` is `boolean`, including `true` and `false`.
|
|
5
5
|
*
|
|
6
6
|
* ```ts
|
|
7
|
-
* import type { BooleanType } from 'type-plus'
|
|
8
|
-
*
|
|
9
7
|
* type R = BooleanType<boolean> // boolean
|
|
10
8
|
* type R = BooleanType<true> // true
|
|
11
9
|
* type R = BooleanType<false> // false
|
|
@@ -24,8 +22,6 @@ export type BooleanType<T, Then = T, Else = never> = IsAnyOrNever<
|
|
|
24
22
|
* Check if the type `T` is not `boolean`, including `true` and `false`.
|
|
25
23
|
*
|
|
26
24
|
* ```ts
|
|
27
|
-
* import type { NotBooleanType } from 'type-plus'
|
|
28
|
-
*
|
|
29
25
|
* type R = NotBooleanType<boolean> // never
|
|
30
26
|
* type R = NotBooleanType<true> // never
|
|
31
27
|
* type R = NotBooleanType<false> // never
|
|
@@ -40,8 +36,6 @@ export type NotBooleanType<T, Then = T, Else = never> = BooleanType<T, Else, The
|
|
|
40
36
|
* Is the type `T` `boolean`, including `true` and `false`.
|
|
41
37
|
*
|
|
42
38
|
* ```ts
|
|
43
|
-
* import type { IsBoolean } from 'type-plus'
|
|
44
|
-
*
|
|
45
39
|
* type R = IsBoolean<boolean> // true
|
|
46
40
|
* type R = IsBoolean<true> // true
|
|
47
41
|
* type R = IsBoolean<false> // true
|
|
@@ -56,8 +50,6 @@ export type IsBoolean<T, Then = true, Else = false> = BooleanType<T, Then, Else>
|
|
|
56
50
|
* Is the type `T` not `boolean`, including `true` and `false`.
|
|
57
51
|
*
|
|
58
52
|
* ```ts
|
|
59
|
-
* import type { IsNotBoolean } from 'type-plus'
|
|
60
|
-
*
|
|
61
53
|
* type R = IsNotBoolean<boolean> // false
|
|
62
54
|
* type R = IsNotBoolean<true> // false
|
|
63
55
|
* type R = IsNotBoolean<false> // false
|
package/ts/boolean/false_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 `false`.
|
|
5
5
|
*
|
|
6
6
|
* ```ts
|
|
7
|
-
* import type { FalseType } from 'type-plus'
|
|
8
|
-
*
|
|
9
7
|
* type R = FalseType<false> // false
|
|
10
8
|
*
|
|
11
9
|
* type R = FalseType<true> // never
|
|
@@ -22,8 +20,6 @@ export type FalseType<T, Then = T, Else = never> = IsAnyOrNever<
|
|
|
22
20
|
* Check if the type `T` is not exactly `false`.
|
|
23
21
|
*
|
|
24
22
|
* ```ts
|
|
25
|
-
* import type { NotFalseType } from 'type-plus'
|
|
26
|
-
*
|
|
27
23
|
* type R = NotFalseType<false> // never
|
|
28
24
|
*
|
|
29
25
|
* type R = NotFalseType<true> // true
|
|
@@ -36,8 +32,6 @@ export type NotFalseType<T, Then = T, Else = never> = FalseType<T, Else, Then>
|
|
|
36
32
|
* Is the type `T` exactly `false`.
|
|
37
33
|
*
|
|
38
34
|
* ```ts
|
|
39
|
-
* import type { IsFalse } from 'type-plus'
|
|
40
|
-
*
|
|
41
35
|
* type R = IsFalse<false> // true
|
|
42
36
|
*
|
|
43
37
|
* type R = IsFalse<true> // false
|
|
@@ -50,8 +44,6 @@ export type IsFalse<T, Then = true, Else = false> = FalseType<T, Then, Else>
|
|
|
50
44
|
* Is the type `T` not exactly `false`.
|
|
51
45
|
*
|
|
52
46
|
* ```ts
|
|
53
|
-
* import type { IsNotFalse } from 'type-plus'
|
|
54
|
-
*
|
|
55
47
|
* type R = IsNotFalse<false> // false
|
|
56
48
|
*
|
|
57
49
|
* type R = IsNotFalse<true> // true
|