type-plus 6.0.0 → 6.1.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.
Files changed (183) hide show
  1. package/README.md +24 -10
  2. package/cjs/any_plus/any.d.ts +29 -0
  3. package/cjs/any_plus/any.d.ts.map +1 -0
  4. package/cjs/{number_plus/_plus.js → any_plus/any.js} +1 -1
  5. package/cjs/any_plus/any.js.map +1 -0
  6. package/cjs/any_plus/index.d.ts +2 -0
  7. package/cjs/any_plus/index.d.ts.map +1 -0
  8. package/cjs/{predicates/IsAny.js → any_plus/index.js} +1 -1
  9. package/cjs/any_plus/index.js.map +1 -0
  10. package/cjs/array_plus/array.d.ts +16 -5
  11. package/cjs/array_plus/array.d.ts.map +1 -1
  12. package/cjs/array_plus/array_plus.d.ts +35 -0
  13. package/cjs/array_plus/array_plus.d.ts.map +1 -0
  14. package/cjs/array_plus/{_plus.js → array_plus.js} +1 -1
  15. package/cjs/array_plus/array_plus.js.map +1 -0
  16. package/cjs/array_plus/create_tuple.d.ts +1 -1
  17. package/cjs/array_plus/create_tuple.d.ts.map +1 -1
  18. package/cjs/array_plus/index.d.ts +15 -15
  19. package/cjs/array_plus/index.d.ts.map +1 -1
  20. package/cjs/array_plus/pad_left.d.ts +4 -3
  21. package/cjs/array_plus/pad_left.d.ts.map +1 -1
  22. package/cjs/array_plus/tail.d.ts +1 -1
  23. package/cjs/array_plus/tail.d.ts.map +1 -1
  24. package/cjs/assertion/assertType.d.ts +1 -1
  25. package/cjs/assertion/assertType.d.ts.map +1 -1
  26. package/cjs/assertion/assertType.js.map +1 -1
  27. package/cjs/index.d.ts +3 -2
  28. package/cjs/index.d.ts.map +1 -1
  29. package/cjs/index.js +6 -5
  30. package/cjs/index.js.map +1 -1
  31. package/cjs/math/Max.d.ts +1 -1
  32. package/cjs/math/Max.d.ts.map +1 -1
  33. package/cjs/number_plus/number.d.ts +13 -0
  34. package/cjs/number_plus/number.d.ts.map +1 -1
  35. package/cjs/number_plus/number_plus.d.ts +2 -0
  36. package/cjs/number_plus/number_plus.d.ts.map +1 -0
  37. package/cjs/number_plus/number_plus.js +3 -0
  38. package/cjs/number_plus/number_plus.js.map +1 -0
  39. package/cjs/object/IsDisjoint.d.ts +2 -2
  40. package/cjs/object/IsDisjoint.d.ts.map +1 -1
  41. package/cjs/object/KeysWithDiffType.d.ts +1 -1
  42. package/cjs/object/KeysWithDiffType.d.ts.map +1 -1
  43. package/cjs/object/KnownKeys.d.ts +1 -1
  44. package/cjs/object/KnownKeys.d.ts.map +1 -1
  45. package/cjs/object/OptionalKeys.d.ts +1 -1
  46. package/cjs/object/OptionalKeys.d.ts.map +1 -1
  47. package/cjs/object/Partial.d.ts +3 -3
  48. package/cjs/object/Partial.d.ts.map +1 -1
  49. package/cjs/object/getField.d.ts +1 -1
  50. package/cjs/object/getField.d.ts.map +1 -1
  51. package/cjs/object/mapKey.d.ts +1 -1
  52. package/cjs/object/mapKey.d.ts.map +1 -1
  53. package/cjs/object/mapProperties.d.ts +1 -1
  54. package/cjs/object/mapProperties.d.ts.map +1 -1
  55. package/cjs/object/omit.d.ts +3 -3
  56. package/cjs/object/omit.d.ts.map +1 -1
  57. package/cjs/object/omit.js +2 -2
  58. package/cjs/object/omit.js.map +1 -1
  59. package/cjs/object/pick.d.ts +1 -1
  60. package/cjs/object/pick.d.ts.map +1 -1
  61. package/cjs/predicates/Equal.d.ts +1 -1
  62. package/cjs/predicates/Equal.d.ts.map +1 -1
  63. package/cjs/predicates/index.d.ts +0 -1
  64. package/cjs/predicates/index.d.ts.map +1 -1
  65. package/cjs/predicates/index.js.map +1 -1
  66. package/cjs/promise/PromiseValueMerge.d.ts +1 -2
  67. package/cjs/promise/PromiseValueMerge.d.ts.map +1 -1
  68. package/esm/any_plus/any.d.ts +29 -0
  69. package/esm/any_plus/any.d.ts.map +1 -0
  70. package/esm/any_plus/any.js +2 -0
  71. package/esm/any_plus/any.js.map +1 -0
  72. package/esm/any_plus/index.d.ts +2 -0
  73. package/esm/any_plus/index.d.ts.map +1 -0
  74. package/esm/any_plus/index.js +2 -0
  75. package/esm/any_plus/index.js.map +1 -0
  76. package/esm/array_plus/array.d.ts +16 -5
  77. package/esm/array_plus/array.d.ts.map +1 -1
  78. package/esm/array_plus/array_plus.d.ts +35 -0
  79. package/esm/array_plus/array_plus.d.ts.map +1 -0
  80. package/esm/array_plus/array_plus.js +2 -0
  81. package/esm/array_plus/array_plus.js.map +1 -0
  82. package/esm/array_plus/create_tuple.d.ts +1 -1
  83. package/esm/array_plus/create_tuple.d.ts.map +1 -1
  84. package/esm/array_plus/index.d.ts +15 -15
  85. package/esm/array_plus/index.d.ts.map +1 -1
  86. package/esm/array_plus/pad_left.d.ts +4 -3
  87. package/esm/array_plus/pad_left.d.ts.map +1 -1
  88. package/esm/array_plus/tail.d.ts +1 -1
  89. package/esm/array_plus/tail.d.ts.map +1 -1
  90. package/esm/assertion/assertType.d.ts +1 -1
  91. package/esm/assertion/assertType.d.ts.map +1 -1
  92. package/esm/assertion/assertType.js.map +1 -1
  93. package/esm/index.d.ts +3 -2
  94. package/esm/index.d.ts.map +1 -1
  95. package/esm/index.js +3 -2
  96. package/esm/index.js.map +1 -1
  97. package/esm/math/Max.d.ts +1 -1
  98. package/esm/math/Max.d.ts.map +1 -1
  99. package/esm/number_plus/number.d.ts +13 -0
  100. package/esm/number_plus/number.d.ts.map +1 -1
  101. package/esm/number_plus/number_plus.d.ts +2 -0
  102. package/esm/number_plus/number_plus.d.ts.map +1 -0
  103. package/esm/number_plus/number_plus.js +2 -0
  104. package/esm/number_plus/number_plus.js.map +1 -0
  105. package/esm/object/IsDisjoint.d.ts +2 -2
  106. package/esm/object/IsDisjoint.d.ts.map +1 -1
  107. package/esm/object/KeysWithDiffType.d.ts +1 -1
  108. package/esm/object/KeysWithDiffType.d.ts.map +1 -1
  109. package/esm/object/KnownKeys.d.ts +1 -1
  110. package/esm/object/KnownKeys.d.ts.map +1 -1
  111. package/esm/object/OptionalKeys.d.ts +1 -1
  112. package/esm/object/OptionalKeys.d.ts.map +1 -1
  113. package/esm/object/Partial.d.ts +3 -3
  114. package/esm/object/Partial.d.ts.map +1 -1
  115. package/esm/object/getField.d.ts +1 -1
  116. package/esm/object/getField.d.ts.map +1 -1
  117. package/esm/object/mapKey.d.ts +1 -1
  118. package/esm/object/mapKey.d.ts.map +1 -1
  119. package/esm/object/mapProperties.d.ts +1 -1
  120. package/esm/object/mapProperties.d.ts.map +1 -1
  121. package/esm/object/omit.d.ts +3 -3
  122. package/esm/object/omit.d.ts.map +1 -1
  123. package/esm/object/omit.js +1 -1
  124. package/esm/object/omit.js.map +1 -1
  125. package/esm/object/pick.d.ts +1 -1
  126. package/esm/object/pick.d.ts.map +1 -1
  127. package/esm/predicates/Equal.d.ts +1 -1
  128. package/esm/predicates/Equal.d.ts.map +1 -1
  129. package/esm/predicates/index.d.ts +0 -1
  130. package/esm/predicates/index.d.ts.map +1 -1
  131. package/esm/predicates/index.js.map +1 -1
  132. package/esm/promise/PromiseValueMerge.d.ts +1 -2
  133. package/esm/promise/PromiseValueMerge.d.ts.map +1 -1
  134. package/package.json +3 -3
  135. package/ts/any_plus/any.ts +29 -0
  136. package/ts/any_plus/index.ts +1 -0
  137. package/ts/array_plus/array.ts +21 -11
  138. package/ts/array_plus/array_plus.ts +66 -0
  139. package/ts/array_plus/create_tuple.ts +1 -1
  140. package/ts/array_plus/index.ts +15 -15
  141. package/ts/array_plus/pad_left.ts +4 -3
  142. package/ts/array_plus/tail.ts +1 -1
  143. package/ts/assertion/assertType.ts +1 -1
  144. package/ts/index.ts +3 -2
  145. package/ts/math/Max.ts +1 -1
  146. package/ts/number_plus/number.ts +14 -0
  147. package/ts/object/IsDisjoint.ts +2 -2
  148. package/ts/object/KeysWithDiffType.ts +1 -1
  149. package/ts/object/KnownKeys.ts +1 -1
  150. package/ts/object/OptionalKeys.ts +1 -1
  151. package/ts/object/Partial.ts +3 -3
  152. package/ts/object/getField.ts +1 -1
  153. package/ts/object/mapKey.ts +1 -1
  154. package/ts/object/mapProperties.ts +1 -1
  155. package/ts/object/omit.ts +4 -3
  156. package/ts/object/pick.ts +1 -1
  157. package/ts/predicates/Equal.ts +1 -1
  158. package/ts/predicates/index.ts +0 -1
  159. package/ts/promise/PromiseValueMerge.ts +9 -11
  160. package/cjs/array_plus/_plus.d.ts +0 -2
  161. package/cjs/array_plus/_plus.d.ts.map +0 -1
  162. package/cjs/array_plus/_plus.js.map +0 -1
  163. package/cjs/number_plus/_plus.d.ts +0 -2
  164. package/cjs/number_plus/_plus.d.ts.map +0 -1
  165. package/cjs/number_plus/_plus.js.map +0 -1
  166. package/cjs/predicates/IsAny.d.ts +0 -3
  167. package/cjs/predicates/IsAny.d.ts.map +0 -1
  168. package/cjs/predicates/IsAny.js.map +0 -1
  169. package/esm/array_plus/_plus.d.ts +0 -2
  170. package/esm/array_plus/_plus.d.ts.map +0 -1
  171. package/esm/array_plus/_plus.js +0 -2
  172. package/esm/array_plus/_plus.js.map +0 -1
  173. package/esm/number_plus/_plus.d.ts +0 -2
  174. package/esm/number_plus/_plus.d.ts.map +0 -1
  175. package/esm/number_plus/_plus.js +0 -2
  176. package/esm/number_plus/_plus.js.map +0 -1
  177. package/esm/predicates/IsAny.d.ts +0 -3
  178. package/esm/predicates/IsAny.d.ts.map +0 -1
  179. package/esm/predicates/IsAny.js +0 -2
  180. package/esm/predicates/IsAny.js.map +0 -1
  181. package/ts/array_plus/_plus.ts +0 -1
  182. package/ts/predicates/IsAny.ts +0 -3
  183. /package/ts/number_plus/{_plus.ts → number_plus.ts} +0 -0
