@stryke/types 0.10.13 → 0.10.19

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.
Files changed (177) hide show
  1. package/README.md +18 -10
  2. package/dist/{array.d.ts → array-DVtfX_TI.d.mts} +17 -13
  3. package/dist/array-DVtfX_TI.d.mts.map +1 -0
  4. package/dist/array-DtIKbcDr.d.cts +122 -0
  5. package/dist/array-DtIKbcDr.d.cts.map +1 -0
  6. package/dist/array.cjs +0 -1
  7. package/dist/array.d.cts +2 -0
  8. package/dist/array.d.mts +2 -0
  9. package/dist/array.mjs +1 -0
  10. package/dist/{async.d.ts → async-BtPWg6IL.d.mts} +14 -8
  11. package/dist/async-BtPWg6IL.d.mts.map +1 -0
  12. package/dist/async-eKWh-_sF.d.cts +111 -0
  13. package/dist/async-eKWh-_sF.d.cts.map +1 -0
  14. package/dist/async.cjs +0 -1
  15. package/dist/async.d.cts +2 -0
  16. package/dist/async.d.mts +2 -0
  17. package/dist/async.mjs +1 -0
  18. package/dist/{base.d.ts → base-CiIyKS-b.d.mts} +120 -126
  19. package/dist/base-CiIyKS-b.d.mts.map +1 -0
  20. package/dist/base-Cpeh4C5c.cjs +3 -0
  21. package/dist/base-DmFPRVSE.mjs +3 -0
  22. package/dist/base-DmFPRVSE.mjs.map +1 -0
  23. package/dist/base-EF17pdAI.d.cts +331 -0
  24. package/dist/base-EF17pdAI.d.cts.map +1 -0
  25. package/dist/base.cjs +1 -16
  26. package/dist/base.d.cts +2 -0
  27. package/dist/base.d.mts +2 -0
  28. package/dist/base.mjs +1 -2
  29. package/dist/configuration-5Q2wg3Id.d.mts +71 -0
  30. package/dist/configuration-5Q2wg3Id.d.mts.map +1 -0
  31. package/dist/configuration-Dvz7q6dd.d.cts +71 -0
  32. package/dist/configuration-Dvz7q6dd.d.cts.map +1 -0
  33. package/dist/configuration.cjs +0 -1
  34. package/dist/configuration.d.cts +2 -0
  35. package/dist/configuration.d.mts +2 -0
  36. package/dist/configuration.mjs +1 -0
  37. package/dist/file-dM8RAMNC.d.cts +51 -0
  38. package/dist/file-dM8RAMNC.d.cts.map +1 -0
  39. package/dist/file-eWushyiM.d.mts +51 -0
  40. package/dist/file-eWushyiM.d.mts.map +1 -0
  41. package/dist/file.cjs +0 -1
  42. package/dist/file.d.cts +2 -0
  43. package/dist/file.d.mts +2 -0
  44. package/dist/file.mjs +1 -0
  45. package/dist/form-mTzpZCeA.d.cts +40 -0
  46. package/dist/form-mTzpZCeA.d.cts.map +1 -0
  47. package/dist/form-sNCVXIEk.d.mts +40 -0
  48. package/dist/form-sNCVXIEk.d.mts.map +1 -0
  49. package/dist/form.cjs +0 -1
  50. package/dist/form.d.cts +2 -0
  51. package/dist/form.d.mts +2 -0
  52. package/dist/form.mjs +1 -0
  53. package/dist/index.cjs +1 -214
  54. package/dist/index.d.cts +19 -0
  55. package/dist/index.d.mts +19 -0
  56. package/dist/index.mjs +1 -1
  57. package/dist/{json.d.ts → json-BlaU0Pbq.d.cts} +11 -13
  58. package/dist/json-BlaU0Pbq.d.cts.map +1 -0
  59. package/dist/json-C3wqh2t3.d.mts +70 -0
  60. package/dist/json-C3wqh2t3.d.mts.map +1 -0
  61. package/dist/json.cjs +0 -1
  62. package/dist/json.d.cts +2 -0
  63. package/dist/json.d.mts +2 -0
  64. package/dist/json.mjs +1 -0
  65. package/dist/logic-BoEG5A3-.d.cts +374 -0
  66. package/dist/logic-BoEG5A3-.d.cts.map +1 -0
  67. package/dist/logic-h9Jrrpsk.d.mts +374 -0
  68. package/dist/logic-h9Jrrpsk.d.mts.map +1 -0
  69. package/dist/logic.cjs +0 -1
  70. package/dist/logic.d.cts +2 -0
  71. package/dist/logic.d.mts +2 -0
  72. package/dist/logic.mjs +1 -0
  73. package/dist/messages-Bxu_o13x.d.mts +21 -0
  74. package/dist/messages-Bxu_o13x.d.mts.map +1 -0
  75. package/dist/messages-PtLJRJeN.d.cts +21 -0
  76. package/dist/messages-PtLJRJeN.d.cts.map +1 -0
  77. package/dist/messages.cjs +0 -1
  78. package/dist/messages.d.cts +2 -0
  79. package/dist/messages.d.mts +2 -0
  80. package/dist/messages.mjs +1 -0
  81. package/dist/navigator-DLpMW73v.d.mts +42 -0
  82. package/dist/navigator-DLpMW73v.d.mts.map +1 -0
  83. package/dist/navigator-wsxMUGqK.d.cts +42 -0
  84. package/dist/navigator-wsxMUGqK.d.cts.map +1 -0
  85. package/dist/navigator.cjs +0 -1
  86. package/dist/navigator.d.cts +2 -0
  87. package/dist/navigator.d.mts +2 -0
  88. package/dist/navigator.mjs +1 -0
  89. package/dist/number.cjs +0 -1
  90. package/dist/number.d.cts +2 -0
  91. package/dist/number.d.mts +2 -0
  92. package/dist/number.mjs +1 -0
  93. package/dist/{object.d.ts → object-B3Rc0f80.d.mts} +56 -84
  94. package/dist/object-B3Rc0f80.d.mts.map +1 -0
  95. package/dist/object-DyLgFijN.d.cts +392 -0
  96. package/dist/object-DyLgFijN.d.cts.map +1 -0
  97. package/dist/object.cjs +0 -1
  98. package/dist/object.d.cts +2 -0
  99. package/dist/object.d.mts +2 -0
  100. package/dist/object.mjs +1 -0
  101. package/dist/package-json-BYMmXu4B.d.mts +261 -0
  102. package/dist/package-json-BYMmXu4B.d.mts.map +1 -0
  103. package/dist/package-json-DMeUqEmW.d.cts +261 -0
  104. package/dist/package-json-DMeUqEmW.d.cts.map +1 -0
  105. package/dist/package-json.cjs +0 -1
  106. package/dist/package-json.d.cts +2 -0
  107. package/dist/package-json.d.mts +2 -0
  108. package/dist/package-json.mjs +1 -0
  109. package/dist/package-manager-PRcovqs-.d.mts +6 -0
  110. package/dist/package-manager-PRcovqs-.d.mts.map +1 -0
  111. package/dist/package-manager-tcG2TLVT.d.cts +6 -0
  112. package/dist/package-manager-tcG2TLVT.d.cts.map +1 -0
  113. package/dist/package-manager.cjs +0 -1
  114. package/dist/package-manager.d.cts +2 -0
  115. package/dist/package-manager.d.mts +2 -0
  116. package/dist/package-manager.mjs +1 -0
  117. package/dist/string.cjs +0 -1
  118. package/dist/string.d.cts +2 -0
  119. package/dist/string.d.mts +2 -0
  120. package/dist/string.mjs +1 -0
  121. package/dist/system-BxYi2_rE.d.mts +5 -0
  122. package/dist/system-BxYi2_rE.d.mts.map +1 -0
  123. package/dist/system-n1LPjzuJ.d.cts +5 -0
  124. package/dist/system-n1LPjzuJ.d.cts.map +1 -0
  125. package/dist/system.cjs +0 -1
  126. package/dist/system.d.cts +2 -0
  127. package/dist/system.d.mts +2 -0
  128. package/dist/system.mjs +1 -0
  129. package/dist/tsconfig-C6dWY2RO.d.cts +803 -0
  130. package/dist/tsconfig-C6dWY2RO.d.cts.map +1 -0
  131. package/dist/tsconfig-CUKA7cEN.d.mts +803 -0
  132. package/dist/tsconfig-CUKA7cEN.d.mts.map +1 -0
  133. package/dist/tsconfig.cjs +0 -1
  134. package/dist/tsconfig.d.cts +2 -0
  135. package/dist/tsconfig.d.mts +2 -0
  136. package/dist/tsconfig.mjs +1 -0
  137. package/dist/user-CkdO4wnf.d.mts +29 -0
  138. package/dist/user-CkdO4wnf.d.mts.map +1 -0
  139. package/dist/user-CovHR6Ne.d.cts +29 -0
  140. package/dist/user-CovHR6Ne.d.cts.map +1 -0
  141. package/dist/user.cjs +0 -1
  142. package/dist/user.d.cts +2 -0
  143. package/dist/user.d.mts +2 -0
  144. package/dist/user.mjs +1 -0
  145. package/dist/utilities-BVS-gcgS.d.mts +51 -0
  146. package/dist/utilities-BVS-gcgS.d.mts.map +1 -0
  147. package/dist/utilities-Jb4ggdM-.d.cts +51 -0
  148. package/dist/utilities-Jb4ggdM-.d.cts.map +1 -0
  149. package/dist/utilities.cjs +0 -1
  150. package/dist/utilities.d.cts +2 -0
  151. package/dist/utilities.d.mts +2 -0
  152. package/dist/utilities.mjs +1 -0
  153. package/dist/validations-C_7osVpS.d.mts +21 -0
  154. package/dist/validations-C_7osVpS.d.mts.map +1 -0
  155. package/dist/validations-CvwxY4RE.d.cts +21 -0
  156. package/dist/validations-CvwxY4RE.d.cts.map +1 -0
  157. package/dist/validations.cjs +0 -1
  158. package/dist/validations.d.cts +2 -0
  159. package/dist/validations.d.mts +2 -0
  160. package/dist/validations.mjs +1 -0
  161. package/package.json +68 -247
  162. package/dist/configuration.d.ts +0 -67
  163. package/dist/file.d.ts +0 -46
  164. package/dist/form.d.ts +0 -35
  165. package/dist/index.d.ts +0 -27
  166. package/dist/logic.d.ts +0 -152
  167. package/dist/messages.d.ts +0 -17
  168. package/dist/navigator.d.ts +0 -41
  169. package/dist/number.d.ts +0 -176
  170. package/dist/package-json.d.ts +0 -260
  171. package/dist/package-manager.d.ts +0 -2
  172. package/dist/string.d.ts +0 -75
  173. package/dist/system.d.ts +0 -1
  174. package/dist/tsconfig.d.ts +0 -798
  175. package/dist/user.d.ts +0 -25
  176. package/dist/utilities.d.ts +0 -53
  177. package/dist/validations.d.ts +0 -16
