type-plus 7.3.1 → 7.5.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 (376) hide show
  1. package/README.md +146 -183
  2. package/cjs/any/any_type.d.ts +8 -8
  3. package/cjs/any/any_type.d.ts.map +1 -1
  4. package/cjs/array/array.at.d.ts +3 -1
  5. package/cjs/array/array.at.d.ts.map +1 -1
  6. package/cjs/array/array.entries.d.ts +4 -3
  7. package/cjs/array/array.entries.d.ts.map +1 -1
  8. package/cjs/array/array.find_last.d.ts +3 -1
  9. package/cjs/array/array.find_last.d.ts.map +1 -1
  10. package/cjs/array/array.some.d.ts +1 -1
  11. package/cjs/array/array.some.d.ts.map +1 -1
  12. package/cjs/array/array_plus.common_prop_keys.d.ts +27 -0
  13. package/cjs/array/array_plus.common_prop_keys.d.ts.map +1 -0
  14. package/cjs/array/array_plus.common_prop_keys.js +3 -0
  15. package/cjs/array/array_plus.common_prop_keys.js.map +1 -0
  16. package/cjs/array/{array.concat.d.ts → array_plus.concat.d.ts} +4 -1
  17. package/cjs/array/array_plus.concat.d.ts.map +1 -0
  18. package/cjs/array/array_plus.concat.js +3 -0
  19. package/cjs/array/array_plus.concat.js.map +1 -0
  20. package/cjs/array/array_plus.d.ts +7 -3
  21. package/cjs/array/array_plus.d.ts.map +1 -1
  22. package/cjs/array/array_plus.drop_match.d.ts +4 -0
  23. package/cjs/array/array_plus.drop_match.d.ts.map +1 -0
  24. package/cjs/array/array_plus.drop_match.js +3 -0
  25. package/cjs/array/array_plus.drop_match.js.map +1 -0
  26. package/cjs/array/array_plus.element_match.d.ts +44 -0
  27. package/cjs/array/array_plus.element_match.d.ts.map +1 -0
  28. package/cjs/array/array_plus.element_match.js +3 -0
  29. package/cjs/array/array_plus.element_match.js.map +1 -0
  30. package/cjs/array/array_plus.filter.d.ts +2 -0
  31. package/cjs/array/array_plus.filter.d.ts.map +1 -0
  32. package/cjs/array/array_plus.filter.js +3 -0
  33. package/cjs/array/array_plus.filter.js.map +1 -0
  34. package/cjs/array/array_plus.find.d.ts +57 -0
  35. package/cjs/array/array_plus.find.d.ts.map +1 -0
  36. package/cjs/array/array_plus.find.js +3 -0
  37. package/cjs/array/array_plus.find.js.map +1 -0
  38. package/cjs/array/array_plus.pad_start.d.ts +5 -0
  39. package/cjs/array/array_plus.pad_start.d.ts.map +1 -0
  40. package/cjs/array/array_plus.pad_start.js +3 -0
  41. package/cjs/array/array_plus.pad_start.js.map +1 -0
  42. package/cjs/array/array_type.d.ts +30 -12
  43. package/cjs/array/array_type.d.ts.map +1 -1
  44. package/cjs/array/filter.d.ts +24 -4
  45. package/cjs/array/filter.d.ts.map +1 -1
  46. package/cjs/array/find_first.d.ts +62 -0
  47. package/cjs/array/find_first.d.ts.map +1 -0
  48. package/cjs/array/{array.find.js → find_first.js} +1 -1
  49. package/cjs/array/find_first.js.map +1 -0
  50. package/cjs/array/head.d.ts +30 -1
  51. package/cjs/array/head.d.ts.map +1 -1
  52. package/cjs/array/intersect_of_props.d.ts +5 -3
  53. package/cjs/array/intersect_of_props.d.ts.map +1 -1
  54. package/cjs/array/last.d.ts +27 -2
  55. package/cjs/array/last.d.ts.map +1 -1
  56. package/cjs/array/literal_array.d.ts +5 -0
  57. package/cjs/array/literal_array.d.ts.map +1 -1
  58. package/cjs/array/literal_array.js +5 -0
  59. package/cjs/array/literal_array.js.map +1 -1
  60. package/cjs/array/pad_start.d.ts +5 -5
  61. package/cjs/array/pad_start.d.ts.map +1 -1
  62. package/cjs/array/reduce_while.d.ts +6 -0
  63. package/cjs/array/reduce_while.d.ts.map +1 -1
  64. package/cjs/array/reduce_while.js +6 -0
  65. package/cjs/array/reduce_while.js.map +1 -1
  66. package/cjs/array/reverse.d.ts +5 -0
  67. package/cjs/array/reverse.d.ts.map +1 -1
  68. package/cjs/array/union_of_props.d.ts +1 -1
  69. package/cjs/array/union_of_props.d.ts.map +1 -1
  70. package/cjs/assertion/assert_type.d.ts +4 -1
  71. package/cjs/assertion/assert_type.d.ts.map +1 -1
  72. package/cjs/assertion/assert_type.js.map +1 -1
  73. package/cjs/functional/compose.d.ts +2 -1
  74. package/cjs/functional/compose.d.ts.map +1 -1
  75. package/cjs/functional/compose.js.map +1 -1
  76. package/cjs/functional/context.d.ts.map +1 -1
  77. package/cjs/index.d.ts +22 -3
  78. package/cjs/index.d.ts.map +1 -1
  79. package/cjs/index.js +9 -3
  80. package/cjs/index.js.map +1 -1
  81. package/cjs/math/numeric_struct.d.ts +1 -1
  82. package/cjs/math/numeric_struct.d.ts.map +1 -1
  83. package/cjs/mix_types/any_or_never_type.d.ts +1 -1
  84. package/cjs/never/never_type.d.ts +11 -0
  85. package/cjs/never/never_type.d.ts.map +1 -1
  86. package/cjs/nodejs/isNodeError.d.ts.map +1 -1
  87. package/cjs/nominal/brand.d.ts.map +1 -1
  88. package/cjs/nominal/flavor.d.ts.map +1 -1
  89. package/cjs/object/index.d.ts +0 -1
  90. package/cjs/object/index.d.ts.map +1 -1
  91. package/cjs/object/index.js.map +1 -1
  92. package/cjs/testing/test_type.d.ts +277 -233
  93. package/cjs/testing/test_type.d.ts.map +1 -1
  94. package/cjs/testing/test_type.js.map +1 -1
  95. package/cjs/tuple/common_prop_keys.d.ts +34 -0
  96. package/cjs/tuple/common_prop_keys.d.ts.map +1 -0
  97. package/cjs/tuple/common_prop_keys.js.map +1 -0
  98. package/cjs/tuple/create_tuple.d.ts.map +1 -1
  99. package/cjs/tuple/drop.d.ts +91 -0
  100. package/cjs/tuple/drop.d.ts.map +1 -0
  101. package/cjs/{array → tuple}/drop.js +3 -1
  102. package/cjs/tuple/drop.js.map +1 -0
  103. package/{esm/array → cjs/tuple}/tail.d.ts +1 -1
  104. package/cjs/{array → tuple}/tail.d.ts.map +1 -1
  105. package/cjs/{array → tuple}/tail.js.map +1 -1
  106. package/cjs/tuple/tuple_plus.common_prop_keys.d.ts +28 -0
  107. package/cjs/tuple/tuple_plus.common_prop_keys.d.ts.map +1 -0
  108. package/cjs/tuple/tuple_plus.common_prop_keys.js +3 -0
  109. package/cjs/tuple/tuple_plus.common_prop_keys.js.map +1 -0
  110. package/cjs/tuple/tuple_plus.d.ts +5 -1
  111. package/cjs/tuple/tuple_plus.d.ts.map +1 -1
  112. package/cjs/tuple/tuple_plus.drop_match.d.ts +6 -0
  113. package/cjs/tuple/tuple_plus.drop_match.d.ts.map +1 -0
  114. package/cjs/tuple/tuple_plus.drop_match.js +3 -0
  115. package/cjs/tuple/tuple_plus.drop_match.js.map +1 -0
  116. package/cjs/tuple/tuple_plus.filter.d.ts +13 -0
  117. package/cjs/tuple/tuple_plus.filter.d.ts.map +1 -0
  118. package/cjs/tuple/tuple_plus.filter.js +3 -0
  119. package/cjs/tuple/tuple_plus.filter.js.map +1 -0
  120. package/cjs/tuple/tuple_plus.find.d.ts +64 -0
  121. package/cjs/tuple/tuple_plus.find.d.ts.map +1 -0
  122. package/cjs/tuple/tuple_plus.find.js +3 -0
  123. package/cjs/tuple/tuple_plus.find.js.map +1 -0
  124. package/cjs/tuple/tuple_plus.js +0 -15
  125. package/cjs/tuple/tuple_plus.js.map +1 -1
  126. package/cjs/tuple/tuple_plus.pad_start.d.ts +11 -5
  127. package/cjs/tuple/tuple_plus.pad_start.d.ts.map +1 -1
  128. package/cjs/tuple/tuple_type.d.ts +41 -23
  129. package/cjs/tuple/tuple_type.d.ts.map +1 -1
  130. package/cjs/union/union.d.ts +33 -0
  131. package/cjs/union/union.d.ts.map +1 -0
  132. package/cjs/{array/array.concat.js → union/union.js} +1 -1
  133. package/cjs/union/union.js.map +1 -0
  134. package/cjs/unknown/unknown_type.d.ts +12 -0
  135. package/cjs/unknown/unknown_type.d.ts.map +1 -1
  136. package/cjs/utils/options.d.ts +10 -0
  137. package/cjs/utils/options.d.ts.map +1 -0
  138. package/cjs/utils/options.js +3 -0
  139. package/cjs/utils/options.js.map +1 -0
  140. package/esm/any/any_type.d.ts +8 -8
  141. package/esm/any/any_type.d.ts.map +1 -1
  142. package/esm/array/array.at.d.ts +3 -1
  143. package/esm/array/array.at.d.ts.map +1 -1
  144. package/esm/array/array.entries.d.ts +4 -3
  145. package/esm/array/array.entries.d.ts.map +1 -1
  146. package/esm/array/array.find_last.d.ts +3 -1
  147. package/esm/array/array.find_last.d.ts.map +1 -1
  148. package/esm/array/array.some.d.ts +1 -1
  149. package/esm/array/array.some.d.ts.map +1 -1
  150. package/esm/array/array_plus.common_prop_keys.d.ts +27 -0
  151. package/esm/array/array_plus.common_prop_keys.d.ts.map +1 -0
  152. package/esm/array/array_plus.common_prop_keys.js +2 -0
  153. package/esm/array/array_plus.common_prop_keys.js.map +1 -0
  154. package/esm/array/{array.concat.d.ts → array_plus.concat.d.ts} +4 -1
  155. package/esm/array/array_plus.concat.d.ts.map +1 -0
  156. package/esm/array/array_plus.concat.js +2 -0
  157. package/esm/array/array_plus.concat.js.map +1 -0
  158. package/esm/array/array_plus.d.ts +7 -3
  159. package/esm/array/array_plus.d.ts.map +1 -1
  160. package/esm/array/array_plus.drop_match.d.ts +4 -0
  161. package/esm/array/array_plus.drop_match.d.ts.map +1 -0
  162. package/esm/array/array_plus.drop_match.js +2 -0
  163. package/esm/array/array_plus.drop_match.js.map +1 -0
  164. package/esm/array/array_plus.element_match.d.ts +44 -0
  165. package/esm/array/array_plus.element_match.d.ts.map +1 -0
  166. package/esm/array/array_plus.element_match.js +2 -0
  167. package/esm/array/array_plus.element_match.js.map +1 -0
  168. package/esm/array/array_plus.filter.d.ts +2 -0
  169. package/esm/array/array_plus.filter.d.ts.map +1 -0
  170. package/esm/array/array_plus.filter.js +2 -0
  171. package/esm/array/array_plus.filter.js.map +1 -0
  172. package/esm/array/array_plus.find.d.ts +57 -0
  173. package/esm/array/array_plus.find.d.ts.map +1 -0
  174. package/esm/array/array_plus.find.js +2 -0
  175. package/esm/array/array_plus.find.js.map +1 -0
  176. package/esm/array/array_plus.pad_start.d.ts +5 -0
  177. package/esm/array/array_plus.pad_start.d.ts.map +1 -0
  178. package/esm/array/array_plus.pad_start.js +2 -0
  179. package/esm/array/array_plus.pad_start.js.map +1 -0
  180. package/esm/array/array_type.d.ts +30 -12
  181. package/esm/array/array_type.d.ts.map +1 -1
  182. package/esm/array/filter.d.ts +24 -4
  183. package/esm/array/filter.d.ts.map +1 -1
  184. package/esm/array/find_first.d.ts +62 -0
  185. package/esm/array/find_first.d.ts.map +1 -0
  186. package/esm/array/find_first.js +2 -0
  187. package/esm/array/find_first.js.map +1 -0
  188. package/esm/array/head.d.ts +30 -1
  189. package/esm/array/head.d.ts.map +1 -1
  190. package/esm/array/intersect_of_props.d.ts +5 -3
  191. package/esm/array/intersect_of_props.d.ts.map +1 -1
  192. package/esm/array/last.d.ts +27 -2
  193. package/esm/array/last.d.ts.map +1 -1
  194. package/esm/array/literal_array.d.ts +5 -0
  195. package/esm/array/literal_array.d.ts.map +1 -1
  196. package/esm/array/literal_array.js +5 -0
  197. package/esm/array/literal_array.js.map +1 -1
  198. package/esm/array/pad_start.d.ts +5 -5
  199. package/esm/array/pad_start.d.ts.map +1 -1
  200. package/esm/array/reduce_while.d.ts +6 -0
  201. package/esm/array/reduce_while.d.ts.map +1 -1
  202. package/esm/array/reduce_while.js +6 -0
  203. package/esm/array/reduce_while.js.map +1 -1
  204. package/esm/array/reverse.d.ts +5 -0
  205. package/esm/array/reverse.d.ts.map +1 -1
  206. package/esm/array/union_of_props.d.ts +1 -1
  207. package/esm/array/union_of_props.d.ts.map +1 -1
  208. package/esm/assertion/assert_type.d.ts +4 -1
  209. package/esm/assertion/assert_type.d.ts.map +1 -1
  210. package/esm/assertion/assert_type.js.map +1 -1
  211. package/esm/functional/compose.d.ts +2 -1
  212. package/esm/functional/compose.d.ts.map +1 -1
  213. package/esm/functional/compose.js.map +1 -1
  214. package/esm/functional/context.d.ts.map +1 -1
  215. package/esm/index.d.ts +22 -3
  216. package/esm/index.d.ts.map +1 -1
  217. package/esm/index.js +4 -2
  218. package/esm/index.js.map +1 -1
  219. package/esm/math/numeric_struct.d.ts +1 -1
  220. package/esm/math/numeric_struct.d.ts.map +1 -1
  221. package/esm/mix_types/any_or_never_type.d.ts +1 -1
  222. package/esm/never/never_type.d.ts +11 -0
  223. package/esm/never/never_type.d.ts.map +1 -1
  224. package/esm/nodejs/isNodeError.d.ts.map +1 -1
  225. package/esm/nominal/brand.d.ts.map +1 -1
  226. package/esm/nominal/flavor.d.ts.map +1 -1
  227. package/esm/object/index.d.ts +0 -1
  228. package/esm/object/index.d.ts.map +1 -1
  229. package/esm/object/index.js.map +1 -1
  230. package/esm/testing/test_type.d.ts +277 -233
  231. package/esm/testing/test_type.d.ts.map +1 -1
  232. package/esm/testing/test_type.js.map +1 -1
  233. package/esm/tuple/common_prop_keys.d.ts +34 -0
  234. package/esm/tuple/common_prop_keys.d.ts.map +1 -0
  235. package/esm/tuple/common_prop_keys.js.map +1 -0
  236. package/esm/tuple/create_tuple.d.ts.map +1 -1
  237. package/esm/tuple/drop.d.ts +91 -0
  238. package/esm/tuple/drop.d.ts.map +1 -0
  239. package/esm/tuple/drop.js +9 -0
  240. package/esm/tuple/drop.js.map +1 -0
  241. package/{cjs/array → esm/tuple}/tail.d.ts +1 -1
  242. package/esm/{array → tuple}/tail.d.ts.map +1 -1
  243. package/esm/{array → tuple}/tail.js.map +1 -1
  244. package/esm/tuple/tuple_plus.common_prop_keys.d.ts +28 -0
  245. package/esm/tuple/tuple_plus.common_prop_keys.d.ts.map +1 -0
  246. package/esm/tuple/tuple_plus.common_prop_keys.js +2 -0
  247. package/esm/tuple/tuple_plus.common_prop_keys.js.map +1 -0
  248. package/esm/tuple/tuple_plus.d.ts +5 -1
  249. package/esm/tuple/tuple_plus.d.ts.map +1 -1
  250. package/esm/tuple/tuple_plus.drop_match.d.ts +6 -0
  251. package/esm/tuple/tuple_plus.drop_match.d.ts.map +1 -0
  252. package/esm/tuple/tuple_plus.drop_match.js +2 -0
  253. package/esm/tuple/tuple_plus.drop_match.js.map +1 -0
  254. package/esm/tuple/tuple_plus.filter.d.ts +13 -0
  255. package/esm/tuple/tuple_plus.filter.d.ts.map +1 -0
  256. package/esm/tuple/tuple_plus.filter.js +2 -0
  257. package/esm/tuple/tuple_plus.filter.js.map +1 -0
  258. package/esm/tuple/tuple_plus.find.d.ts +64 -0
  259. package/esm/tuple/tuple_plus.find.d.ts.map +1 -0
  260. package/esm/tuple/tuple_plus.find.js +2 -0
  261. package/esm/tuple/tuple_plus.find.js.map +1 -0
  262. package/esm/tuple/tuple_plus.js +1 -1
  263. package/esm/tuple/tuple_plus.js.map +1 -1
  264. package/esm/tuple/tuple_plus.pad_start.d.ts +11 -5
  265. package/esm/tuple/tuple_plus.pad_start.d.ts.map +1 -1
  266. package/esm/tuple/tuple_type.d.ts +41 -23
  267. package/esm/tuple/tuple_type.d.ts.map +1 -1
  268. package/esm/union/union.d.ts +33 -0
  269. package/esm/union/union.d.ts.map +1 -0
  270. package/esm/union/union.js +2 -0
  271. package/esm/union/union.js.map +1 -0
  272. package/esm/unknown/unknown_type.d.ts +12 -0
  273. package/esm/unknown/unknown_type.d.ts.map +1 -1
  274. package/esm/utils/options.d.ts +10 -0
  275. package/esm/utils/options.d.ts.map +1 -0
  276. package/esm/utils/options.js +2 -0
  277. package/esm/utils/options.js.map +1 -0
  278. package/package.json +12 -9
  279. package/ts/any/any_type.ts +8 -9
  280. package/ts/any/readme.md +71 -4
  281. package/ts/array/array.at.ts +3 -1
  282. package/ts/array/array.entries.ts +4 -2
  283. package/ts/array/array.find_last.ts +3 -1
  284. package/ts/array/array.some.ts +1 -1
  285. package/ts/array/array_plus.common_prop_keys.ts +35 -0
  286. package/ts/array/{array.concat.ts → array_plus.concat.ts} +3 -0
  287. package/ts/array/array_plus.drop_match.ts +16 -0
  288. package/ts/array/array_plus.element_match.ts +61 -0
  289. package/ts/array/array_plus.filter.ts +5 -0
  290. package/ts/array/array_plus.find.ts +71 -0
  291. package/ts/array/array_plus.pad_start.ts +13 -0
  292. package/ts/array/array_plus.ts +7 -3
  293. package/ts/array/array_type.ts +30 -12
  294. package/ts/array/filter.ts +27 -22
  295. package/ts/array/find_first.ts +71 -0
  296. package/ts/array/head.ts +40 -1
  297. package/ts/array/intersect_of_props.ts +7 -3
  298. package/ts/array/last.ts +36 -2
  299. package/ts/array/literal_array.ts +5 -0
  300. package/ts/array/pad_start.ts +6 -10
  301. package/ts/array/readme.md +297 -32
  302. package/ts/array/reduce_while.ts +6 -0
  303. package/ts/array/reverse.ts +5 -0
  304. package/ts/array/union_of_props.ts +1 -1
  305. package/ts/assertion/assert_type.ts +4 -1
  306. package/ts/assertion/readme.md +4 -3
  307. package/ts/functional/compose.ts +2 -1
  308. package/ts/functional/context.ts +1 -1
  309. package/ts/index.ts +22 -3
  310. package/ts/math/numeric_struct.ts +9 -9
  311. package/ts/mix_types/any_or_never_type.ts +1 -1
  312. package/ts/mix_types/readme.md +7 -1
  313. package/ts/never/never_type.ts +13 -0
  314. package/ts/nodejs/isNodeError.ts +13 -13
  315. package/ts/nominal/brand.ts +1 -1
  316. package/ts/nominal/flavor.ts +1 -1
  317. package/ts/object/index.ts +0 -1
  318. package/ts/testing/readme.md +30 -0
  319. package/ts/testing/test_type.ts +279 -234
  320. package/ts/tuple/common_prop_keys.ts +41 -0
  321. package/ts/tuple/create_tuple.ts +9 -9
  322. package/ts/tuple/drop.ts +125 -0
  323. package/ts/tuple/readme.md +263 -9
  324. package/ts/{array → tuple}/tail.ts +1 -1
  325. package/ts/tuple/tuple_plus.common_prop_keys.ts +47 -0
  326. package/ts/tuple/tuple_plus.drop_match.ts +20 -0
  327. package/ts/tuple/tuple_plus.filter.ts +29 -0
  328. package/ts/tuple/tuple_plus.find.ts +88 -0
  329. package/ts/tuple/tuple_plus.pad_start.ts +37 -21
  330. package/ts/tuple/tuple_plus.ts +5 -1
  331. package/ts/tuple/tuple_type.ts +67 -25
  332. package/ts/union/readme.md +81 -0
  333. package/ts/union/union.ts +37 -0
  334. package/ts/unknown/unknown_type.ts +13 -0
  335. package/ts/utils/options.ts +10 -0
  336. package/cjs/array/array.concat.d.ts.map +0 -1
  337. package/cjs/array/array.concat.js.map +0 -1
  338. package/cjs/array/array.find.d.ts +0 -21
  339. package/cjs/array/array.find.d.ts.map +0 -1
  340. package/cjs/array/array.find.js.map +0 -1
  341. package/cjs/array/common_prop_keys.d.ts +0 -11
  342. package/cjs/array/common_prop_keys.d.ts.map +0 -1
  343. package/cjs/array/common_prop_keys.js.map +0 -1
  344. package/cjs/array/drop.d.ts +0 -19
  345. package/cjs/array/drop.d.ts.map +0 -1
  346. package/cjs/array/drop.js.map +0 -1
  347. package/cjs/array/index.d.ts +0 -17
  348. package/cjs/array/index.d.ts.map +0 -1
  349. package/cjs/array/index.js +0 -33
  350. package/cjs/array/index.js.map +0 -1
  351. package/esm/array/array.concat.d.ts.map +0 -1
  352. package/esm/array/array.concat.js +0 -2
  353. package/esm/array/array.concat.js.map +0 -1
  354. package/esm/array/array.find.d.ts +0 -21
  355. package/esm/array/array.find.d.ts.map +0 -1
  356. package/esm/array/array.find.js +0 -2
  357. package/esm/array/array.find.js.map +0 -1
  358. package/esm/array/common_prop_keys.d.ts +0 -11
  359. package/esm/array/common_prop_keys.d.ts.map +0 -1
  360. package/esm/array/common_prop_keys.js.map +0 -1
  361. package/esm/array/drop.d.ts +0 -19
  362. package/esm/array/drop.d.ts.map +0 -1
  363. package/esm/array/drop.js +0 -7
  364. package/esm/array/drop.js.map +0 -1
  365. package/esm/array/index.d.ts +0 -17
  366. package/esm/array/index.d.ts.map +0 -1
  367. package/esm/array/index.js +0 -17
  368. package/esm/array/index.js.map +0 -1
  369. package/ts/array/array.find.ts +0 -32
  370. package/ts/array/common_prop_keys.ts +0 -18
  371. package/ts/array/drop.ts +0 -71
  372. package/ts/array/index.ts +0 -16
  373. /package/cjs/{array → tuple}/common_prop_keys.js +0 -0
  374. /package/cjs/{array → tuple}/tail.js +0 -0
  375. /package/esm/{array → tuple}/common_prop_keys.js +0 -0
  376. /package/esm/{array → tuple}/tail.js +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "type-plus",