@@ -16,9 +16,11 @@ export type Zero = 0 | 0n
16
16
  *
17
17
  * type R = Integer<0> // 0
18
18
  * type R = Integer<1.1> // never
19
+ * type R = Integer<number> // never as it contains non-integer
19
20
  *
20
21
  * type R = Integer<0, true, false> // true
21
22
  * type R = Integer<1.1, true, false> // false
23
+ *
22
24
  * ```
23
25
  */
24
26
  export type Integer<N extends Numeric, Then = N, Else = never> = `${N}` extends `${bigint}` ? Then : Else
@@ -56,3 +58,15 @@ export type Negative<N extends Numeric, Then = N, Else = never> = N extends Zero
56
58
  * ```
57
59
  */
58
60
  export type NonNegative<N extends Numeric, Then = N, Else = never> = Negative<N, Else, Then>
61
+
62
+ /**
63
+ * Check if the type `T` is exactly the type `number` and not numeric literals.
64
+ *
65
+ * ```
66
+ * import type { NumberType } from 'type-plus'
67
+ *
68
+ * type R = NumberType<number> // true
69
+ * type R = NumberType<1> // false
70
+ * ```
71
+ */
72
+ export type NumberType<T extends number, Then = T, Else = never> = number extends T ? Then : Else
@@ -1,6 +1,6 @@
1
- import { And, Not } from '../predicates/index.js'
1
+ import type { And, Not } from '../predicates/index.js'
2
2
  import type { AnyRecord } from './AnyRecord.js'
