type-plus 7.4.0 → 7.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.
Files changed (202) hide show
  1. package/README.md +81 -92
  2. package/cjs/array/array.entries.d.ts +4 -3
  3. package/cjs/array/array.entries.d.ts.map +1 -1
  4. package/cjs/array/array_index.d.ts +4 -1
  5. package/cjs/array/array_index.d.ts.map +1 -1
  6. package/cjs/array/array_plus.common_prop_keys.d.ts +27 -0
  7. package/cjs/array/array_plus.common_prop_keys.d.ts.map +1 -0
  8. package/cjs/array/array_plus.common_prop_keys.js +3 -0
  9. package/cjs/array/array_plus.common_prop_keys.js.map +1 -0
  10. package/cjs/array/array_plus.d.ts +6 -3
  11. package/cjs/array/array_plus.d.ts.map +1 -1
  12. package/cjs/array/array_plus.drop_match.d.ts +4 -0
  13. package/cjs/array/array_plus.drop_match.d.ts.map +1 -0
  14. package/cjs/array/array_plus.drop_match.js +3 -0
  15. package/cjs/array/array_plus.drop_match.js.map +1 -0
  16. package/cjs/array/array_plus.element_match.d.ts +44 -0
  17. package/cjs/array/array_plus.element_match.d.ts.map +1 -0
  18. package/cjs/array/array_plus.element_match.js +3 -0
  19. package/cjs/array/array_plus.element_match.js.map +1 -0
  20. package/cjs/array/array_plus.find.d.ts +57 -0
  21. package/cjs/array/array_plus.find.d.ts.map +1 -0
  22. package/cjs/array/array_plus.find.js +3 -0
  23. package/cjs/array/array_plus.find.js.map +1 -0
  24. package/cjs/array/array_plus.split_at.d.ts +20 -15
  25. package/cjs/array/array_plus.split_at.d.ts.map +1 -1
  26. package/cjs/array/find_first.d.ts +62 -0
  27. package/cjs/array/find_first.d.ts.map +1 -0
  28. package/cjs/array/{array.find.js → find_first.js} +1 -1
  29. package/cjs/array/find_first.js.map +1 -0
  30. package/cjs/array/head.d.ts +18 -6
  31. package/cjs/array/head.d.ts.map +1 -1
  32. package/cjs/array/last.d.ts +17 -6
  33. package/cjs/array/last.d.ts.map +1 -1
  34. package/cjs/assertion/assert_type.d.ts +4 -1
  35. package/cjs/assertion/assert_type.d.ts.map +1 -1
  36. package/cjs/assertion/assert_type.js.map +1 -1
  37. package/cjs/index.d.ts +5 -2
  38. package/cjs/index.d.ts.map +1 -1
  39. package/cjs/index.js.map +1 -1
  40. package/cjs/never/never_type.d.ts +11 -0
  41. package/cjs/never/never_type.d.ts.map +1 -1
  42. package/cjs/object/index.d.ts +0 -1
  43. package/cjs/object/index.d.ts.map +1 -1
  44. package/cjs/object/index.js.map +1 -1
  45. package/cjs/testing/test_type.d.ts +277 -276
  46. package/cjs/testing/test_type.d.ts.map +1 -1
  47. package/cjs/testing/test_type.js.map +1 -1
  48. package/cjs/tuple/common_prop_keys.d.ts +15 -10
  49. package/cjs/tuple/common_prop_keys.d.ts.map +1 -1
  50. package/cjs/tuple/drop.d.ts +45 -26
  51. package/cjs/tuple/drop.d.ts.map +1 -1
  52. package/cjs/tuple/drop.js.map +1 -1
  53. package/cjs/tuple/tuple_plus.common_prop_keys.d.ts +28 -0
  54. package/cjs/tuple/tuple_plus.common_prop_keys.d.ts.map +1 -0
  55. package/cjs/tuple/tuple_plus.common_prop_keys.js +3 -0
  56. package/cjs/tuple/tuple_plus.common_prop_keys.js.map +1 -0
  57. package/cjs/tuple/tuple_plus.d.ts +3 -0
  58. package/cjs/tuple/tuple_plus.d.ts.map +1 -1
  59. package/cjs/tuple/tuple_plus.drop_match.d.ts +6 -0
  60. package/cjs/tuple/tuple_plus.drop_match.d.ts.map +1 -0
  61. package/cjs/tuple/tuple_plus.drop_match.js +3 -0
  62. package/cjs/tuple/tuple_plus.drop_match.js.map +1 -0
  63. package/cjs/tuple/tuple_plus.filter.d.ts +2 -2
  64. package/cjs/tuple/tuple_plus.find.d.ts +64 -0
  65. package/cjs/tuple/tuple_plus.find.d.ts.map +1 -0
  66. package/cjs/tuple/tuple_plus.find.js +3 -0
  67. package/cjs/tuple/tuple_plus.find.js.map +1 -0
  68. package/cjs/tuple/tuple_plus.pad_start.d.ts +7 -6
  69. package/cjs/tuple/tuple_plus.pad_start.d.ts.map +1 -1
  70. package/cjs/tuple/tuple_type.d.ts +41 -23
  71. package/cjs/tuple/tuple_type.d.ts.map +1 -1
  72. package/cjs/union/union.d.ts +33 -0
  73. package/cjs/union/union.d.ts.map +1 -0
  74. package/cjs/union/union.js +3 -0
  75. package/cjs/union/union.js.map +1 -0
  76. package/cjs/unknown/unknown_type.d.ts +12 -0
  77. package/cjs/unknown/unknown_type.d.ts.map +1 -1
  78. package/cjs/utils/options.d.ts +10 -0
  79. package/cjs/utils/options.d.ts.map +1 -0
  80. package/cjs/utils/options.js +3 -0
  81. package/cjs/utils/options.js.map +1 -0
  82. package/esm/array/array.entries.d.ts +4 -3
  83. package/esm/array/array.entries.d.ts.map +1 -1
  84. package/esm/array/array_index.d.ts +4 -1
  85. package/esm/array/array_index.d.ts.map +1 -1
  86. package/esm/array/array_plus.common_prop_keys.d.ts +27 -0
  87. package/esm/array/array_plus.common_prop_keys.d.ts.map +1 -0
  88. package/esm/array/array_plus.common_prop_keys.js +2 -0
  89. package/esm/array/array_plus.common_prop_keys.js.map +1 -0
  90. package/esm/array/array_plus.d.ts +6 -3
  91. package/esm/array/array_plus.d.ts.map +1 -1
  92. package/esm/array/array_plus.drop_match.d.ts +4 -0
  93. package/esm/array/array_plus.drop_match.d.ts.map +1 -0
  94. package/esm/array/array_plus.drop_match.js +2 -0
  95. package/esm/array/array_plus.drop_match.js.map +1 -0
  96. package/esm/array/array_plus.element_match.d.ts +44 -0
  97. package/esm/array/array_plus.element_match.d.ts.map +1 -0
  98. package/esm/array/array_plus.element_match.js +2 -0
  99. package/esm/array/array_plus.element_match.js.map +1 -0
  100. package/esm/array/array_plus.find.d.ts +57 -0
  101. package/esm/array/array_plus.find.d.ts.map +1 -0
  102. package/esm/array/array_plus.find.js +2 -0
  103. package/esm/array/array_plus.find.js.map +1 -0
  104. package/esm/array/array_plus.split_at.d.ts +20 -15
  105. package/esm/array/array_plus.split_at.d.ts.map +1 -1
  106. package/esm/array/find_first.d.ts +62 -0
  107. package/esm/array/find_first.d.ts.map +1 -0
  108. package/esm/array/find_first.js +2 -0
  109. package/esm/array/find_first.js.map +1 -0
  110. package/esm/array/head.d.ts +18 -6
  111. package/esm/array/head.d.ts.map +1 -1
  112. package/esm/array/last.d.ts +17 -6
  113. package/esm/array/last.d.ts.map +1 -1
  114. package/esm/assertion/assert_type.d.ts +4 -1
  115. package/esm/assertion/assert_type.d.ts.map +1 -1
  116. package/esm/assertion/assert_type.js.map +1 -1
  117. package/esm/index.d.ts +5 -2
  118. package/esm/index.d.ts.map +1 -1
  119. package/esm/index.js.map +1 -1
  120. package/esm/never/never_type.d.ts +11 -0
  121. package/esm/never/never_type.d.ts.map +1 -1
  122. package/esm/object/index.d.ts +0 -1
  123. package/esm/object/index.d.ts.map +1 -1
  124. package/esm/object/index.js.map +1 -1
  125. package/esm/testing/test_type.d.ts +277 -276
  126. package/esm/testing/test_type.d.ts.map +1 -1
  127. package/esm/testing/test_type.js.map +1 -1
  128. package/esm/tuple/common_prop_keys.d.ts +15 -10
  129. package/esm/tuple/common_prop_keys.d.ts.map +1 -1
  130. package/esm/tuple/drop.d.ts +45 -26
  131. package/esm/tuple/drop.d.ts.map +1 -1
  132. package/esm/tuple/drop.js.map +1 -1
  133. package/esm/tuple/tuple_plus.common_prop_keys.d.ts +28 -0
  134. package/esm/tuple/tuple_plus.common_prop_keys.d.ts.map +1 -0
  135. package/esm/tuple/tuple_plus.common_prop_keys.js +2 -0
  136. package/esm/tuple/tuple_plus.common_prop_keys.js.map +1 -0
  137. package/esm/tuple/tuple_plus.d.ts +3 -0
  138. package/esm/tuple/tuple_plus.d.ts.map +1 -1
  139. package/esm/tuple/tuple_plus.drop_match.d.ts +6 -0
  140. package/esm/tuple/tuple_plus.drop_match.d.ts.map +1 -0
  141. package/esm/tuple/tuple_plus.drop_match.js +2 -0
  142. package/esm/tuple/tuple_plus.drop_match.js.map +1 -0
  143. package/esm/tuple/tuple_plus.filter.d.ts +2 -2
  144. package/esm/tuple/tuple_plus.find.d.ts +64 -0
  145. package/esm/tuple/tuple_plus.find.d.ts.map +1 -0
  146. package/esm/tuple/tuple_plus.find.js +2 -0
  147. package/esm/tuple/tuple_plus.find.js.map +1 -0
  148. package/esm/tuple/tuple_plus.pad_start.d.ts +7 -6
  149. package/esm/tuple/tuple_plus.pad_start.d.ts.map +1 -1
  150. package/esm/tuple/tuple_type.d.ts +41 -23
  151. package/esm/tuple/tuple_type.d.ts.map +1 -1
  152. package/esm/union/union.d.ts +33 -0
  153. package/esm/union/union.d.ts.map +1 -0
  154. package/esm/union/union.js +2 -0
  155. package/esm/union/union.js.map +1 -0
  156. package/esm/unknown/unknown_type.d.ts +12 -0
  157. package/esm/unknown/unknown_type.d.ts.map +1 -1
  158. package/esm/utils/options.d.ts +10 -0
  159. package/esm/utils/options.d.ts.map +1 -0
  160. package/esm/utils/options.js +2 -0
  161. package/esm/utils/options.js.map +1 -0
  162. package/package.json +12 -1
  163. package/ts/array/array.entries.ts +4 -2
  164. package/ts/array/array_index.ts +33 -23
  165. package/ts/array/array_plus.common_prop_keys.ts +35 -0
  166. package/ts/array/array_plus.drop_match.ts +16 -0
  167. package/ts/array/array_plus.element_match.ts +61 -0
  168. package/ts/array/array_plus.find.ts +71 -0
  169. package/ts/array/array_plus.split_at.ts +52 -23
  170. package/ts/array/array_plus.ts +6 -3
  171. package/ts/array/find_first.ts +71 -0
  172. package/ts/array/head.ts +28 -6
  173. package/ts/array/last.ts +26 -6
  174. package/ts/array/readme.md +152 -32
  175. package/ts/assertion/assert_type.ts +4 -1
  176. package/ts/assertion/readme.md +3 -2
  177. package/ts/index.ts +5 -5
  178. package/ts/never/never_type.ts +13 -0
  179. package/ts/object/index.ts +0 -1
  180. package/ts/testing/test_type.ts +279 -277
  181. package/ts/tuple/common_prop_keys.ts +18 -32
  182. package/ts/tuple/drop.ts +61 -60
  183. package/ts/tuple/readme.md +178 -39
  184. package/ts/tuple/tuple_plus.common_prop_keys.ts +47 -0
  185. package/ts/tuple/tuple_plus.drop_match.ts +20 -0
  186. package/ts/tuple/tuple_plus.filter.ts +2 -2
  187. package/ts/tuple/tuple_plus.find.ts +88 -0
  188. package/ts/tuple/tuple_plus.pad_start.ts +28 -25
  189. package/ts/tuple/tuple_plus.ts +3 -0
  190. package/ts/tuple/tuple_type.ts +67 -25
  191. package/ts/union/readme.md +81 -0
  192. package/ts/union/union.ts +37 -0
  193. package/ts/unknown/unknown_type.ts +13 -0
  194. package/ts/utils/options.ts +10 -0
  195. package/cjs/array/array.find.d.ts +0 -23
  196. package/cjs/array/array.find.d.ts.map +0 -1
  197. package/cjs/array/array.find.js.map +0 -1
  198. package/esm/array/array.find.d.ts +0 -23
  199. package/esm/array/array.find.d.ts.map +0 -1
  200. package/esm/array/array.find.js +0 -2
  201. package/esm/array/array.find.js.map +0 -1
  202. package/ts/array/array.find.ts +0 -34