3
- "version": "7.3.1",
3
+ "version": "7.5.0",
4
4
  "description": "Provides additional types for TypeScript.",
5
5
  "homepage": "https://github.com/unional/type-plus/tree/main/type-plus#readme",
6
6
  "bugs": {
@@ -19,14 +19,18 @@
19
19
  "sideEffects": false,
20
20
  "type": "module",
21
21
  "exports": {
22
- "import": {
23
- "types": "./esm/index.d.ts",
22
+ ".": {
23
+ "import": {
24
+ "types": "./esm/index.d.ts",
25
+ "default": "./esm/index.js"
26
+ },
27
+ "require": {
28
+ "types": "./cjs/index.d.ts",
29
+ "default": "./cjs/index.js"
30
+ },
24
31
  "default": "./esm/index.js"
25
32
  },
26
- "require": {
27
- "types": "./cjs/index.d.ts",
28
- "default": "./cjs/index.js"
29
- }
33
+ "./package.json": "./package.json"
30
34
  },
31
35
  "main": "./cjs/index.js",
32
36
  "module": "./esm/index.js",
@@ -64,8 +68,7 @@
64
68
  "satisfier": "^5.2.2",
65
69
  "size-limit": "^8.2.4",
66
70
  "ts-jest": "^29.1.0",
67
- "tslib": "^2.4.0",
68
- "typescript": "^5.0.4"
71
+ "tslib": "^2.4.0"
69
72
  },
70
73
  "scripts": {
71
74
  "build": "run-p build:cjs build:esm build:tslib",
@@ -1,8 +1,7 @@
1
-
2
1
  /**
3
- * Parse `T` to ensure it is exactly `any`.
2
+ * 🌪️ *filter*
4
3
  *
5
- * 🐾 *parse*
4
+ * Filter `T` to ensure it is exactly `any`.
6
5
  *
7
6
  * @example
8
7
  * ```ts
@@ -16,10 +15,10 @@
16
15
  export type AnyType<T, Then = T, Else = never> = 0 extends 1 & T ? Then : Else
17
16
 
18
17
  /**
19
- * Validate if `T` is exactly `any`.
20
- *
21
18
  * 🎭 *validate*
22
19
  *
20
+ * Validate if `T` is exactly `any`.
21
+ *
23
22
  * @example
24
23
  * ```ts
25
24
  * type R = IsAny<any> // true
@@ -32,9 +31,9 @@ export type AnyType<T, Then = T, Else = never> = 0 extends 1 & T ? Then : Else
32
31
  export type IsAny<T, Then = true, Else = false> = AnyType<T, Then, Else>
33
32
 
34
33
  /**
35
- * Parse `T` to ensure it is not exactly `any`.
34
+ * 🌪️ *filter*
36
35
  *
37
- * 🐾 *parse*
36
+ * Filter `T` to ensure it is not exactly `any`.
38
37
  *
39
38
  * @example
40
39
  * ```ts
@@ -48,10 +47,10 @@ export type IsAny<T, Then = true, Else = false> = AnyType<T, Then, Else>
48
47
  export type NotAnyType<T, Then = T, Else = never> = AnyType<T, Else, Then>
49
48
 
50
49
  /**
51
- * Validate if `T` is not exactly `any`.
52
- *
53
50
  * 🎭 *validate*
54
51
  *
52
+ * Validate if `T` is not exactly `any`.
53
+ *
55
54
  * @example
56
55
  * ```ts
57
56
  * import type { IsNotAny } from 'type-plus'
package/ts/any/readme.md CHANGED
@@ -12,10 +12,77 @@ They are strict type checks, meaning they match only the type `any`.
12
12
  Union and intersections are not a factor here they are resolved to `any`,
13
13
  except `any & never` which is `never`.
14
14
 
15
- - [`AnyType<T, Then = T, Else = never>`](any_type.ts#L15): check if `T` is exactly `any`.
16
- - [`IsAny<T, Then = true, Else = false`](any_type.ts#L30): is `T` exactly `any`.
17
- - [`NotAnyType<T, Then = T, Else = never>`](any_type.ts#L45): check if `T` is not exactly `any`.
18
- - [`IsNotAny<T, Then = true, Else = false>`](any_type.ts#L60): is `T` not exactly `any`.
15
+ ### [AnyType](./any.spec.ts#15)
16
+
17
+ `AnyType<T, Then = T, Else = never>`
18
+
19
+ 🌪️ *filter*
20
+
21
+ Filter `T` to ensure it is exactly `any`.
22
+
23
+ ```ts
24
+ import type { AnyType } from 'type-plus'
25
+
26
+ type R = AnyType<any> // any
27
+
28
+ type R = AnyType<never> // never
29
+ type R = AnyType<unknown> // never
30
+ type R = AnyType<string | boolean> // never
31
+ ```
32
+
33
+ ### [IsAny](./any.spec.ts#31)
34
+
35
+ `IsAny<T, Then = true, Else = false>`
36
+
37
+ 🎭 *validate*
38
+
39
+ Validate if `T` is exactly `any`.
40
+
41
+ ```ts
42
+ import type { IsAny } from 'type-plus'
43
+
44
+ type R = IsAny<any> // true
45
+
46
+ type R = IsAny<never> // false
47
+ type R = IsAny<unknown> // false
48
+ type R = IsAny<string | boolean> // false
49
+ ```
50
+
51
+ ### [NotAnyType](./any.spec.ts#47)
52
+
53
+ `NotAnyType<T, Then = T, Else = never>`
54
+
55
+ 🌪️ *filter*
56
+
57
+ Filter `T` to ensure it is not exactly `any`.
58
+
59
+ ```ts
60
+ import type { NotAnyType } from 'type-plus'
61
+
62
+ type R = NotAnyType<any> // never
63
+
64
+ type R = NotAnyType<never> // never
65
+ type R = NotAnyType<unknown> // never
66
+ type R = NotAnyType<string | boolean> // string | boolean
67
+ ```
68
+
69
+ ### [IsNotAny](./any.spec.ts#65)
70
+
71
+ `IsNotAny<T, Then = true, Else = false>`
72
+
73
+ 🎭 *validate*
74
+
75
+ Validate if `T` is not exactly `any`.
76
+
77
+ ```ts
78
+ import type { IsNotAny } from 'type-plus'
79
+
80
+ type R = IsNotAny<any> // false
81
+
82
+ type R = IsNotAny<never> // true
83
+ type R = IsNotAny<unknown> // true
84
+ type R = IsNotAny<string | boolean> // true
85
+ ```
19
86
 
20
87
  ## Trivia
21
88
 
@@ -3,7 +3,9 @@ import type { TupleType } from '../tuple/tuple_type.js'
3
3
  import type { IndexAt } from './array_index.js'
4
4
 
5
5
  /**
6
- * Gets the type of the array or tuple at index `N`.
6
+ * 🦴 *utilities*
7
+ *
8
+ * Gets the type of the array or tuple at positive or negative index `N`.
7
9
  *
8
10
  * Like `Array.at()`, this type supports negative numbers.
9
11
  *
@@ -13,12 +13,14 @@ import type { IsTuple } from '../tuple/tuple_type.js'
13
13
  */
14
14
  export type Entries<A extends unknown[]> = IsTuple<
15
15
  A,
16
- Device<A, []>,
16
+ Entries.Device<A, []>,
17
17
  A extends Array<infer T> ? Array<[number, T]> : never
18
18
  >
19
19
 
20
- type Device<A extends unknown[], R extends unknown[]> = A['length'] extends 0
20
+ export namespace Entries {
21
+ export type Device<A extends unknown[], R extends unknown[]> = A['length'] extends 0
21
22
  ? R
22
23
  : A extends [...infer F, infer N]
23
24
  ? Device<F, [[F['length'], N], ...R]>
24
25
  : never
26
+ }
@@ -1,7 +1,9 @@
1
1
  import type { TupleType } from '../tuple/tuple_type.js'
2
2
 
3
3
  /**
4
- * Returns the last type in the array or tuple that matches the `Criteria`.
4
+ * 🦴 *utilities*
5
+ *
6
+ * Gets the last type in the array or tuple that matches the `Criteria`.
5
7
  *
6
8
  * If the `Criteria` is not met, it will return `never'.
7
9
  *
@@ -1,6 +1,6 @@
1
1
  import type { IsEqual } from '../equal/equal.js'
2
2
  import type { CanAssign } from '../index.js'
3
- import type { Tail } from './tail.js'
3
+ import type { Tail } from '../tuple/tail.js'
4
4
  import type { UnionOfValues } from './union_of_values.js'
5
5
 
6
6
  /**
@@ -0,0 +1,35 @@
1
+ import type { NeverType } from '../never/never_type.js'
2
+ import type { KeyTypes } from '../object/KeyTypes.js'
3
+
4
+ /**
5
+ * ⚗️ *transform*
6
+ * 🔢 *customization*
7
+ *
8
+ * Gets the common keys of the record types in the array `A`.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * import { type ArrayPlus } from 'type-plus'
13
+ *
14
+ * type R = ArrayPlus.CommonPropKeys<Array<{ a: 1 }>> // 'a'
15
+ * type R = ArrayPlus.CommonPropKeys<Array<{ a: 1, b: 1 } | { a: 1, c: 1 }>> // 'a'
16
+ * ```
17
+ *
18
+ * @typeParam Options['caseNever'] Return type when `T` is `never`.
19
+ * Default to `never`.
20
+ */
21
+ export type CommonPropKeys<
22
+ A extends Record<KeyTypes, unknown>[],
23
+ Options extends CommonPropKeys.Options = CommonPropKeys.DefaultOptions
24
+ > = NeverType<A,
25
+ Options['caseNever'],
26
+ A extends Array<infer R extends Record<KeyTypes, unknown>> ? keyof R : never
27
+ >
28
+
29
+ export namespace CommonPropKeys {
30
+ export interface Options extends NeverType.Options {
31
+ }
32
+
33
+ export interface DefaultOptions extends NeverType.DefaultOptions {
34
+ }
35
+ }
@@ -1,4 +1,7 @@
1
1
  /**
2
+ * 🦴 *utilities
3
+ * 💀 *deprecated* Will be available only as `ArrayPlus.Concat` in the next version
4
+ *
2
5
  * Concats two arrays or tuples.
3
6
  *
4
7
  * alias of: `[...A, ...B]`
@@ -0,0 +1,16 @@
1
+ import type { NonNull } from '../utils/NonNull.js'
2
+ import type { NonUndefined } from '../utils/NonUndefined.js'
3
+
4
+ export type DropMatch<A extends Readonly<Array<unknown>>, Criteria> = A[0] extends Criteria
5
+ ? never[]
6
+ : (undefined extends Criteria
7
+ ? (null extends Criteria
8
+ ? Array<NonNullable<A[0]>>
9
+ : Array<NonUndefined<A[0]>>)
10
+ : (null extends Criteria
11
+ ? Array<NonNull<A[0]>>
12
+ : (Criteria extends A[0]
13
+ ? Array<Exclude<A[0], Criteria>>
14
+ : (A[0] extends Criteria
15
+ ? A
16
+ : Array<Exclude<A[0], Criteria>>))))
@@ -0,0 +1,61 @@
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
+ /**
6
+ * 🦴 *utilities*
7
+ * 🔢 *customizable*
8
+ *
9
+ * Filter the element `T` in an array or tuple to match `Criteria`.
10
+ *
11
+ * @typeParam Options['widen'] Allow using narrow type to match widen type.
12
+ * e.g. `number, 1` -> `1 | undefined`.
13
+ * Default to `true`.
14
+ *
15
+ * @typeParam Options['caseNotMatch'] Return value when `T` does not match `Criteria`.
16
+ * Default to `never`.
17
+ *
18
+ * @typeParam Options['caseWiden'] Return value when `widen` is true.
19
+ * Default to `Criteria | undefined`.
20
+ *
21
+ * @typeParam Options['caseUnionNotMatch'] Return value when a branch of the union `T` does not match `Criteria`.
22
+ * Default to `never`.
23
+ *
24
+ * If you want the type to behave more like JavaScript,
25
+ * you can override it to return `undefined`.
26
+ *
27
+ * Since it is a union, the result will be joined to the matched branch as union.
28
+ * e.g. `ElementMatch<1 | 2, 1>` -> `1 | undefined`
29
+ */
30
+ export type ElementMatch<
31
+ T,
32
+ Criteria,
33
+ Options extends ElementMatch.Options = ElementMatch.DefaultOptions<Criteria>
34
+ > = [T] extends [Criteria]
35
+ ? T
36
+ : (MergeOptions<Options, ElementMatch.DefaultOptions<Criteria>> extends infer C extends Record<keyof ElementMatch.Options, unknown>
37
+ ? ((T extends Criteria
38
+ ? T
39
+ : (C['widen'] extends true
40
+ ? (Criteria extends T
41
+ ? C['caseWiden']
42
+ : C['caseNotMatch'])
43
+ : C['caseNotMatch'])) extends infer R
44
+ ? IsUnion<T, IsNever<R, R, R | C['caseUnionNotMatch']>, R>
45
+ : C['caseNotMatch'])
46
+ : never)
47
+
48
+ export namespace ElementMatch {
49
+ export interface Options {
50
+ widen?: boolean | undefined,
51
+ caseNotMatch?: unknown,
52
+ caseWiden?: unknown,
53
+ caseUnionNotMatch?: unknown
54
+ }
55
+ export interface DefaultOptions<Criteria> {
56
+ widen: true,
57
+ caseNotMatch: never,
58
+ caseWiden: Criteria | undefined,
59
+ caseUnionNotMatch: never
60
+ }
61
+ }
@@ -0,0 +1,5 @@
1
+ export type Filter<A extends unknown[], Criteria> = A[0] extends Criteria
2
+ ? A
3
+ : Criteria extends A[0]
4
+ ? Array<Criteria>
5
+ : never[]
@@ -0,0 +1,71 @@
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
+ /**
7
+ * 🦴 *utilities*
8
+ * 🔢 *customizable*
9
+ *
10
+ * Finds the type in array `A` that matches `Criteria`.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * type R = ArrayPlus.Find<Array<string>, string> // string
15
+ * type R = ArrayPlus.Find<Array<1 | 2 | 'x'>, number> // 1 | 2 | undefined
16
+ * type R = ArrayPlus.Find<Array<string | number>, number | string> // string | number
17
+ * type R = ArrayPlus.Find<Array<number>, 1> // widen: 1 | undefined
18
+ * type R = ArrayPlus.Find<Array<string | number>, number> // unionMiss: number | undefined
19
+ *
20
+ * type R = ArrayPlus.Find<string[], number> // never
21
+ * ```
22
+ *
23
+ * @typeParam Options['widen'] performs widen match.
24
+ * Default to `true`.
25
+ * With widen match, a narrowed type will match its widen type.
26
+ * e.g. matching `1` against `number` yields `1 | undefined`
27
+ *
28
+ * The widen behavior can be customized by `Options['caseWiden']`
29
+ *
30
+ * @typeParam Options['caseNever'] return type when `A` is `never`. Default to `never`.
31
+ *
32
+ * @typeParam Options['caseNotMatch'] Return value when `T` does not match `Criteria`.
33
+ * Default to `never`.
34
+ *
35
+ * @typeParam Options['caseTuple'] return type when `A` is a tuple. Default to `not supported` message.
36
+ *
37
+ * @typeParam Options['caseWiden'] return type when `T` in `A` is a widen type of `Criteria`.
38
+ * Default to `Criteria | undefined`.
39
+ * Set it to `never` for a more type-centric behavior
40
+ *
41
+ * @typeParam Options['caseUnionNotMatch'] Return value when a branch of the union `T` does not match `Criteria`.
42
+ * Default to `never`.
43
+ *
44
+ * If you want the type to behave more like JavaScript,
45
+ * you can override it to return `undefined`.
46
+ *
47
+ * Since it is a union, the result will be joined to the matched branch as union.
48
+ */
49
+ export type Find<
50
+ A extends unknown[],
51
+ Criteria,
52
+ Options extends Find.Options = Find.DefaultOptions<Criteria>
53
+ > =
54
+ MergeOptions<Options, Find.DefaultOptions<Criteria>> extends infer O extends Find.Options
55
+ ? TupleType<
56
+ A,
57
+ O['caseTuple'],
58
+ A extends Array<infer T> ? ElementMatch<T, Criteria, O> : never,
59
+ O
60
+ >
61
+ : never
62
+
63
+ export namespace Find {
64
+ export interface Options extends ElementMatch.Options, NeverType.Options {
65
+ caseTuple?: unknown,
66
+ }
67
+
68
+ export interface DefaultOptions<Criteria> extends ElementMatch.DefaultOptions<Criteria>, NeverType.DefaultOptions {
69
+ caseTuple: 'does not support tuple. Please use `FindFirst` or `TuplePlus.Find` instead.',
70
+ }
71
+ }
@@ -0,0 +1,13 @@
1
+ import type { CanAssign } from '../index.js'
2
+ import type { CreateTuple } from '../tuple/create_tuple.js'
3
+ import type { UnionOfValues } from './union_of_values.js'
4
+
5
+ export type PadStart<
6
+ A extends unknown[],
7
+ MaxLength extends number,
8
+ PadWith = unknown
9
+ > = MaxLength extends 0
10
+ ? A
11
+ : CanAssign<PadWith, UnionOfValues<A>> extends true
12
+ ? A
13
+ : PadStart<[...CreateTuple<MaxLength, PadWith>, ...A], MaxLength, PadWith>
@@ -1,10 +1,14 @@
1
1
  export type { At } from './array.at.js'
2
- export type { Concat } from './array.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'
11
+ export type { Filter } from './array_plus.filter.js'
12
+ export type { Find } from './array_plus.find.js'
13
+ export type { PadStart } from './array_plus.pad_start.js'
9
14
  export type { SplitAt } from './array_plus.split_at.js'
10
- export type { PadStart } from './pad_start.js'
@@ -2,12 +2,17 @@ import type { IsNever } from '../never/never_type.js'
2
2
  import type { StrictNumberType } from '../number/strict_number_type.js'
3
3
 
4
4
  /**
5
- * Check if the type `T` is an array and not a tuple.
5
+ * 🌪️ *filter*
6
6
  *
7
+ * Filter `T` to ensure it is an array, excluding tuple.
8
+ *
9
+ * @example
7
10
  * ```ts
8
11
  * type R = ArrayType<number[]> // number[]
9
12
  *
10
13
  * type R = ArrayType<[1]> // never
14
+ * type R = ArrayType<number[] | 1> // never
15
+ * type R = ArrayType<number[] & { a: 1 }> // never
11
16
  * ```
12
17
  */
13
18
  export type ArrayType<T, Then = T, Else = never> = IsNever<
@@ -17,32 +22,45 @@ export type ArrayType<T, Then = T, Else = never> = IsNever<
17
22
  >
18
23
 
19
24
  /**
20
- * Check if the type `T` is not an array.
25
+ * 🎭 *validate*
26
+ *
27
+ * Validate that `T` is an array, excluding tuple.
21
28
  *
29
+ * @example
22
30
  * ```ts
23
- * type R = NotArrayType<number[]> // never
31
+ * type R = IsArray<number[]> // true
24
32
  *
25
- * type R = NotArrayType<number> // number
26
- * type R = NotArrayType<[1]> // [1]
33
+ * type R = IsArray<number> // false
34
+ * type R = IsArray<[1]> // false
27
35
  * ```
28
36
  */
29
- export type NotArrayType<T, Then = T, Else = never> = ArrayType<T, Else, Then>
37
+ export type IsArray<T, Then = true, Else = false> = ArrayType<T, Then, Else>
30
38
 
31
39
  /**
32
- * Is `T` an array?
40
+ * 🌪️ *filter*
41
+ *
42
+ * Filter `T` to ensure it is not an array, excluding tuple.
33
43
  *
44
+ * i.e. *tuple* will pass through this filter.
45
+ *
46
+ * @example
34
47
  * ```ts
35
- * type R = IsArray<number[]> // true
48
+ * type R = NotArrayType<number[]> // never
36
49
  *
37
- * type R = IsArray<number> // false
38
- * type R = IsArray<[1]> // false
50
+ * type R = NotArrayType<number> // number
51
+ * type R = NotArrayType<[1]> // [1]
39
52
  * ```
40
53
  */
41
- export type IsArray<T, Then = true, Else = false> = ArrayType<T, Then, Else>
54
+ export type NotArrayType<T, Then = T, Else = never> = ArrayType<T, Else, Then>
42
55
 
43
56
  /**
44
- * Is `T` not an array?
57
+ * 🎭 *validate*
58
+ *
59
+ * Validate that `T` is not an array, excluding tuple.
60
+ *
61
+ * i.e. *tuple* will pass through this filter.
45
62
  *
63
+ * @example
46
64
  * ```ts
47
65
  * type R = IsNotArray<number[]> // false
48
66
  *
@@ -1,27 +1,32 @@
1
+ import type { Filter as FilterTuple } from '../tuple/tuple_plus.filter.js'
2
+ import type { Filter as FilterArray } from './array_plus.filter.js'
3
+
1
4
  /**
2
- * filter the array or tuple `A`, keeping entries satisfying `Criteria`.
5
+ * ⚗️ *transform*
6
+ *
7
+ * Filter the array or tuple `A`, keeping entries satisfying `Criteria`.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * type R = Filter<[1, 2, '3'], number> // [1, 2]
12
+ * type R = Filter<Array<string | undefined>, string> // string[]
13
+ * ```
3
14
  */
4
- export type Filter<A extends Array<any>, Criteria> = number extends A['length']
5
- ? // array
6
- A[0] extends Criteria
7
- ? A
8
- : Criteria extends A[0]
9
- ? Array<Criteria>
10
- : never[]
11
- : // tuple
12
- A['length'] extends 0
13
- ? never
14
- : A extends [infer Head, ...infer Tail]
15
- ? Tail['length'] extends 0
16
- ? Head extends Criteria
17
- ? [Head]
18
- : never[]
19
- : Head extends Criteria
20
- ? [Head, ...Filter<Tail, Criteria>]
21
- : Filter<Tail, Criteria>
22
- : never
15
+ export type Filter<A extends unknown[], Criteria> = number extends A['length']
16
+ ? FilterArray<A, Criteria>
17
+ : FilterTuple<A, Criteria>
23
18
 
24
19
  /**
25
- * keeps entries satisfying `Criteria` in array or tuple `A`.
20
+ * ⚗️ *transform*
21
+ * 👽 *alias*
22
+ *
23
+ * Keeps entries satisfying `Criteria` in array or tuple `A`.
24
+ *
25
+ * @alias of [Filter](./filter.ts)
26
+ * @example
27
+ * ```ts
28
+ * type R = KeepMatch<[1, 2, 3], number> // [1, 2]
29
+ * type R = KeepMatch<Array<string|undefined>, string> // string[]
30
+ * ```
26
31
  */
27
- export type KeepMatch<A extends Array<any>, Criteria> = Filter<A, Criteria>
32
+ export type KeepMatch<A extends unknown[], Criteria> = Filter<A, Criteria>
@@ -0,0 +1,71 @@
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
+ /**
6
+ * 🦴 *utilities*
7
+ * 🔢 *customizable*
8
+ *
9
+ * Find the first type in the array or tuple `A` that matches `Criteria`.
10
+ *
11
+ * If the `Criteria` is not met, it will return `never'.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * type R = FindFirst<[true, 1, 'x', 3], string> // 'x'
16
+ * type R = FindFirst<[true, 1, 'x', 3], number> // 1
17
+ * type R = FindFirst<[string, number, 1], 1> // widen: 1 | undefined
18
+ * type R = FindFirst<[true, number | string], string> // unionMiss: string | undefined
19
+ * type R = FindFirst<Array<string>, string> // string
20
+ * type R = FindFirst<Array<1 | 2 | 'x'>, number> // 1 | 2 | undefined
21
+ * type R = FindFirst<Array<string | number>, number | string> // string | number
22
+ * type R = FindFirst<Array<number>, 1> // widen: 1 | undefined
23
+ * type R = FindFirst<Array<string | number>, number> // unionMiss: number | undefined
24
+ *
25
+ * type R = FindFirst<[true, 1, 'x'], 2> // never
26
+ * type R = FindFirst<string[], number> // never
27
+ * ```
28
+ *
29
+ * @typeParam Options['widen'] performs widen match.
30
+ * Default to `true`.
31
+ * With widen match, a narrowed type will match its widen type.
32
+ * e.g. matching `1` against `number` yields `1 | undefined`
33
+ *
34
+ * The widen behavior can be customized by `Options['caseWiden']`
35
+ *
36
+ * @typeParam Options['caseEmptyTuple'] return type when `A` is an empty tuple.
37
+ * Default to `never`.
38
+ *
39
+ * @typeParam Options['caseNever'] return type when `A` is `never`. Default to `never`.
40
+ *
41
+ * @typeParam Options['caseNoMatch'] Return value when `T` does not match `Criteria`.
42
+ * Default to `never`.
43
+ *
44
+ * @typeParam Options['caseWiden'] return type when `T` in `A` is a widen type of `Criteria`.
45
+ * Default to `Criteria | undefined`.
46
+ * Set it to `never` for a more type-centric behavior
47
+ *
48
+ * @typeParam Options['caseUnionMiss'] Return value when a branch of the union `T` does not match `Criteria`.
49
+ * Default to `undefined`.
50
+ * Since it is a union, the result will be join to the matched branch as union.
51
+ */
52
+ export type FindFirst<
53
+ A extends unknown[],
54
+ Criteria, Options extends FindFirst.Options = FindFirst.DefaultOptions<Criteria>
55
+ > = TupleType<
56
+ A,
57
+ TupleFind<A, Criteria, Options>,
58
+ ArrayFind<A, Criteria, Options>
59
+ >
60
+
61
+ export namespace FindFirst {
62
+ export interface Options extends ArrayFind.Options, TupleFind.Options { }
63
+ export interface DefaultOptions<Criteria>
64
+ extends ArrayFind.DefaultOptions<Criteria>, TupleFind.DefaultOptions<Criteria> { }
65
+ }
66
+
67
+
68
+ /**
69
+ * @deprecated use FindFirst
70
+ */
71
+ export type First<A extends any[], Criteria> = FindFirst<A, Criteria>