3
- import { HasKey } from './hasKey.js'
3
+ import type { HasKey } from './hasKey.js'
4
4
 
5
5
  /**
6
6
  * Are the two records disjoint from each other.
@@ -1,4 +1,4 @@
1
- import { ValueOf } from './ValueOf.js'
1
+ import type { ValueOf } from './ValueOf.js'
2
2
  import type { IsDisjoint } from './IsDisjoint.js'
3
3
  import type { AnyRecord } from './AnyRecord.js'
4
4
 
@@ -2,7 +2,7 @@
2
2
  // known from Gerrit Birkeland @Gerrit0
3
3
  // https://github.com/Microsoft/TypeScript/issues/25987#issuecomment-408339599
4
4
 
5
- import { PrimitiveTypes } from '../PrimitiveTypes.js'
5
+ import type { PrimitiveTypes } from '../PrimitiveTypes.js'
6
6
 
7
7
  // https://github.com/microsoft/TypeScript/issues/25987#issuecomment-441224690
8
8
  export type KnownKeys<T> = T extends PrimitiveTypes
@@ -1,4 +1,4 @@
1
- import { KeyTypes } from './KeyTypes.js'
1
+ import type { KeyTypes } from './KeyTypes.js'
2
2
 
3
3
  export type OptionalKeys<O extends Record<KeyTypes, any>> = O extends unknown ? OptionalKeys._<O> : never
4
4
 
@@ -1,6 +1,6 @@
1
- import { UnionKeys } from '../UnionKeys.js'
2
- import { Omit } from './omit.js'
3
- import { Pick } from './pick.js'
1
+ import type { UnionKeys } from '../UnionKeys.js'
2
+ import type { Omit } from './omit.js'
3
+ import type { Pick } from './pick.js'
4
4
 
5
5
  /**
6
6
  * Apply `Partial<>` on the selected properties.
@@ -1,4 +1,4 @@
1
- import { UnionKeys } from '../UnionKeys.js'
1
+ import type { UnionKeys } from '../UnionKeys.js'
2
2
 
3
3
  export function getField<T, TX extends Exclude<T, undefined | null>, K extends UnionKeys<TX>>(
4
4
  subject: T,
@@ -1,4 +1,4 @@
1
- import { KeyTypes } from './KeyTypes.js'
1
+ import type { KeyTypes } from './KeyTypes.js'
2
2
 
3
3
  export function mapKey<R, S extends Record<KeyTypes, any>, T = any>(
4
4
  subject: S,
@@ -1,6 +1,6 @@
1
1
  import type { AnyRecord } from './AnyRecord.js'
2
2
  import { reduceByKey } from './reduceKey.js'
3
- import { ValueOf } from './ValueOf.js'
3
+ import type { ValueOf } from './ValueOf.js'
4
4
 
5
5
  /**
6
6
  * An Object-specific version of `map`.
package/ts/object/omit.ts CHANGED
@@ -1,7 +1,8 @@
1
- import { AnyRecord, reduceByKey } from '../object/index.js'
2
- import { UnionKeys } from '../UnionKeys.js'
3
- import { Pick } from './pick.js'
1
+ import type { UnionKeys } from '../UnionKeys.js'
2
+ import type { AnyRecord } from './AnyRecord.js'
3
+ import type { Pick } from './pick.js'
4
4
  import { record } from './record.js'
5
+ import { reduceByKey } from './reduceKey.js'
5
6
 
6
7
  // by Titian Cernicova-Dragomir
7
8
  // https://github.com/microsoft/TypeScript/issues/28339#issuecomment-463577347
package/ts/object/pick.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { UnionKeys } from '../UnionKeys.js'
1
+ import type { UnionKeys } from '../UnionKeys.js'
2
2
  import type { AnyRecord } from './AnyRecord.js'
3
3
  import { record } from './record.js'
4
4
  import { reduceByKey } from './reduceKey.js'
@@ -1,4 +1,4 @@
1
- import type { IsAny } from './IsAny.js'
1
+ import type { IsAny } from '../any_plus/any.js'
2
2
  import type { And, Or } from './logical.js'
3
3
 
4
4
  /**
@@ -2,7 +2,6 @@ export * from './CanAssign.js'
2
2
  export type { Equal, IsEqual, IsNotEqual, NotEqual } from './Equal.js'
3
3
  export type { Extendable, IsExtend, IsNotExtend, NotExtendable } from './Extends.js'
4
4
  export type { If } from './If.js'
5
- export type { IsAny } from './IsAny.js'
6
5
  export type { IsEmptyObject } from './IsEmptyObject.js'
7
6
  export * from './isType.js'
8
7
  export type { And, Not, Or, Xor } from './logical.js'
@@ -1,5 +1,3 @@
1
- import type { PromiseValue } from './PromiseValue.js'
2
-
3
1
  /**
4
2
  * Merging value types from multiple promises.
5
3
  */