package/README.md CHANGED
@@ -22,21 +22,22 @@ More than 200 type utilities for [TypeScript] for applications, library, and typ
22
22
  5. [Type Specific Utilities](#type-specific-utilities)
23
23
  1. [any](#any)
24
24
  2. [Array](#array)
25
- 3. [bigint](#bigint)
26
- 4. [boolean](#boolean)
27
- 5. [function](#function)
28
- 6. [never](#never)
29
- 7. [null](#null)
30
- 8. [number](#number)
31
- 9. [numeric](#numeric)
32
- 10. [object](#object)
33
- 11. [Promise](#promise)
34
- 12. [string](#string)
35
- 13. [symbol](#symbol)
36
- 14. [tuple](#tuple)
37
- 15. [undefined](#undefined)
38
- 16. [unknown](#unknown)
39
- 17. [void](#void)
25
+ 3. [union](#union)
26
+ 4. [bigint](#bigint)
27
+ 5. [boolean](#boolean)
28
+ 6. [function](#function)
29
+ 7. [never](#never)
30
+ 8. [null](#null)
31
+ 9. [number](#number)
32
+ 10. [numeric](#numeric)
33
+ 11. [object](#object)
34
+ 12. [Promise](#promise)
35
+ 13. [string](#string)
36
+ 14. [symbol](#symbol)
37
+ 15. [tuple](#tuple)
38
+ 16. [undefined](#undefined)
39
+ 17. [unknown](#unknown)
40
+ 18. [void](#void)
40
41
  6. [Constant Types](#constant-types)
41
42
  7. [JSON Support](#json-support)
42
43
  8. [Type manipulation](#type-manipulation)
@@ -92,18 +93,20 @@ Each type and utility function in [type-plus] will be updated to include example
92
93
 
93
94
  Each tag has an associated icon:
94
95
 
95
- - 👽 *alias* (:alien:): Alias of another type
96
- - 🚦 *assertion* (:vertical_traffic_light:): assertion function
97
- - 💀 *deprecated* (:skull:): deprecated and will be removed soon
98
- - 🌪️ *filter* (:tornado:): a.k.a. *parse* These types perform some kind of test. If the input passes the test, the input is returned. Otherwise, it returns `never` (other icons considered: ↪️👉🚋⏩🐾🔑🚪💂🧲🙅‍♂️🪚)
99
- - 🛡️ *guard* (:shield:): type guard function
100
- - 💥 *immediate* (:boom:): The effect of the type can be observed immediately during development
101
- - 🏃 *runtime* (:runner:): The function has runtime effect
102
- - 🩳 *shortcut* (:shorts:): Shortcut or convenient types
103
- - 🧪 *testing* (:test_tube:): The type or function are designed for test
104
- - ⚗️ *transform* (:alembic:): These types transforms the input to another category
105
- - 🦴 *utilities* (:bone:): provide various functionalities (other icons considered: 🔧🔨)
106
- - 🎭 *validate* (:performing_arts:): a.k.a. *predicate* or *logical*. These types perform some kind of test. If the input passes the test, it returns `true` or `false` (other icons considered: ⭕)
96
+ - 👽 *alias*: Alias of another type
97
+ - 🚦 *assertion*: assertion function
98
+ - 🔢 *customizable*: the behavior of the type is customizable.
99
+ - 💀 *deprecated*: deprecated and will be removed soon
100
+ - 🌪️ *filter*: a.k.a. *parse* These types perform some kind of test. If the input passes the test, the input is returned. Otherwise, it returns `never`
101
+ - 🛡️ *guard*: type guard function
102
+ - 💥 *immediate*: the effect of the type can be observed immediately during development
103
+ - ㊙️ *internal*: the type is internal and should not be used directly
104
+ - 🏃 *runtime*: the function has runtime effect
105
+ - 🩳 *shortcut*: Shortcut or convenient types
106
+ - 🧪 *testing*: the type or function are designed for test
107
+ - ⚗️ *transform*: these types transforms the input to another category
108
+ - 🦴 *utilities*: provide various functionalities
109
+ - 🎭 *validate*: a.k.a. *predicate* or *logical*. These types perform some kind of test. If the input passes the test, it returns `true` or `false`
107
110
 
108
111
  ## Assertion Function
109
112
 
@@ -377,45 +380,50 @@ You can learn more in their respective sections:
377
380
 
378
381
  ### [any](./ts/any/readme.md)
379
382
 
380
- - [`AnyType<T>`](./ts/any/readme.md#anytype)
381
- - [`IsAny<T>`](./ts/any/readme.md#isany)
382
- - [`NotAnyType<T>`](./ts/any/readme.md#notanytype)
383
- - [`IsNotAny<T>`](./ts/any/readme.md#isnotany)
384
- - [`AnyOrNeverType<T>`](./ts/mix_types/readme.md#anyornevertype)
385
- - [`IsAnyOrNever<T>`](./ts/mix_types/readme.md#isanyornever)
386
-
387
- ### Array
388
-
389
- - [`ArrayType<T>`](./ts/array/readme.md#arraytype)
390
- - [`IsArray<T>`](./ts/array/readme.md#isarray)
391
- - [`NotArrayType<T>`](./ts/array/readme.md#notarraytype)
392
- - [`IsNotArrayType<T>`](./ts/array/readme.md#isnotarraytype)
393
- - [`At<T>`](./ts/array/readme.md#at)
394
- - [`Concat<T>`](./ts/array/readme.md#concat)
395
- - [`FindFirst<T>`](./ts/array/readme.md#findfirst)
396
- - [`FindLast<T>`](./ts/array/readme.md#findlast)
397
- - [`Some<T>`](./ts/array/readme.md#some)
398
- - [`Filter<T>`](./ts/array/readme.md#filter)
399
- - [`KeepMatch<T>`](./ts/array/readme.md#keepmatch)
400
- - [`Head<T>`](./ts/array/readme.md#head)
401
- - [`IntersectOfProps<T>`](./ts/array/readme.md#intersectofprops)
402
- - [`MapToProp<T>`](./ts/array/readme.md#maptoprop)
403
- - [`Last<T>`](./ts/array/readme.md#last)
404
- - [`literalArray<T>`](./ts/array/readme.md#literalarray)
405
- - [`PadStart<T>`](./ts/array/readme.md#padstart)
383
+ - [`AnyType`](./ts/any/readme.md#anytype)
384
+ - [`IsAny`](./ts/any/readme.md#isany)
385
+ - [`NotAnyType`](./ts/any/readme.md#notanytype)
386
+ - [`IsNotAny`](./ts/any/readme.md#isnotany)
387
+ - [`AnyOrNeverType`](./ts/mix_types/readme.md#anyornevertype)
388
+ - [`IsAnyOrNever`](./ts/mix_types/readme.md#isanyornever)
389
+
390
+ ### [Array](./ts/array/readme.md)
391
+
392
+ - 🌪️[`ArrayType`](./ts/array/readme.md#arraytype): Filter `T` to ensure it is an array, excluding tuple.
393
+ - 🎭[`IsArray`](./ts/array/readme.md#isarray): Validate that `T` is an array, excluding tuple.
394
+ - 🌪️[`NotArrayType`](./ts/array/readme.md#notarraytype): Filter `T` to ensure it is not an array, excluding tuple.
395
+ - 🎭[`IsNotArrayType`](./ts/array/readme.md#isnotarraytype): Validate that `T` is not an array, excluding tuple.
396
+ - 🦴[`At`](./ts/array/readme.md#at): Gets the type of the array or tuple at positive or negative index `N`.
397
+ - 🦴💀[`Concat`](./ts/array/readme.md#concat): Concats two arrays or tuples.
398
+ - 🦴🔢[`FindFirst`](./ts/array/readme.md#findfirst): Find the first type in the array or tuple `A` that matches `Criteria`.
399
+ - [`FindLast`](./ts/array/readme.md#findlast)
400
+ - [`Some`](./ts/array/readme.md#some)
401
+ - ⚗️[`Filter`](./ts/array/readme.md#filter): Filter the array or tuple `A`, keeping entries satisfying `Criteria`.
402
+ - ⚗️👽[`KeepMatch`](./ts/array/readme.md#keepmatch): Keeps entries satisfying `Criteria` in array or tuple `A`.
403
+ - 🦴🔢[`Head`](./ts/array/readme.md#head): Gets the first entry in the tuple or the type of array `T`.
404
+ - [`IntersectOfProps`](./ts/array/readme.md#intersectofprops)
405
+ - [`MapToProp`](./ts/array/readme.md#maptoprop)
406
+ - 🦴🔢[`Last`](./ts/array/readme.md#last): Gets the last entry in the tuple or the type of array `T`.
407
+ - [`literalArray`](./ts/array/readme.md#literalarray)
408
+ - [`PadStart`](./ts/array/readme.md#padstart)
406
409
  - [`reduceWhile`](./ts/array/readme.md#reducewhile)
407
- - [`Reverse<T>`](./ts/array/readme.md#reverse)
408
- - [`PropUnion<T>`](./ts/array/readme.md#propunion)
409
- - [`UnionOfProps<T>`](./ts/array/readme.md#unionofprops)
410
- - [`UnionOfValues<T>`](./ts/array/readme.md#unionofvalues)
411
- - [`ArrayPlus.At<T>`](./ts/array/readme.md#arrayplusat)
412
- - [`ArrayPlus.Concat<T>`](./ts/array/readme.md#arrayplusconcat)
413
- - [`ArrayPlus.Entries<T>`](./ts/array/readme.md#arrayplusentries)
414
- - [`ArrayPlus.Find<T>`](./ts/array/readme.md#arrayplusfind)
415
- - [`ArrayPlus.FindLast<T>`](./ts/array/readme.md#arrayplusfindlast)
416
- - [`ArrayPlus.Reverse<T>`](./ts/array/readme.md#arrayplusreverse)
417
- - [`ArrayPlus.SplitAt<T>`](./ts/array/readme.md#arrayplussplitat)
418
- - [`ArrayPlus.Some<T>`](./ts/array/readme.md#arrayplussome)
410
+ - [`Reverse`](./ts/array/readme.md#reverse)
411
+ - [`PropUnion`](./ts/array/readme.md#propunion)
412
+ - [`UnionOfProps`](./ts/array/readme.md#unionofprops)
413
+ - [`UnionOfValues`](./ts/array/readme.md#unionofvalues)
414
+ - [`ArrayPlus.At`](./ts/array/readme.md#arrayplusat)
415
+ - [`ArrayPlus.Concat`](./ts/array/readme.md#arrayplusconcat)
416
+ - [`ArrayPlus.Entries`](./ts/array/readme.md#arrayplusentries)
417
+ - 🦴🔢[`ArrayPlus.Find`](./ts/array/readme.md#arrayplusfind): Finds the type in array `A` that matches `Criteria`.
418
+ - [`ArrayPlus.FindLast`](./ts/array/readme.md#arrayplusfindlast)
419
+ - [`ArrayPlus.Reverse`](./ts/array/readme.md#arrayplusreverse)
420
+ - [`ArrayPlus.SplitAt`](./ts/array/readme.md#arrayplussplitat)
421
+ - [`ArrayPlus.Some`](./ts/array/readme.md#arrayplussome)
422
+
423
+ ### [union](./ts/union/readme.md)
424
+
425
+ - [`IsUnion`](./ts/union//readme.md#isunion)
426
+ - [`UnionType`](./ts/union/readme.md#uniontype)
419
427
 
420
428
  ### bigint
421
429
 
@@ -757,25 +765,14 @@ You can learn more in their respective sections:
757
765
 
758
766
  ### tuple
759
767
 
760
- > [`TupleType<T>`](ts/tuple/readme.md#type-checking)
761
-
762
- ↪️ `parse`: is a tuple.
763
-
764
- > [`IsTuple<T>`](ts/tuple/readme.md#type-checking)
765
-
766
- `predicate`: is a tuple.
767
-
768
- > [`NotTupleType<T>`](ts/tuple/readme.md#type-checking)
769
-
770
- ↪️ `parse`: is not a tuple.
771
-
772
- > [`IsNotTuple<T>`](ts/tuple/readme.md#type-checking)
773
-
774
- ⭕ `predicate`: is not a tuple.
775
-
776
- > `CommonPropKeys<A>`
777
-
778
- 🔨 `utilities`: gets common keys inside the records in the array `A` (deprecate `CommonKeys`).
768
+ - 🌪️ [`TupleType`](./ts/tuple/readme.md#tupletype): Filter `T` to ensure it is a tuple, excluding array.
769
+ - 🎭 [`IsTuple`](./ts/tuple/readme.md#istuple): Validate that `T` is a tuple, excluding array.
770
+ - 🌪️ [`NotTupleType`](./ts/tuple/readme.md#nottupletype): Filter `T` to ensure it is not an tuple, excluding array.
771
+ - 🎭 [`IsNotTuple`](./ts/tuple/readme.md#isnottupletype): Validate that `T` is not an tuple, excluding array.
772
+ - ⚗️🔢[`CommonPropKeys`](./ts/tuple/readme.md#commonpropkeys): Gets the common property keys of the elements in tuple `T`.
773
+ - ⚗️💀`CommonKeys`: Deprecated. Please use `CommonPropKeys` instead.
774
+ - ⚗️🔢[`DropFirst`](./ts/tuple/readme.md#dropfirst): Drops the first entry in the tuple`T`.
775
+ - ⚗️🔢[`DropLast`](./ts/tuple/readme.md#droplast): Drops the last entry in the tuple`T`.
779
776
 
780
777
  > `CreateTuple<L, T>`
781
778
 
@@ -785,14 +782,6 @@ You can learn more in their respective sections:
785
782
 
786
783
  🔨 `utilities`: drop a particular value from an array.
787
784
 
788
- > `DropFirst<A>`
789
-
790
- 🔨 `utilities`: drops the first value type of `A`.
791
-
792
- > `DropLast<A>`
793
-
794
- 🔨 `utilities`: drops the last value type of `A`.
795
-
796
785
  > `DropMatch<A, Criteria>`
797
786
 
798
787
  🔨 `utilities`: drops entries matching `Criteria` in array or tuple `A`.
@@ -11,7 +11,8 @@ import type { IsTuple } from '../tuple/tuple_type.js';
11
11
  * ArrayPlus.Entries<[1, 2, 3]> // [[0, 1], [1, 2], [2, 3]]
12
12
  * ```
13
13
  */
14
- export type Entries<A extends unknown[]> = IsTuple<A, Device<A, []>, A extends Array<infer T> ? Array<[number, T]> : never>;
15
- type Device<A extends unknown[], R extends unknown[]> = A['length'] extends 0 ? R : A extends [...infer F, infer N] ? Device<F, [[F['length'], N], ...R]> : never;
16
- export {};
14
+ export type Entries<A extends unknown[]> = IsTuple<A, Entries.Device<A, []>, A extends Array<infer T> ? Array<[number, T]> : never>;
15
+ export declare namespace Entries {
16
+ type Device<A extends unknown[], R extends unknown[]> = A['length'] extends 0 ? R : A extends [...infer F, infer N] ? Device<F, [[F['length'], N], ...R]> : never;
17
+ }
17
18
  //# sourceMappingURL=array.entries.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"array.entries.d.ts","sourceRoot":"","sources":["../../ts/array/array.entries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AACrD;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,OAAO,EAAE,IAAI,OAAO,CACjD,CAAC,EACD,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,EACb,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,CACrD,CAAA;AAED,KAAK,MAAM,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,CAAC,SAAS,OAAO,EAAE,IAAI,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,GAC1E,CAAC,GACD,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GAC/B,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,GACnC,KAAK,CAAA"}
1
+ {"version":3,"file":"array.entries.d.ts","sourceRoot":"","sources":["../../ts/array/array.entries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AACrD;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,OAAO,EAAE,IAAI,OAAO,CACjD,CAAC,EACD,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,EACrB,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,CACrD,CAAA;AAED,yBAAiB,OAAO,CAAC;IACxB,KAAY,MAAM,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,CAAC,SAAS,OAAO,EAAE,IAAI,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,GAClF,CAAC,GACD,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GAC/B,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,GACnC,KAAK,CAAA;CACP"}
@@ -18,7 +18,10 @@ import type { Negative } from '../numeric/negative.js';
18
18
  * type R = IndexAt<['a', 'b', 'c'], -4> // never
19
19
  * ```
20
20
  */
21
- export type IndexAt<A extends Array<unknown>, N extends number, Fail = never, Upper = A['length'], Lower = 0> = IsEqual<A['length'], 0, Fail, Integer<N, StrictNumberType<A['length'], N, Negative<N, GreaterThan<Abs<N>, A['length']> extends true ? Lower : Subtract<A['length'], Abs<N>>, GreaterThan<A['length'], N> extends true ? N : Upper>>, IsAny<N, number, StrictNumberType<N, N>>>>;
21
+ export type IndexAt<A extends Array<unknown>, N extends number, Fail = never, Upper = A['length'], Lower = 0> = IsNever<A, Fail, IndexAt._<A, N, Fail, Upper, Lower>>;
22
+ export declare namespace IndexAt {
23
+ type _<A extends Array<unknown>, N extends number, Fail = never, Upper = A['length'], Lower = 0> = IsEqual<A['length'], 0, Fail, Integer<N, StrictNumberType<A['length'], N, Negative<N, GreaterThan<Abs<N>, A['length']> extends true ? Lower : Subtract<A['length'], Abs<N>>, GreaterThan<A['length'], N> extends true ? N : Upper>>, IsAny<N, number, StrictNumberType<N, N>>>>;
24
+ }
22
25
  /**
23
26
  * Is N an out of bound index of A.
24
27
  *
@@ -1 +1 @@
1
- {"version":3,"file":"array_index.d.ts","sourceRoot":"","sources":["../../ts/array/array_index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAA;AACvE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AAEtD;;;;;;;;;;GAUG;AACH,MAAM,MAAM,OAAO,CAClB,CAAC,SAAS,KAAK,CAAC,OAAO,CAAC,EACxB,CAAC,SAAS,MAAM,EAChB,IAAI,GAAG,KAAK,EACZ,KAAK,GAAG,CAAC,CAAC,QAAQ,CAAC,EACnB,KAAK,GAAG,CAAC,IACN,OAAO,CACV,CAAC,CAAC,QAAQ,CAAC,EACX,CAAC,EACD,IAAI,EACJ,OAAO,CACN,CAAC,EACD,gBAAgB,CACf,CAAC,CAAC,QAAQ,CAAC,EAEX,CAAC,EAED,QAAQ,CACP,CAAC,EACD,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,SAAS,IAAI,GAAG,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,EACrF,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,IAAI,GAAG,CAAC,GAAG,KAAK,CACpD,CACD,EAED,KAAK,CACJ,CAAC,EACD,MAAM,EACN,gBAAgB,CACf,CAAC,EAED,CAAC,CACD,CACD,CACD,CACD,CAAA;AAED;;;;;;;;;;GAUG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,CAAC,SAAS,MAAM,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,KAAK,IAAI,OAAO,CACxG,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,EAClC,IAAI,EACJ,IAAI,CACJ,CAAA"}
1
+ {"version":3,"file":"array_index.d.ts","sourceRoot":"","sources":["../../ts/array/array_index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAA;AACvE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AAEtD;;;;;;;;;;GAUG;AACH,MAAM,MAAM,OAAO,CAClB,CAAC,SAAS,KAAK,CAAC,OAAO,CAAC,EACxB,CAAC,SAAS,MAAM,EAChB,IAAI,GAAG,KAAK,EACZ,KAAK,GAAG,CAAC,CAAC,QAAQ,CAAC,EACnB,KAAK,GAAG,CAAC,IACN,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAA;AAEzD,yBAAiB,OAAO,CAAC;IACxB,KAAY,CAAC,CACZ,CAAC,SAAS,KAAK,CAAC,OAAO,CAAC,EACxB,CAAC,SAAS,MAAM,EAChB,IAAI,GAAG,KAAK,EACZ,KAAK,GAAG,CAAC,CAAC,QAAQ,CAAC,EACnB,KAAK,GAAG,CAAC,IACN,OAAO,CACV,CAAC,CAAC,QAAQ,CAAC,EACX,CAAC,EACD,IAAI,EACJ,OAAO,CACN,CAAC,EACD,gBAAgB,CACf,CAAC,CAAC,QAAQ,CAAC,EAEX,CAAC,EAED,QAAQ,CACP,CAAC,EACD,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,SAAS,IAAI,GAAG,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,EACrF,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,IAAI,GAAG,CAAC,GAAG,KAAK,CACpD,CACD,EAED,KAAK,CACJ,CAAC,EACD,MAAM,EACN,gBAAgB,CACf,CAAC,EAED,CAAC,CACD,CACD,CACD,CACD,CAAA;CACD;AAED;;;;;;;;;;GAUG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,CAAC,SAAS,MAAM,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,KAAK,IAAI,OAAO,CACxG,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,EAClC,IAAI,EACJ,IAAI,CACJ,CAAA"}
@@ -0,0 +1,27 @@
1
+ import type { NeverType } from '../never/never_type.js';
2
+ import type { KeyTypes } from '../object/KeyTypes.js';
3
+ /**
4
+ * ⚗️ *transform*
5
+ * 🔢 *customization*
6
+ *
7
+ * Gets the common keys of the record types in the array `A`.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * import { type ArrayPlus } from 'type-plus'
12
+ *
13
+ * type R = ArrayPlus.CommonPropKeys<Array<{ a: 1 }>> // 'a'
14
+ * type R = ArrayPlus.CommonPropKeys<Array<{ a: 1, b: 1 } | { a: 1, c: 1 }>> // 'a'
15
+ * ```
16
+ *
17
+ * @typeParam Options['caseNever'] Return type when `T` is `never`.
18
+ * Default to `never`.
19
+ */
20
+ export type CommonPropKeys<A extends Record<KeyTypes, unknown>[], Options extends CommonPropKeys.Options = CommonPropKeys.DefaultOptions> = NeverType<A, Options['caseNever'], A extends Array<infer R extends Record<KeyTypes, unknown>> ? keyof R : never>;
21
+ export declare namespace CommonPropKeys {
22
+ interface Options extends NeverType.Options {
23
+ }
24
+ interface DefaultOptions extends NeverType.DefaultOptions {
25
+ }
26
+ }
27
+ //# sourceMappingURL=array_plus.common_prop_keys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array_plus.common_prop_keys.d.ts","sourceRoot":"","sources":["../../ts/array/array_plus.common_prop_keys.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAErD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,cAAc,CACzB,CAAC,SAAS,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAE,EACrC,OAAO,SAAS,cAAc,CAAC,OAAO,GAAG,cAAc,CAAC,cAAc,IACnE,SAAS,CAAC,CAAC,EACd,OAAO,CAAC,WAAW,CAAC,EACpB,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,SAAS,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,KAAK,CAC5E,CAAA;AAED,yBAAiB,cAAc,CAAC;IAC/B,UAAiB,OAAQ,SAAQ,SAAS,CAAC,OAAO;KACjD;IAED,UAAiB,cAAe,SAAQ,SAAS,CAAC,cAAc;KAC/D;CACD"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=array_plus.common_prop_keys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array_plus.common_prop_keys.js","sourceRoot":"","sources":["../../ts/array/array_plus.common_prop_keys.ts"],"names":[],"mappings":""}
@@ -1,12 +1,15 @@
1
1
  export type { At } from './array.at.js';
2
- export type { Concat } from './array_plus.concat.js';
3
2
  export type { Entries } from './array.entries.js';
4
- export type { FindFirst as Find } from './array.find.js';
5
3
  export type { FindLast } from './array.find_last.js';
6
4
  export type { Reverse } from './array.reverse.js';
7
5
  export type { Some } from './array.some.js';
8
6
  export type { IndexAt, IsIndexOutOfBound } from './array_index.js';
7
+ export type { CommonPropKeys } from './array_plus.common_prop_keys.js';
8
+ export type { Concat } from './array_plus.concat.js';
9
+ export type { DropMatch } from './array_plus.drop_match.js';
10
+ export type { ElementMatch } from './array_plus.element_match.js';
9
11
  export type { Filter } from './array_plus.filter.js';
10
- export type { SplitAt } from './array_plus.split_at.js';
12
+ export type { Find } from './array_plus.find.js';
11
13
  export type { PadStart } from './array_plus.pad_start.js';
14
+ export type { SplitAt } from './array_plus.split_at.js';
12
15
  //# sourceMappingURL=array_plus.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"array_plus.d.ts","sourceRoot":"","sources":["../../ts/array/array_plus.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,EAAE,EAAE,MAAM,eAAe,CAAA;AACvC,YAAY,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AACpD,YAAY,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AACjD,YAAY,EAAE,SAAS,IAAI,IAAI,EAAE,MAAM,iBAAiB,CAAA;AACxD,YAAY,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AACpD,YAAY,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AACjD,YAAY,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAC3C,YAAY,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAClE,YAAY,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AACpD,YAAY,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AACvD,YAAY,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAA"}
1
+ {"version":3,"file":"array_plus.d.ts","sourceRoot":"","sources":["../../ts/array/array_plus.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,EAAE,EAAE,MAAM,eAAe,CAAA;AACvC,YAAY,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AACjD,YAAY,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AACpD,YAAY,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AACjD,YAAY,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAC3C,YAAY,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAClE,YAAY,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAA;AACtE,YAAY,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AACpD,YAAY,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AAC3D,YAAY,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AACjE,YAAY,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AACpD,YAAY,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAChD,YAAY,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAA;AACzD,YAAY,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA"}
@@ -0,0 +1,4 @@
1
+ import type { NonNull } from '../utils/NonNull.js';
2
+ import type { NonUndefined } from '../utils/NonUndefined.js';
3
+ export type DropMatch<A extends Readonly<Array<unknown>>, Criteria> = A[0] extends Criteria ? never[] : (undefined extends Criteria ? (null extends Criteria ? Array<NonNullable<A[0]>> : Array<NonUndefined<A[0]>>) : (null extends Criteria ? Array<NonNull<A[0]>> : (Criteria extends A[0] ? Array<Exclude<A[0], Criteria>> : (A[0] extends Criteria ? A : Array<Exclude<A[0], Criteria>>))));
4
+ //# sourceMappingURL=array_plus.drop_match.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array_plus.drop_match.d.ts","sourceRoot":"","sources":["../../ts/array/array_plus.drop_match.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAE5D,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,QAAQ,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,QAAQ,GACxF,KAAK,EAAE,GACP,CAAC,SAAS,SAAS,QAAQ,GAC1B,CAAC,IAAI,SAAS,QAAQ,GACrB,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GACxB,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAC3B,CAAC,IAAI,SAAS,QAAQ,GACrB,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GACpB,CAAC,QAAQ,SAAS,CAAC,CAAC,CAAC,CAAC,GACrB,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,GAC9B,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,QAAQ,GACrB,CAAC,GACD,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=array_plus.drop_match.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array_plus.drop_match.js","sourceRoot":"","sources":["../../ts/array/array_plus.drop_match.ts"],"names":[],"mappings":""}
@@ -0,0 +1,44 @@
1
+ import type { IsNever } from '../never/never_type.js';
2
+ import type { IsUnion } from '../union/union.js';
3
+ import type { MergeOptions } from '../utils/options.js';
4
+ /**
5
+ * 🦴 *utilities*
6
+ * 🔢 *customizable*
7
+ *
8
+ * Filter the element `T` in an array or tuple to match `Criteria`.
9
+ *
10
+ * @typeParam Options['widen'] Allow using narrow type to match widen type.
11
+ * e.g. `number, 1` -> `1 | undefined`.
12
+ * Default to `true`.
13
+ *
14
+ * @typeParam Options['caseNotMatch'] Return value when `T` does not match `Criteria`.
15
+ * Default to `never`.
16
+ *
17
+ * @typeParam Options['caseWiden'] Return value when `widen` is true.
18
+ * Default to `Criteria | undefined`.
19
+ *
20
+ * @typeParam Options['caseUnionNotMatch'] Return value when a branch of the union `T` does not match `Criteria`.
21
+ * Default to `never`.
22
+ *
23
+ * If you want the type to behave more like JavaScript,
24
+ * you can override it to return `undefined`.
25
+ *
26
+ * Since it is a union, the result will be joined to the matched branch as union.
27
+ * e.g. `ElementMatch<1 | 2, 1>` -> `1 | undefined`
28
+ */
29
+ export type ElementMatch<T, Criteria, Options extends ElementMatch.Options = ElementMatch.DefaultOptions<Criteria>> = [T] extends [Criteria] ? T : (MergeOptions<Options, ElementMatch.DefaultOptions<Criteria>> extends infer C extends Record<keyof ElementMatch.Options, unknown> ? ((T extends Criteria ? T : (C['widen'] extends true ? (Criteria extends T ? C['caseWiden'] : C['caseNotMatch']) : C['caseNotMatch'])) extends infer R ? IsUnion<T, IsNever<R, R, R | C['caseUnionNotMatch']>, R> : C['caseNotMatch']) : never);
30
+ export declare namespace ElementMatch {
31
+ interface Options {
32
+ widen?: boolean | undefined;
33
+ caseNotMatch?: unknown;
34
+ caseWiden?: unknown;
35
+ caseUnionNotMatch?: unknown;
36
+ }
37
+ interface DefaultOptions<Criteria> {
38
+ widen: true;
39
+ caseNotMatch: never;
40
+ caseWiden: Criteria | undefined;
41
+ caseUnionNotMatch: never;
42
+ }
43
+ }
44
+ //# sourceMappingURL=array_plus.element_match.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array_plus.element_match.d.ts","sourceRoot":"","sources":["../../ts/array/array_plus.element_match.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,MAAM,YAAY,CACvB,CAAC,EACD,QAAQ,EACR,OAAO,SAAS,YAAY,CAAC,OAAO,GAAG,YAAY,CAAC,cAAc,CAAC,QAAQ,CAAC,IACzE,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,GACvB,CAAC,GACD,CAAC,YAAY,CAAC,OAAO,EAAE,YAAY,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,SAAS,MAAM,CAAC,SAAS,MAAM,CAAC,MAAM,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,GAChI,CAAC,CAAC,CAAC,SAAS,QAAQ,GACnB,CAAC,GACD,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,IAAI,GACvB,CAAC,QAAQ,SAAS,CAAC,GAClB,CAAC,CAAC,WAAW,CAAC,GACd,CAAC,CAAC,cAAc,CAAC,CAAC,GACnB,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,MAAM,CAAC,GACpC,OAAO,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC,GACxD,CAAC,CAAC,cAAc,CAAC,CAAC,GACnB,KAAK,CAAC,CAAA;AAEV,yBAAiB,YAAY,CAAC;IAC7B,UAAiB,OAAO;QACvB,KAAK,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;QAC5B,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,iBAAiB,CAAC,EAAE,OAAO,CAAA;KAC3B;IACD,UAAiB,cAAc,CAAC,QAAQ;QACvC,KAAK,EAAE,IAAI,CAAC;QACZ,YAAY,EAAE,KAAK,CAAC;QACpB,SAAS,EAAE,QAAQ,GAAG,SAAS,CAAC;QAChC,iBAAiB,EAAE,KAAK,CAAA;KACxB;CACD"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=array_plus.element_match.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array_plus.element_match.js","sourceRoot":"","sources":["../../ts/array/array_plus.element_match.ts"],"names":[],"mappings":""}
@@ -0,0 +1,57 @@
1
+ import type { NeverType } from '../never/never_type.js';
2
+ import type { TupleType } from '../tuple/tuple_type.js';
3
+ import type { MergeOptions } from '../utils/options.js';
4
+ import type { ElementMatch } from './array_plus.element_match.js';
5
+ /**
6
+ * 🦴 *utilities*
7
+ * 🔢 *customizable*
8
+ *
9
+ * Finds the type in array `A` that matches `Criteria`.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * type R = ArrayPlus.Find<Array<string>, string> // string
14
+ * type R = ArrayPlus.Find<Array<1 | 2 | 'x'>, number> // 1 | 2 | undefined
15
+ * type R = ArrayPlus.Find<Array<string | number>, number | string> // string | number
16
+ * type R = ArrayPlus.Find<Array<number>, 1> // widen: 1 | undefined
17
+ * type R = ArrayPlus.Find<Array<string | number>, number> // unionMiss: number | undefined
18
+ *
19
+ * type R = ArrayPlus.Find<string[], number> // never
20
+ * ```
21
+ *
22
+ * @typeParam Options['widen'] performs widen match.
23
+ * Default to `true`.
24
+ * With widen match, a narrowed type will match its widen type.
25
+ * e.g. matching `1` against `number` yields `1 | undefined`
26
+ *
27
+ * The widen behavior can be customized by `Options['caseWiden']`
28
+ *
29
+ * @typeParam Options['caseNever'] return type when `A` is `never`. Default to `never`.
30
+ *
31
+ * @typeParam Options['caseNotMatch'] Return value when `T` does not match `Criteria`.
32
+ * Default to `never`.
33
+ *
34
+ * @typeParam Options['caseTuple'] return type when `A` is a tuple. Default to `not supported` message.
35
+ *
36
+ * @typeParam Options['caseWiden'] return type when `T` in `A` is a widen type of `Criteria`.
37
+ * Default to `Criteria | undefined`.
38
+ * Set it to `never` for a more type-centric behavior
39
+ *
40
+ * @typeParam Options['caseUnionNotMatch'] Return value when a branch of the union `T` does not match `Criteria`.
41
+ * Default to `never`.
42
+ *
43
+ * If you want the type to behave more like JavaScript,
44
+ * you can override it to return `undefined`.
45
+ *
46
+ * Since it is a union, the result will be joined to the matched branch as union.
47
+ */
48
+ export type Find<A extends unknown[], Criteria, Options extends Find.Options = Find.DefaultOptions<Criteria>> = MergeOptions<Options, Find.DefaultOptions<Criteria>> extends infer O extends Find.Options ? TupleType<A, O['caseTuple'], A extends Array<infer T> ? ElementMatch<T, Criteria, O> : never, O> : never;
49
+ export declare namespace Find {
50
+ interface Options extends ElementMatch.Options, NeverType.Options {
51
+ caseTuple?: unknown;
52
+ }
53
+ interface DefaultOptions<Criteria> extends ElementMatch.DefaultOptions<Criteria>, NeverType.DefaultOptions {
54
+ caseTuple: 'does not support tuple. Please use `FindFirst` or `TuplePlus.Find` instead.';
55
+ }
56
+ }
57
+ //# sourceMappingURL=array_plus.find.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array_plus.find.d.ts","sourceRoot":"","sources":["../../ts/array/array_plus.find.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAEjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,MAAM,MAAM,IAAI,CACf,CAAC,SAAS,OAAO,EAAE,EACnB,QAAQ,EACR,OAAO,SAAS,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,IAE5D,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,SAAS,MAAM,CAAC,SAAS,IAAI,CAAC,OAAO,GACvF,SAAS,CACV,CAAC,EACD,CAAC,CAAC,WAAW,CAAC,EACd,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,GAAG,KAAK,EAC/D,CAAC,CACD,GACC,KAAK,CAAA;AAER,yBAAiB,IAAI,CAAC;IACrB,UAAiB,OAAQ,SAAQ,YAAY,CAAC,OAAO,EAAE,SAAS,CAAC,OAAO;QACvE,SAAS,CAAC,EAAE,OAAO,CAAC;KACpB;IAED,UAAiB,cAAc,CAAC,QAAQ,CAAE,SAAQ,YAAY,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC,cAAc;QAChH,SAAS,EAAE,6EAA6E,CAAC;KACzF;CACD"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=array_plus.find.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array_plus.find.js","sourceRoot":"","sources":["../../ts/array/array_plus.find.ts"],"names":[],"mappings":""}
@@ -1,35 +1,40 @@
1
+ import type { NeverType } from '../never/never_type.js';
2
+ import type { IsTuple } from '../tuple/tuple_type.js';
1
3
  import type { IndexAt } from './array_index.js';
2
4
  import type { ArrayType } from './array_type.js';
3
5
  /**
4
- * Splits an array into two at the specified `Index`.
6
+ * ⚗️ *transform*
7
+ *
8
+ * Splits array or tuple `A` into two at the specified `Index`.
5
9
  *
6
10
  * If the `Index` is out of bounds,
7
- * it will set to the boundary value, similar to `array.splice()`.
11
+ * it will set to the boundary value.
12
+ *
13
+ * It is the type level `splice()`.
8
14
  *
9
15
  * @example
10
16
  * ```ts
11
- * SplitAt<[1, 2, 3, 4, 5], 0> // [[], [1, 2, 3, 4, 5]]
12
- * SplitAt<[1, 2, 3, 4, 5], -5> // [[], [1, 2, 3, 4, 5]]
13
- *
14
17
  * SplitAt<[1, 2, 3, 4, 5], 2> // [[1, 2], [3, 4, 5]]
18
+ * SplitAt<[1, 2, 3, 4, 5], -3> // [[1, 2], [3, 4, 5]]
15
19
  *
16
- * SplitAt<[1, 2, 3, 4, 5], 4> // [[1, 2, 3, 4], [5]]
17
- * SplitAt<[1, 2, 3, 4, 5], -1> // [[1, 2, 3, 4], [5]]
20
+ * SplitAt<[1, 2, 3, 4, 5], 2, 2> // [[1, 2, 5], [3, 4]]
18
21
  *
19
- * SplitAt<[1, 2, 3, 4, 5], 5> // [[1, 2, 3, 4, 5], []]
22
+ * SplitAt<[1, 2, 3, 4, 5], 2, 2, ['a', 'b']> // [[1, 2, 'a', 'b', 5], [3, 4]]
20
23
  *
21
24
  * // out of bound resets to boundary
22
25
  * SplitAt<[1, 2, 3, 4, 5], 6> // [[1, 2, 3, 4, 5], []]
23
26
  * SplitAt<[1, 2, 3, 4, 5], -6> // [[], [1, 2, 3, 4, 5]]
24
27
  * ```
25
28
  */
26
- export type SplitAt<A extends unknown[], Index extends number> = ArrayType<A, [
29
+ export type SplitAt<A extends unknown[], Index extends number, DeleteCount extends number | never = never, Insert extends unknown[] | never = never> = ArrayType<A, [
27
30
  A,
28
31
  A
29
- ], ArraySplitAtDevice<A, [], IndexAt<A, Index>>>;
30
- /**
31
- * Splits an array into two at the specified `Index`.
32
- * The device does not work on negative index nor out of bound index.
33
- */
34
- export type ArraySplitAtDevice<A extends unknown[], B extends unknown[], Index extends number> = Index extends B['length'] ? [B, A] : A extends [infer Head, ...infer Tail] ? ArraySplitAtDevice<Tail, [...B, Head], Index> : never;
32
+ ], SplitAt._<A, [], [], IndexAt._<A, Index>, DeleteCount, Insert>>;
33
+ export declare namespace SplitAt {
34
+ type _<A extends unknown[], B extends unknown[], C extends unknown[], Index extends number, DeleteCount, Insert extends unknown[]> = 0 extends A['length'] ? IsTuple<Insert, [[...Insert, ...B], C], [B, C]> : (Index extends B['length'] ? _D<A, B, C, DeleteCount, Insert> : (A extends [infer Head, ...infer Tail] ? _<Tail, [...B, Head], [], Index, DeleteCount, Insert> : 'unexpected: A does not extends [Head, ...Tail]'));
35
+ type _D<A extends unknown[], B extends unknown[], C extends unknown[], DeleteCount, Insert extends unknown[]> = NeverType<DeleteCount, [
36
+ B,
37
+ A
38
+ ], DeleteCount extends C['length'] ? IsTuple<Insert, [[...B, ...Insert, ...A], C], [[...B, ...A], C]> : (A extends [infer Head, ...infer Tail] ? _D<Tail, B, [...C, Head], DeleteCount, Insert> : IsTuple<Insert, [[...Insert, ...B], C], [B, C]>)>;
39
+ }
35
40
  //# sourceMappingURL=array_plus.split_at.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"array_plus.split_at.d.ts","sourceRoot":"","sources":["../../ts/array/array_plus.split_at.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAEhD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,KAAK,SAAS,MAAM,IAAI,SAAS,CACzE,CAAC,EACD;IAAC,CAAC;IAAE,CAAC;CAAC,EACN,kBAAkB,CAAC,CAAC,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAC5C,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,kBAAkB,CAC7B,CAAC,SAAS,OAAO,EAAE,EACnB,CAAC,SAAS,OAAO,EAAE,EACnB,KAAK,SAAS,MAAM,IACjB,KAAK,SAAS,CAAC,CAAC,QAAQ,CAAC,GAC1B,CAAC,CAAC,EAAE,CAAC,CAAC,GACN,CAAC,SAAS,CAAC,MAAM,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,GACrC,kBAAkB,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,EAAE,KAAK,CAAC,GAC7C,KAAK,CAAA"}
1
+ {"version":3,"file":"array_plus.split_at.d.ts","sourceRoot":"","sources":["../../ts/array/array_plus.split_at.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAEhD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,MAAM,OAAO,CAClB,CAAC,SAAS,OAAO,EAAE,EACnB,KAAK,SAAS,MAAM,EACpB,WAAW,SAAS,MAAM,GAAG,KAAK,GAAG,KAAK,EAC1C,MAAM,SAAS,OAAO,EAAE,GAAG,KAAK,GAAG,KAAK,IACrC,SAAS,CACZ,CAAC,EACD;IAAC,CAAC;IAAE,CAAC;CAAC,EACN,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,CAC9D,CAAA;AAED,yBAAiB,OAAO,CAAC;IACxB,KAAY,CAAC,CACZ,CAAC,SAAS,OAAO,EAAE,EACnB,CAAC,SAAS,OAAO,EAAE,EACnB,CAAC,SAAS,OAAO,EAAE,EACnB,KAAK,SAAS,MAAM,EACpB,WAAW,EACX,MAAM,SAAS,OAAO,EAAE,IACrB,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,GACtB,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAC/C,CAAC,KAAK,SAAS,CAAC,CAAC,QAAQ,CAAC,GACzB,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,GAChC,CAAC,CAAC,SAAS,CAAC,MAAM,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,GACrC,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,CAAC,GACrD,gDAAgD,CAAC,CAAC,CAAA;IAEvD,KAAY,EAAE,CACb,CAAC,SAAS,OAAO,EAAE,EACnB,CAAC,SAAS,OAAO,EAAE,EACnB,CAAC,SAAS,OAAO,EAAE,EACnB,WAAW,EACX,MAAM,SAAS,OAAO,EAAE,IACrB,SAAS,CACZ,WAAW,EACX;QAAC,CAAC;QAAE,CAAC;KAAC,EACN,WAAW,SAAS,CAAC,CAAC,QAAQ,CAAC,GAC7B,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAChE,CAAC,CAAC,SAAS,CAAC,MAAM,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,GACrC,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,GAC9C,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CACjD,CACD,CAAA;CACD"}
@@ -0,0 +1,62 @@
1
+ import type { TupleType } from '../tuple/tuple_type.js';
2
+ import type { Find as TupleFind } from '../tuple/tuple_plus.find.js';
3
+ import type { Find as ArrayFind } from './array_plus.find.js';
4
+ /**
5
+ * 🦴 *utilities*
6
+ * 🔢 *customizable*
7
+ *
8
+ * Find the first type in the array or tuple `A` that matches `Criteria`.
9
+ *
10
+ * If the `Criteria` is not met, it will return `never'.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * type R = FindFirst<[true, 1, 'x', 3], string> // 'x'
15
+ * type R = FindFirst<[true, 1, 'x', 3], number> // 1
16
+ * type R = FindFirst<[string, number, 1], 1> // widen: 1 | undefined
17
+ * type R = FindFirst<[true, number | string], string> // unionMiss: string | undefined
18
+ * type R = FindFirst<Array<string>, string> // string
19
+ * type R = FindFirst<Array<1 | 2 | 'x'>, number> // 1 | 2 | undefined
20
+ * type R = FindFirst<Array<string | number>, number | string> // string | number
21
+ * type R = FindFirst<Array<number>, 1> // widen: 1 | undefined
22
+ * type R = FindFirst<Array<string | number>, number> // unionMiss: number | undefined
23
+ *
24
+ * type R = FindFirst<[true, 1, 'x'], 2> // never
25
+ * type R = FindFirst<string[], number> // never
26
+ * ```
27
+ *
28
+ * @typeParam Options['widen'] performs widen match.
29
+ * Default to `true`.
30
+ * With widen match, a narrowed type will match its widen type.
31
+ * e.g. matching `1` against `number` yields `1 | undefined`
32
+ *
33
+ * The widen behavior can be customized by `Options['caseWiden']`
34
+ *
35
+ * @typeParam Options['caseEmptyTuple'] return type when `A` is an empty tuple.
36
+ * Default to `never`.
37
+ *
38
+ * @typeParam Options['caseNever'] return type when `A` is `never`. Default to `never`.
39
+ *
40
+ * @typeParam Options['caseNoMatch'] Return value when `T` does not match `Criteria`.
41
+ * Default to `never`.
42
+ *
43
+ * @typeParam Options['caseWiden'] return type when `T` in `A` is a widen type of `Criteria`.
44
+ * Default to `Criteria | undefined`.
45
+ * Set it to `never` for a more type-centric behavior
46
+ *
47
+ * @typeParam Options['caseUnionMiss'] Return value when a branch of the union `T` does not match `Criteria`.
48
+ * Default to `undefined`.
49
+ * Since it is a union, the result will be join to the matched branch as union.
50
+ */
51
+ export type FindFirst<A extends unknown[], Criteria, Options extends FindFirst.Options = FindFirst.DefaultOptions<Criteria>> = TupleType<A, TupleFind<A, Criteria, Options>, ArrayFind<A, Criteria, Options>>;
52
+ export declare namespace FindFirst {
53
+ interface Options extends ArrayFind.Options, TupleFind.Options {
54
+ }
55
+ interface DefaultOptions<Criteria> extends ArrayFind.DefaultOptions<Criteria>, TupleFind.DefaultOptions<Criteria> {
56
+ }
57
+ }
58
+ /**
59
+ * @deprecated use FindFirst
60
+ */
61
+ export type First<A extends any[], Criteria> = FindFirst<A, Criteria>;
62
+ //# sourceMappingURL=find_first.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find_first.d.ts","sourceRoot":"","sources":["../../ts/array/find_first.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,KAAK,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,6BAA6B,CAAA;AACpE,OAAO,KAAK,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,MAAM,MAAM,SAAS,CACpB,CAAC,SAAS,OAAO,EAAE,EACnB,QAAQ,EAAE,OAAO,SAAS,SAAS,CAAC,OAAO,GAAG,SAAS,CAAC,cAAc,CAAC,QAAQ,CAAC,IAC7E,SAAS,CACZ,CAAC,EACD,SAAS,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,EAC/B,SAAS,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,CAC/B,CAAA;AAED,yBAAiB,SAAS,CAAC;IAC1B,UAAiB,OAAQ,SAAQ,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC,OAAO;KAAI;IACzE,UAAiB,cAAc,CAAC,QAAQ,CACvC,SAAQ,SAAS,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC,cAAc,CAAC,QAAQ,CAAC;KAAI;CACnF;AAGD;;GAEG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,GAAG,EAAE,EAAE,QAAQ,IAAI,SAAS,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAA"}
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=array.find.js.map
3
+ //# sourceMappingURL=find_first.js.map