package/dist/logic.d.ts DELETED
@@ -1,152 +0,0 @@
1
- import type { BuildTuple, IsEqual } from "./base";
2
- import type { IsNegative, NegativeInfinity, PositiveInfinity } from "./number";
3
- import type { StringLength, StringToNumber } from "./string";
4
- /**
5
- * Returns a boolean for whether A is false.
6
- *
7
- * @example
8
- * ```
9
- * Not<true>;
10
- * //=> false
11
- *
12
- * Not<false>;
13
- * //=> true
14
- * ```
15
- */
16
- export type Not<A extends boolean> = A extends true ? false : A extends false ? true : never;
17
- /**
18
- * Returns a boolean for whether the given `boolean` is not `false`.
19
- */
20
- export type IsNotFalse<T extends boolean> = [T] extends [false] ? false : true;
21
- export type Or<A extends boolean, B extends boolean> = [
22
- A,
23
- B
24
- ][number] extends false ? false : true extends [IsEqual<A, true>, IsEqual<B, true>][number] ? true : never;
25
- export type And<A extends boolean, B extends boolean> = [
26
- A,
27
- B
28
- ][number] extends true ? true : true extends [IsEqual<A, false>, IsEqual<B, false>][number] ? false : never;
29
- /**
30
- * Returns a boolean for whether `A` represents a number greater than `B`, where `A` and `B` are both positive numeric characters.
31
- *
32
- * @example
33
- * ```
34
- * PositiveNumericCharacterGt<'5', '1'>;
35
- * //=> true
36
- *
37
- * PositiveNumericCharacterGt<'1', '1'>;
38
- * //=> false
39
- * ```
40
- */
41
- export type PositiveNumericCharacterGt<A extends string, B extends string> = NumericString extends `${infer HeadA}${A}${infer _TailA}` ? NumericString extends `${infer HeadB}${B}${infer _TailB}` ? HeadA extends `${HeadB}${infer _}${infer __}` ? true : false : never : never;
42
- /**
43
- * Returns a boolean for whether `A` represents a number greater than `B`, where `A` and `B` are both numeric strings and have the same length.
44
- *
45
- * @example
46
- * ```
47
- * SameLengthPositiveNumericStringGt<'50', '10'>;
48
- * //=> true
49
- *
50
- * SameLengthPositiveNumericStringGt<'10', '10'>;
51
- * //=> false
52
- * ```
53
- */
54
- export type SameLengthPositiveNumericStringGt<A extends string, B extends string> = A extends `${infer FirstA}${infer RestA}` ? B extends `${infer FirstB}${infer RestB}` ? FirstA extends FirstB ? SameLengthPositiveNumericStringGt<RestA, RestB> : PositiveNumericCharacterGt<FirstA, FirstB> : never : false;
55
- type NumericString = "0123456789";
56
- /**
57
- * Returns a boolean for whether `A` is greater than `B`, where `A` and `B` are both positive numeric strings.
58
- *
59
- * @example
60
- * ```
61
- * PositiveNumericStringGt<'500', '1'>;
62
- * //=> true
63
- *
64
- * PositiveNumericStringGt<'1', '1'>;
65
- * //=> false
66
- *
67
- * PositiveNumericStringGt<'1', '500'>;
68
- * //=> false
69
- * ```
70
- */
71
- export type PositiveNumericStringGt<A extends string, B extends string> = A extends B ? false : [
72
- BuildTuple<StringLength<A>, 0>,
73
- BuildTuple<StringLength<B>, 0>
74
- ] extends infer R extends [readonly unknown[], readonly unknown[]] ? R[0] extends [...R[1], ...infer Remain extends readonly unknown[]] ? 0 extends Remain["length"] ? SameLengthPositiveNumericStringGt<A, B> : true : false : never;
75
- export type LessThan<A extends number, B extends number> = number extends A | B ? never : GreaterThanOrEqual<A, B> extends true ? false : true;
76
- export type GreaterThan<A extends number, B extends number> = number extends A | B ? never : [
77
- IsEqual<A, PositiveInfinity>,
78
- IsEqual<A, NegativeInfinity>,
79
- IsEqual<B, PositiveInfinity>,
80
- IsEqual<B, NegativeInfinity>
81
- ] extends infer R extends [boolean, boolean, boolean, boolean] ? Or<And<IsEqual<R[0], true>, IsEqual<R[2], false>>, And<IsEqual<R[3], true>, IsEqual<R[1], false>>> extends true ? true : Or<And<IsEqual<R[1], true>, IsEqual<R[3], false>>, And<IsEqual<R[2], true>, IsEqual<R[0], false>>> extends true ? false : true extends R[number] ? false : [IsNegative<A>, IsNegative<B>] extends infer R extends [
82
- boolean,
83
- boolean
84
- ] ? [true, false] extends R ? false : [false, true] extends R ? true : [false, false] extends R ? PositiveNumericStringGt<`${A}`, `${B}`> : PositiveNumericStringGt<`${NumberAbsolute<B>}`, `${NumberAbsolute<A>}`> : never : never;
85
- export type GreaterThanOrEqual<A extends number, B extends number> = number extends A | B ? never : A extends B ? true : GreaterThan<A, B>;
86
- /**
87
- * Returns the minimum value from a tuple of integers.
88
- *
89
- * Note:
90
- * - Float numbers are not supported.
91
- *
92
- * @example
93
- * ```
94
- * ArrayMin<[1, 2, 5, 3]>;
95
- * //=> 1
96
- *
97
- * ArrayMin<[1, 2, 5, 3, -5]>;
98
- * //=> -5
99
- * ```
100
- */
101
- export type ArrayMin<A extends number[], Result extends number = PositiveInfinity> = number extends A[number] ? never : A extends [infer F extends number, ...infer R extends number[]] ? LessThan<F, Result> extends true ? ArrayMin<R, F> : ArrayMin<R, Result> : Result;
102
- /**
103
- * Returns the maximum value from a tuple of integers.
104
- *
105
- * Note:
106
- * - Float numbers are not supported.
107
- *
108
- * @example
109
- * ```
110
- * ArrayMax<[1, 2, 5, 3]>;
111
- * //=> 5
112
- *
113
- * ArrayMax<[1, 2, 5, 3, 99, -1]>;
114
- * //=> 99
115
- * ```
116
- */
117
- export type ArrayMax<A extends number[], Result extends number = NegativeInfinity> = number extends A[number] ? never : A extends [infer F extends number, ...infer R extends number[]] ? GreaterThan<F, Result> extends true ? ArrayMax<R, F> : ArrayMax<R, Result> : Result;
118
- /**
119
- * Returns the absolute value of a given value.
120
- *
121
- * @example
122
- * ```
123
- * NumberAbsolute<-1>;
124
- * //=> 1
125
- *
126
- * NumberAbsolute<1>;
127
- * //=> 1
128
- *
129
- * NumberAbsolute<NegativeInfinity>
130
- * //=> PositiveInfinity
131
- * ```
132
- */
133
- export type NumberAbsolute<N extends number> = `${N}` extends `-${infer StringPositiveN}` ? StringToNumber<StringPositiveN> : N;
134
- export type Subtract<A extends number, B extends number> = number extends A | B ? number : [
135
- IsEqual<A, PositiveInfinity>,
136
- IsEqual<A, NegativeInfinity>,
137
- IsEqual<B, PositiveInfinity>,
138
- IsEqual<B, NegativeInfinity>
139
- ] extends infer R extends [boolean, boolean, boolean, boolean] ? Or<And<IsEqual<R[0], true>, IsEqual<R[2], false>>, And<IsEqual<R[3], true>, IsEqual<R[1], false>>> extends true ? PositiveInfinity : Or<And<IsEqual<R[1], true>, IsEqual<R[3], false>>, And<IsEqual<R[2], true>, IsEqual<R[0], false>>> extends true ? NegativeInfinity : true extends R[number] ? number : [IsNegative<A>, IsNegative<B>] extends infer R ? [false, false] extends R ? BuildTuple<A> extends infer _R ? R extends [...BuildTuple<B>, ...infer R] ? R["length"] : number : never : LessThan<A, B> extends true ? number : [false, true] extends R ? Sum<A, NumberAbsolute<B>> : Subtract<NumberAbsolute<B>, NumberAbsolute<A>> : never : never;
140
- export type Sum<A extends number, B extends number> = number extends A | B ? number : [
141
- IsEqual<A, PositiveInfinity>,
142
- IsEqual<A, NegativeInfinity>,
143
- IsEqual<B, PositiveInfinity>,
144
- IsEqual<B, NegativeInfinity>
145
- ] extends infer R extends [boolean, boolean, boolean, boolean] ? Or<And<IsEqual<R[0], true>, IsEqual<R[3], false>>, And<IsEqual<R[2], true>, IsEqual<R[1], false>>> extends true ? PositiveInfinity : Or<And<IsEqual<R[1], true>, IsEqual<R[2], false>>, And<IsEqual<R[3], true>, IsEqual<R[0], false>>> extends true ? NegativeInfinity : true extends R[number] ? number : ([IsNegative<A>, IsNegative<B>] extends infer R ? [false, false] extends R ? [...BuildTuple<A>, ...BuildTuple<B>]["length"] : [true, true] extends R ? number : ArrayMax<[
146
- NumberAbsolute<A>,
147
- NumberAbsolute<B>
148
- ]> extends infer Max_ ? ArrayMin<[
149
- NumberAbsolute<A>,
150
- NumberAbsolute<B>
151
- ]> extends infer Min_ extends number ? Max_ extends A | B ? Subtract<Max_, Min_> : number : never : never : never) & number : never;
152
- export {};
@@ -1,17 +0,0 @@
1
- export type MessageType = "help" | "error" | "warning" | "info" | "success";
2
- export type MessageDetails<TMessageType extends MessageType = MessageType> = {
3
- code: string;
4
- message?: string;
5
- type: TMessageType;
6
- params?: Record<string, any>;
7
- } | {
8
- code?: string;
9
- message: string;
10
- type: TMessageType;
11
- params?: Record<string, any>;
12
- };
13
- export type HelpMessageDetails = MessageDetails<"help">;
14
- export type ErrorMessageDetails = MessageDetails<"error">;
15
- export type WarningMessageDetails = MessageDetails<"warning">;
16
- export type InfoMessageDetails = MessageDetails<"info">;
17
- export type SuccessMessageDetails = MessageDetails<"success">;
@@ -1,41 +0,0 @@
1
- export type EventListener = (event: Event) => void;
2
- export interface BatteryManager {
3
- supported: boolean;
4
- loading: boolean;
5
- level: number | null;
6
- charging: boolean | null;
7
- chargingTime: number | null;
8
- dischargingTime: number | null;
9
- addEventListener: (type: string, listener: () => void) => void;
10
- removeEventListener: (type: string, listener: () => void) => void;
11
- }
12
- export interface NetworkState {
13
- online: boolean;
14
- downlink: number | null;
15
- downlinkMax: number | null;
16
- effectiveType: string | null;
17
- rtt: number | null;
18
- saveData: boolean | null;
19
- type: string | null;
20
- }
21
- export declare interface NavigatorNetworkInformation {
22
- readonly connection?: NetworkInformation;
23
- }
24
- export declare interface Navigator extends NavigatorNetworkInformation {
25
- }
26
- export declare interface WorkerNavigator extends NavigatorNetworkInformation {
27
- }
28
- export type ConnectionType = "bluetooth" | "cellular" | "ethernet" | "mixed" | "none" | "other" | "unknown" | "wifi" | "wimax";
29
- export type EffectiveConnectionType = "2g" | "3g" | "4g" | "slow-2g";
30
- type Megabit = number;
31
- type Millisecond = number;
32
- export interface NetworkInformation extends EventTarget {
33
- readonly type?: ConnectionType;
34
- readonly effectiveType?: EffectiveConnectionType;
35
- readonly downlinkMax?: Megabit;
36
- readonly downlink?: Megabit;
37
- readonly rtt?: Millisecond;
38
- readonly saveData?: boolean;
39
- onchange?: EventListener;
40
- }
41
- export {};
package/dist/number.d.ts DELETED
@@ -1,176 +0,0 @@
1
- import type { Not } from "./logic";
2
- export type Numeric = number | bigint;
3
- export type Zero = 0 | 0n;
4
- /**
5
- * Matches the hidden `Infinity` type.
6
- *
7
- * Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/32277) if you want to have this type as a built-in in TypeScript.
8
- *
9
- * @see NegativeInfinity
10
- */
11
- export type PositiveInfinity = 1e999;
12
- /**
13
- * Matches the hidden `-Infinity` type.
14
- *
15
- * Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/32277) if you want to have this type as a built-in in TypeScript.
16
- *
17
- * @see PositiveInfinity
18
- */
19
- export type NegativeInfinity = -1e999;
20
- /**
21
- * A finite `number`.
22
- * You can't pass a `bigint` as they are already guaranteed to be finite.
23
- *
24
- * Use-case: Validating and documenting parameters.
25
- *
26
- * Note: This can't detect `NaN`, please upvote [this issue](https://github.com/microsoft/TypeScript/issues/28682) if you want to have this type as a built-in in TypeScript.
27
- *
28
- * @example
29
- * ```
30
- * import type {Finite} from 'type-fest';
31
- *
32
- * declare function setScore<T extends number>(length: Finite<T>): void;
33
- * ```
34
- */
35
- export type Finite<T extends number> = T extends PositiveInfinity | NegativeInfinity ? never : T;
36
- /**
37
- * A `number` that is an integer.
38
- *
39
- * Use-case: Validating and documenting parameters.
40
- *
41
- * @example
42
- * ```
43
- * type Integer = Integer<1>;
44
- * //=> 1
45
- *
46
- * type IntegerWithDecimal = Integer<1.0>;
47
- * //=> 1
48
- *
49
- * type NegativeInteger = Integer<-1>;
50
- * //=> -1
51
- *
52
- * type Float = Integer<1.5>;
53
- * //=> never
54
- *
55
- * // Supports non-decimal numbers
56
- *
57
- * type OctalInteger: Integer<0o10>;
58
- * //=> 0o10
59
- *
60
- * type BinaryInteger: Integer<0b10>;
61
- * //=> 0b10
62
- *
63
- * type HexadecimalInteger: Integer<0x10>;
64
- * //=> 0x10
65
- * ```
66
- *
67
- * @example
68
- * ```
69
- * import type {Integer} from 'type-fest';
70
- *
71
- * declare function setYear<T extends number>(length: Integer<T>): void;
72
- * ```
73
- *
74
- * @see NegativeInteger
75
- * @see NonNegativeInteger
76
- */
77
- export type Integer<T> = T extends unknown ? IsInteger<T> extends true ? T : never : never;
78
- export type IsInteger<T> = T extends bigint ? true : T extends number ? number extends T ? false : T extends PositiveInfinity | NegativeInfinity ? false : Not<IsFloat<T>> : false;
79
- export type IsFloat<T> = T extends number ? `${T}` extends `${string | number | bigint | boolean | null | undefined}${number}.${infer Decimal extends number}` ? Decimal extends Zero ? false : true : false : false;
80
- /**
81
- * A `number` that is not an integer.
82
- *
83
- * Use-case: Validating and documenting parameters.
84
- *
85
- * It does not accept `Infinity`.
86
- *
87
- * @example
88
- * ```
89
- * import type {Float} from 'type-fest';
90
- *
91
- * declare function setPercentage<T extends number>(length: Float<T>): void;
92
- * ```
93
- *
94
- * @see Integer
95
- */
96
- export type Float<T> = T extends unknown ? IsFloat<T> extends true ? T : never : never;
97
- /**
98
- * A negative (`-∞ < x < 0`) `number` that is not an integer.
99
- * Equivalent to `Negative<Float<T>>`.
100
- *
101
- * Use-case: Validating and documenting parameters.
102
- *
103
- * @see Negative
104
- * @see Float
105
- */
106
- export type NegativeFloat<T extends number> = Negative<Float<T>>;
107
- /**
108
- * A negative `number`/`bigint` (`-∞ < x < 0`)
109
- *
110
- * Use-case: Validating and documenting parameters.
111
- *
112
- * @see NegativeInteger
113
- * @see NonNegative
114
- */
115
- export type Negative<T extends Numeric> = T extends Zero ? never : `${T}` extends `-${string}` ? T : never;
116
- /**
117
- * A negative (`-∞ < x < 0`) `number` that is an integer.
118
- * Equivalent to `Negative<Integer<T>>`.
119
- *
120
- * You can't pass a `bigint` as they are already guaranteed to be integers, instead use `Negative<T>`.
121
- *
122
- * Use-case: Validating and documenting parameters.
123
- *
124
- * @see Negative
125
- * @see Integer
126
- */
127
- export type NegativeInteger<T extends number> = Negative<Integer<T>>;
128
- /**
129
- * A non-negative `number`/`bigint` (`0 <= x < ∞`).
130
- *
131
- * Use-case: Validating and documenting parameters.
132
- *
133
- * @see NonNegativeInteger
134
- * @see Negative
135
- *
136
- * @example
137
- * ```
138
- * import type {NonNegative} from 'type-fest';
139
- *
140
- * declare function setLength<T extends number>(length: NonNegative<T>): void;
141
- * ```
142
- */
143
- export type NonNegative<T extends Numeric> = T extends Zero ? T : Negative<T> extends never ? T : never;
144
- /**
145
- * A non-negative (`0 <= x < ∞`) `number` that is an integer.
146
- * Equivalent to `NonNegative<Integer<T>>`.
147
- *
148
- * You can't pass a `bigint` as they are already guaranteed to be integers, instead use `NonNegative<T>`.
149
- *
150
- * Use-case: Validating and documenting parameters.
151
- *
152
- * @see NonNegative
153
- * @see Integer
154
- *
155
- * @example
156
- * ```
157
- * import type {NonNegativeInteger} from 'type-fest';
158
- *
159
- * declare function setLength<T extends number>(length: NonNegativeInteger<T>): void;
160
- * ```
161
- */
162
- export type NonNegativeInteger<T extends number> = NonNegative<Integer<T>>;
163
- /**
164
- * Returns a boolean for whether the given number is a negative number.
165
- *
166
- * @see Negative
167
- *
168
- * @example
169
- * ```
170
- * import type {IsNegative} from 'type-fest';
171
- *
172
- * type ShouldBeFalse = IsNegative<1>;
173
- * type ShouldBeTrue = IsNegative<-1>;
174
- * ```
175
- */
176
- export type IsNegative<T extends Numeric> = T extends Negative<T> ? true : false;
@@ -1,260 +0,0 @@
1
- /**
2
- * The `package.json` file is the only required file in a package. It must be located at the root of a package, and can contain the following fields.
3
- */
4
- export interface PackageJson extends Record<string, any> {
5
- /**
6
- * The name is what your thing is called.
7
- * Some rules:
8
- * - The name must be less than or equal to 214 characters. This includes the scope for scoped packages.
9
- * - The name can’t start with a dot or an underscore.
10
- * - New packages must not have uppercase letters in the name.
11
- * - The name ends up being part of a URL, an argument on the command line, and a folder name. Therefore, the name can’t contain any non-URL-safe characters.
12
- */
13
- name?: string;
14
- /**
15
- * Version must be parseable by `node-semver`, which is bundled with npm as a dependency. (`npm install semver` to use it yourself.)
16
- */
17
- version?: string;
18
- /**
19
- * Put a description in it. It’s a string. This helps people discover your package, as it’s listed in `npm search`.
20
- */
21
- description?: string;
22
- /**
23
- * Put keywords in it. It’s an array of strings. This helps people discover your package as it’s listed in `npm search`.
24
- */
25
- keywords?: string[];
26
- /**
27
- * The url to the project homepage.
28
- */
29
- homepage?: string;
30
- /**
31
- * The url to your project’s issue tracker and / or the email address to which issues should be reported. These are helpful for people who encounter issues with your package.
32
- */
33
- bugs?: string | {
34
- url?: string;
35
- email?: string;
36
- };
37
- /**
38
- * You should specify a license for your package so that people know how they are permitted to use it, and any restrictions you’re placing on it.
39
- */
40
- license?: string;
41
- /**
42
- * Specify the place where your code lives. This is helpful for people who want to contribute. If the git repo is on GitHub, then the `npm docs` command will be able to find you.
43
- * For GitHub, GitHub gist, Bitbucket, or GitLab repositories you can use the same shortcut syntax you use for npm install:
44
- */
45
- repository?: string | {
46
- type: string;
47
- url: string;
48
- /**
49
- * If the `package.json` for your package is not in the root directory (for example if it is part of a monorepo), you can specify the directory in which it lives:
50
- */
51
- directory?: string;
52
- };
53
- /**
54
- * The `scripts` field is a dictionary containing script commands that are run at various times in the lifecycle of your package.
55
- */
56
- scripts?: Record<string, string>;
57
- /**
58
- * If you set `"private": true` in your package.json, then npm will refuse to publish it.
59
- */
60
- private?: boolean;
61
- /**
62
- * The “author” is one person.
63
- */
64
- author?: PackageJsonPerson;
65
- /**
66
- * “contributors” is an array of people.
67
- */
68
- contributors?: PackageJsonPerson[];
69
- /**
70
- * The optional `files` field is an array of file patterns that describes the entries to be included when your package is installed as a dependency. File patterns follow a similar syntax to `.gitignore`, but reversed: including a file, directory, or glob pattern (`*`, `**\/*`, and such) will make it so that file is included in the tarball when it’s packed. Omitting the field will make it default to `["*"]`, which means it will include all files.
71
- */
72
- files?: string[];
73
- /**
74
- * The main field is a module ID that is the primary entry point to your program. That is, if your package is named `foo`, and a user installs it, and then does `require("foo")`, then your main module’s exports object will be returned.
75
- * This should be a module ID relative to the root of your package folder.
76
- * For most modules, it makes the most sense to have a main script and often not much else.
77
- */
78
- main?: string;
79
- /**
80
- * If your module is meant to be used client-side the browser field should be used instead of the main field. This is helpful to hint users that it might rely on primitives that aren’t available in Node.js modules. (e.g. window)
81
- */
82
- browser?: string | Record<string, string | false>;
83
- /**
84
- * The `unpkg` field is used to specify the URL to a UMD module for your package. This is used by default in the unpkg.com CDN service.
85
- */
86
- unpkg?: string;
87
- /**
88
- * A map of command name to local file name. On install, npm will symlink that file into `prefix/bin` for global installs, or `./node_modules/.bin/` for local installs.
89
- */
90
- bin?: string | Record<string, string>;
91
- /**
92
- * Specify either a single file or an array of filenames to put in place for the `man` program to find.
93
- */
94
- man?: string | string[];
95
- /**
96
- * Dependencies are specified in a simple object that maps a package name to a version range. The version range is a string which has one or more space-separated descriptors. Dependencies can also be identified with a tarball or git URL.
97
- */
98
- dependencies?: Record<string, string>;
99
- /**
100
- * If someone is planning on downloading and using your module in their program, then they probably don’t want or need to download and build the external test or documentation framework that you use.
101
- * In this case, it’s best to map these additional items in a `devDependencies` object.
102
- */
103
- devDependencies?: Record<string, string>;
104
- /**
105
- * If a dependency can be used, but you would like npm to proceed if it cannot be found or fails to install, then you may put it in the `optionalDependencies` object. This is a map of package name to version or url, just like the `dependencies` object. The difference is that build failures do not cause installation to fail.
106
- */
107
- optionalDependencies?: Record<string, string>;
108
- /**
109
- * In some cases, you want to express the compatibility of your package with a host tool or library, while not necessarily doing a `require` of this host. This is usually referred to as a plugin. Notably, your module may be exposing a specific interface, expected and specified by the host documentation.
110
- */
111
- peerDependencies?: Record<string, string>;
112
- /**
113
- * TypeScript typings, typically ending by `.d.ts`.
114
- */
115
- types?: string;
116
- /**
117
- * This field is synonymous with `types`.
118
- */
119
- typings?: string;
120
- /**
121
- * Non-Standard Node.js alternate entry-point to main.
122
- * An initial implementation for supporting CJS packages (from main), and use module for ESM modules.
123
- */
124
- module?: string;
125
- /**
126
- * Make main entry-point be loaded as an ESM module, support "export" syntax instead of "require"
127
- *
128
- * Docs:
129
- * - https://nodejs.org/docs/latest-v14.x/api/esm.html#esm_package_json_type_field
130
- *
131
- * @defaultValue 'commonjs'
132
- */
133
- type?: "module" | "commonjs";
134
- /**
135
- * Alternate and extensible alternative to "main" entry point.
136
- *
137
- * When using `{type: "module"}`, any ESM module file MUST end with `.mjs` extension.
138
- *
139
- * Docs:
140
- * - https://nodejs.org/docs/latest-v14.x/api/esm.html#esm_exports_sugar
141
- */
142
- exports?: PackageJsonExports;
143
- /**
144
- * Docs:
145
- * - https://nodejs.org/api/packages.html#imports
146
- */
147
- imports?: Record<string, string | Record<string, string>>;
148
- /**
149
- * The field is used to define a set of sub-packages (or workspaces) within a monorepo.
150
- *
151
- * This field is an array of glob patterns or an object with specific configurations for managing
152
- * multiple packages in a single repository.
153
- */
154
- workspaces?: string[];
155
- /**
156
- * The field is is used to specify different TypeScript declaration files for
157
- * different versions of TypeScript, allowing for version-specific type definitions.
158
- */
159
- typesVersions?: Record<string, Record<string, string[]>>;
160
- /**
161
- * You can specify which operating systems your module will run on:
162
- * ```json
163
- * {
164
- * "os": ["darwin", "linux"]
165
- * }
166
- * ```
167
- * You can also block instead of allowing operating systems, just prepend the blocked os with a '!':
168
- * ```json
169
- * {
170
- * "os": ["!win32"]
171
- * }
172
- * ```
173
- * The host operating system is determined by `process.platform`
174
- * It is allowed to both block and allow an item, although there isn't any good reason to do this.
175
- */
176
- os?: string[];
177
- /**
178
- * If your code only runs on certain cpu architectures, you can specify which ones.
179
- * ```json
180
- * {
181
- * "cpu": ["x64", "ia32"]
182
- * }
183
- * ```
184
- * Like the `os` option, you can also block architectures:
185
- * ```json
186
- * {
187
- * "cpu": ["!arm", "!mips"]
188
- * }
189
- * ```
190
- * The host architecture is determined by `process.arch`
191
- */
192
- cpu?: string[];
193
- /**
194
- * This is a set of config values that will be used at publish-time.
195
- */
196
- publishConfig?: {
197
- /**
198
- * The registry that will be used if the package is published.
199
- */
200
- registry?: string;
201
- /**
202
- * The tag that will be used if the package is published.
203
- */
204
- tag?: string;
205
- /**
206
- * The access level that will be used if the package is published.
207
- */
208
- access?: "public" | "restricted";
209
- /**
210
- * **pnpm-only**
211
- *
212
- * By default, for portability reasons, no files except those listed in
213
- * the bin field will be marked as executable in the resulting package
214
- * archive. The executableFiles field lets you declare additional fields
215
- * that must have the executable flag (+x) set even if
216
- * they aren't directly accessible through the bin field.
217
- */
218
- executableFiles?: string[];
219
- /**
220
- * **pnpm-only**
221
- *
222
- * You also can use the field `publishConfig.directory` to customize
223
- * the published subdirectory relative to the current `package.json`.
224
- *
225
- * It is expected to have a modified version of the current package in
226
- * the specified directory (usually using third party build tools).
227
- */
228
- directory?: string;
229
- /**
230
- * **pnpm-only**
231
- *
232
- * When set to `true`, the project will be symlinked from the
233
- * `publishConfig.directory` location during local development.
234
- *
235
- * @defaultValue true
236
- */
237
- linkDirectory?: boolean;
238
- } & Pick<PackageJson, "bin" | "main" | "exports" | "types" | "typings" | "module" | "browser" | "unpkg" | "typesVersions" | "os" | "cpu">;
239
- /**
240
- * See: https://nodejs.org/api/packages.html#packagemanager
241
- * This field defines which package manager is expected to be used when working on the current project.
242
- * Should be of the format: `<name>@<version>[#hash]`
243
- */
244
- packageManager?: string;
245
- [key: string]: any;
246
- }
247
- /**
248
- * A “person” is an object with a “name” field and optionally “url” and “email”. Or you can shorten that all into a single string, and npm will parse it for you.
249
- */
250
- type PackageJsonPerson = string | {
251
- name: string;
252
- email?: string;
253
- url?: string;
254
- };
255
- type PackageJsonExportKey = "." | "import" | "require" | "types" | "node" | "browser" | "default" | (string & {});
256
- type PackageJsonExportsObject = {
257
- [P in PackageJsonExportKey]?: string | PackageJsonExportsObject | Array<string | PackageJsonExportsObject>;
258
- };
259
- type PackageJsonExports = string | PackageJsonExportsObject | Array<string | PackageJsonExportsObject>;
260
- export {};
@@ -1,2 +0,0 @@
1
- export type PackageManager = "npm" | "yarn" | "pnpm" | "bun";
2
- export type PackageManagerLockFile = "package-lock.json" | "yarn.lock" | "pnpm-lock.yaml" | "bun.lock";