@@ -14,13 +12,13 @@ export type PromiseValueMerge<
14
12
  P8 extends Promise<any> = any,
15
13
  P9 extends Promise<any> = any
16
14
  > = Promise<
17
- PromiseValue<P1> &
18
- PromiseValue<P2> &
19
- PromiseValue<P3> &
20
- PromiseValue<P4> &
21
- PromiseValue<P5> &
22
- PromiseValue<P6> &
23
- PromiseValue<P7> &
24
- PromiseValue<P8> &
25
- PromiseValue<P9>
15
+ Awaited<P1> &
16
+ Awaited<P2> &
17
+ Awaited<P3> &
18
+ Awaited<P4> &
19
+ Awaited<P5> &
20
+ Awaited<P6> &
21
+ Awaited<P7> &
22
+ Awaited<P8> &
23
+ Awaited<P9>
26
24
  >
@@ -1,2 +0,0 @@
1
- export type * from './array.js';
2
- //# sourceMappingURL=_plus.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"_plus.d.ts","sourceRoot":"","sources":["../../ts/array_plus/_plus.ts"],"names":[],"mappings":"AAAA,mBAAmB,YAAY,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"_plus.js","sourceRoot":"","sources":["../../ts/array_plus/_plus.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export type * from './number.js';
2
- //# sourceMappingURL=_plus.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"_plus.d.ts","sourceRoot":"","sources":["../../ts/number_plus/_plus.ts"],"names":[],"mappings":"AAAA,mBAAmB,aAAa,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"_plus.js","sourceRoot":"","sources":["../../ts/number_plus/_plus.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- import type { IsExtend } from './Extends.js';
2
- export type IsAny<T, Then = true, Else = false> = boolean extends IsExtend<T, string> ? Then : Else;
3
- //# sourceMappingURL=IsAny.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IsAny.d.ts","sourceRoot":"","sources":["../../ts/predicates/IsAny.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAE5C,MAAM,MAAM,KAAK,CAAC,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,KAAK,IAAI,OAAO,SAAS,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC,GAAG,IAAI,GAAG,IAAI,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"IsAny.js","sourceRoot":"","sources":["../../ts/predicates/IsAny.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export type * from './array.js';
2
- //# sourceMappingURL=_plus.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"_plus.d.ts","sourceRoot":"","sources":["../../ts/array_plus/_plus.ts"],"names":[],"mappings":"AAAA,mBAAmB,YAAY,CAAA"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=_plus.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"_plus.js","sourceRoot":"","sources":["../../ts/array_plus/_plus.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export type * from './number.js';
2
- //# sourceMappingURL=_plus.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"_plus.d.ts","sourceRoot":"","sources":["../../ts/number_plus/_plus.ts"],"names":[],"mappings":"AAAA,mBAAmB,aAAa,CAAA"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=_plus.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"_plus.js","sourceRoot":"","sources":["../../ts/number_plus/_plus.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- import type { IsExtend } from './Extends.js';
2
- export type IsAny<T, Then = true, Else = false> = boolean extends IsExtend<T, string> ? Then : Else;
3
- //# sourceMappingURL=IsAny.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IsAny.d.ts","sourceRoot":"","sources":["../../ts/predicates/IsAny.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAE5C,MAAM,MAAM,KAAK,CAAC,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,KAAK,IAAI,OAAO,SAAS,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC,GAAG,IAAI,GAAG,IAAI,CAAA"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=IsAny.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IsAny.js","sourceRoot":"","sources":["../../ts/predicates/IsAny.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- export type * from './array.js'
@@ -1,3 +0,0 @@
1
- import type { IsExtend } from './Extends.js'
2
-
3
- export type IsAny<T, Then = true, Else = false> = boolean extends IsExtend<T, string> ? Then : Else
File without changes