type-plus 6.8.0 → 7.0.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 (539) hide show
  1. package/README.md +1053 -356
  2. package/cjs/array/{array.d.ts → array.at.d.ts} +4 -14
  3. package/cjs/array/array.at.d.ts.map +1 -0
  4. package/cjs/array/{pad_left.js → array.at.js} +1 -1
  5. package/cjs/array/array.at.js.map +1 -0
  6. package/cjs/array/array.concat.d.ts +13 -0
  7. package/cjs/array/array.concat.d.ts.map +1 -0
  8. package/cjs/array/array.concat.js +3 -0
  9. package/cjs/array/array.concat.js.map +1 -0
  10. package/cjs/array/array.entries.d.ts +17 -0
  11. package/cjs/array/array.entries.d.ts.map +1 -0
  12. package/cjs/array/array.entries.js +3 -0
  13. package/cjs/array/array.entries.js.map +1 -0
  14. package/cjs/array/array.find.d.ts +21 -0
  15. package/cjs/array/array.find.d.ts.map +1 -0
  16. package/cjs/array/{find_first.js → array.find.js} +1 -1
  17. package/cjs/array/array.find.js.map +1 -0
  18. package/cjs/array/array.find_last.d.ts +17 -0
  19. package/cjs/array/array.find_last.d.ts.map +1 -0
  20. package/cjs/array/array.find_last.js +3 -0
  21. package/cjs/array/array.find_last.js.map +1 -0
  22. package/cjs/array/array.reverse.d.ts +2 -0
  23. package/cjs/array/array.reverse.d.ts.map +1 -0
  24. package/cjs/array/array.reverse.js +3 -0
  25. package/cjs/array/array.reverse.js.map +1 -0
  26. package/cjs/array/array.some.d.ts +29 -0
  27. package/cjs/array/array.some.d.ts.map +1 -0
  28. package/cjs/array/array.some.js +3 -0
  29. package/cjs/array/array.some.js.map +1 -0
  30. package/cjs/array/array_index.d.ts +8 -8
  31. package/cjs/array/array_index.d.ts.map +1 -1
  32. package/cjs/array/array_plus.d.ts +9 -1
  33. package/cjs/array/array_plus.d.ts.map +1 -1
  34. package/cjs/array/array_plus.split_at.d.ts +30 -0
  35. package/cjs/array/array_plus.split_at.d.ts.map +1 -0
  36. package/cjs/array/array_plus.split_at.js +3 -0
  37. package/cjs/array/array_plus.split_at.js.map +1 -0
  38. package/cjs/array/drop.d.ts +2 -2
  39. package/cjs/array/drop.d.ts.map +1 -1
  40. package/cjs/array/index.d.ts +4 -5
  41. package/cjs/array/index.d.ts.map +1 -1
  42. package/cjs/array/index.js +4 -5
  43. package/cjs/array/index.js.map +1 -1
  44. package/cjs/array/pad_start.d.ts +32 -0
  45. package/cjs/array/pad_start.d.ts.map +1 -0
  46. package/cjs/array/{find_last.js → pad_start.js} +1 -1
  47. package/cjs/array/pad_start.js.map +1 -0
  48. package/cjs/assertion/assert_type.d.ts +3 -0
  49. package/cjs/assertion/assert_type.d.ts.map +1 -1
  50. package/cjs/assertion/assert_type.js +3 -0
  51. package/cjs/assertion/assert_type.js.map +1 -1
  52. package/cjs/bigint/cast.d.ts +10 -0
  53. package/cjs/bigint/cast.d.ts.map +1 -0
  54. package/cjs/{array/some.js → bigint/cast.js} +1 -1
  55. package/cjs/bigint/cast.js.map +1 -0
  56. package/cjs/equal/equal.d.ts +51 -3
  57. package/cjs/equal/equal.d.ts.map +1 -1
  58. package/cjs/functional/Maybe.d.ts +2 -2
  59. package/cjs/functional/Maybe.d.ts.map +1 -1
  60. package/cjs/index.d.ts +16 -7
  61. package/cjs/index.d.ts.map +1 -1
  62. package/cjs/index.js +6 -1
  63. package/cjs/index.js.map +1 -1
  64. package/cjs/math/abs.d.ts +6 -0
  65. package/cjs/math/abs.d.ts.map +1 -0
  66. package/cjs/math/{Add.js → abs.js} +1 -1
  67. package/cjs/math/abs.js.map +1 -0
  68. package/cjs/math/add.d.ts +7 -0
  69. package/cjs/math/add.d.ts.map +1 -0
  70. package/cjs/math/{Max.js → add.js} +1 -1
  71. package/cjs/math/add.js.map +1 -0
  72. package/cjs/math/greater_than.d.ts +4 -0
  73. package/cjs/math/greater_than.d.ts.map +1 -0
  74. package/cjs/math/greater_than.js +3 -0
  75. package/cjs/math/greater_than.js.map +1 -0
  76. package/cjs/math/index.d.ts +6 -6
  77. package/cjs/math/index.d.ts.map +1 -1
  78. package/cjs/math/math_plus.d.ts +5 -0
  79. package/cjs/math/math_plus.d.ts.map +1 -0
  80. package/cjs/math/math_plus.js +3 -0
  81. package/cjs/math/math_plus.js.map +1 -0
  82. package/cjs/math/math_plus.to_negative.d.ts +13 -0
  83. package/cjs/math/math_plus.to_negative.d.ts.map +1 -0
  84. package/cjs/math/math_plus.to_negative.js +3 -0
  85. package/cjs/math/math_plus.to_negative.js.map +1 -0
  86. package/cjs/math/max.d.ts +4 -0
  87. package/cjs/math/max.d.ts.map +1 -0
  88. package/cjs/math/{Abs.js → max.js} +1 -1
  89. package/cjs/math/max.js.map +1 -0
  90. package/cjs/math/multiply.d.ts +6 -0
  91. package/cjs/math/multiply.d.ts.map +1 -0
  92. package/cjs/{array/array.js → math/multiply.js} +1 -1
  93. package/cjs/math/multiply.js.map +1 -0
  94. package/cjs/math/numeric_struct.d.ts +1469 -0
  95. package/cjs/math/numeric_struct.d.ts.map +1 -0
  96. package/cjs/math/numeric_struct.js +3 -0
  97. package/cjs/math/numeric_struct.js.map +1 -0
  98. package/cjs/math/subtract.d.ts +7 -0
  99. package/cjs/math/subtract.d.ts.map +1 -0
  100. package/cjs/math/subtract.js +3 -0
  101. package/cjs/math/subtract.js.map +1 -0
  102. package/cjs/nominal/brand.js +2 -2
  103. package/cjs/nominal/brand.js.map +1 -1
  104. package/cjs/nominal/flavor.js +2 -2
  105. package/cjs/nominal/flavor.js.map +1 -1
  106. package/cjs/number/cast.d.ts +10 -0
  107. package/cjs/number/cast.d.ts.map +1 -0
  108. package/cjs/number/cast.js +3 -0
  109. package/cjs/number/cast.js.map +1 -0
  110. package/cjs/number/number_array.d.ts +0 -2
  111. package/cjs/number/number_array.d.ts.map +1 -1
  112. package/cjs/number/number_array.js +14 -1
  113. package/cjs/number/number_array.js.map +1 -1
  114. package/cjs/number/number_plus.d.ts +4 -5
  115. package/cjs/number/number_plus.d.ts.map +1 -1
  116. package/cjs/number/strict_number_type.d.ts +12 -0
  117. package/cjs/number/strict_number_type.d.ts.map +1 -1
  118. package/cjs/numeric/cast.d.ts +27 -0
  119. package/cjs/numeric/cast.d.ts.map +1 -0
  120. package/cjs/numeric/cast.js +3 -0
  121. package/cjs/numeric/cast.js.map +1 -0
  122. package/{esm/number → cjs/numeric}/integer.d.ts +2 -0
  123. package/cjs/numeric/integer.d.ts.map +1 -0
  124. package/cjs/{number → numeric}/integer.js.map +1 -1
  125. package/cjs/numeric/negative.d.ts.map +1 -0
  126. package/cjs/{number → numeric}/negative.js.map +1 -1
  127. package/cjs/numeric/numeric_plus.d.ts +5 -0
  128. package/cjs/numeric/numeric_plus.d.ts.map +1 -0
  129. package/cjs/numeric/numeric_plus.js +3 -0
  130. package/cjs/numeric/numeric_plus.js.map +1 -0
  131. package/cjs/numeric/numeric_type.d.ts.map +1 -0
  132. package/cjs/{number → numeric}/numeric_type.js.map +1 -1
  133. package/cjs/{number → numeric}/positive.d.ts +2 -2
  134. package/cjs/numeric/positive.d.ts.map +1 -0
  135. package/cjs/{number → numeric}/positive.js.map +1 -1
  136. package/cjs/object/ANotB.d.ts +3 -3
  137. package/cjs/object/ANotB.d.ts.map +1 -1
  138. package/cjs/object/Partial.d.ts +6 -0
  139. package/cjs/object/Partial.d.ts.map +1 -1
  140. package/cjs/object/Required.d.ts +4 -0
  141. package/cjs/object/Required.d.ts.map +1 -1
  142. package/cjs/object/index.d.ts +1 -1
  143. package/cjs/object/index.d.ts.map +1 -1
  144. package/cjs/object/object_type.d.ts +1 -1
  145. package/cjs/object/split.d.ts +3 -1
  146. package/cjs/object/split.d.ts.map +1 -1
  147. package/cjs/object/split.js.map +1 -1
  148. package/cjs/predicates/CanAssign.d.ts +35 -0
  149. package/cjs/predicates/CanAssign.d.ts.map +1 -1
  150. package/cjs/predicates/CanAssign.js.map +1 -1
  151. package/cjs/predicates/Extends.d.ts +2 -2
  152. package/cjs/predicates/Extends.d.ts.map +1 -1
  153. package/cjs/predicates/index.d.ts +0 -1
  154. package/cjs/predicates/index.d.ts.map +1 -1
  155. package/cjs/predicates/index.js +0 -1
  156. package/cjs/predicates/index.js.map +1 -1
  157. package/cjs/testing/stub.d.ts.map +1 -1
  158. package/cjs/testing/stub.js +4 -3
  159. package/cjs/testing/stub.js.map +1 -1
  160. package/cjs/testing/test_type.d.ts +125 -50
  161. package/cjs/testing/test_type.d.ts.map +1 -1
  162. package/cjs/testing/test_type.js +4 -141
  163. package/cjs/testing/test_type.js.map +1 -1
  164. package/cjs/tuple/create_tuple.d.ts +28 -0
  165. package/cjs/tuple/create_tuple.d.ts.map +1 -0
  166. package/cjs/{array → tuple}/create_tuple.js.map +1 -1
  167. package/cjs/tuple/tuple_plus.d.ts +2 -0
  168. package/cjs/tuple/tuple_plus.d.ts.map +1 -0
  169. package/cjs/tuple/tuple_plus.js +18 -0
  170. package/cjs/tuple/tuple_plus.js.map +1 -0
  171. package/cjs/tuple/tuple_plus.pad_start.d.ts +22 -0
  172. package/cjs/tuple/tuple_plus.pad_start.d.ts.map +1 -0
  173. package/cjs/tuple/tuple_plus.pad_start.js +3 -0
  174. package/cjs/tuple/tuple_plus.pad_start.js.map +1 -0
  175. package/cjs/{predicates/isType.d.ts → type-guard/is_type.d.ts} +5 -3
  176. package/cjs/type-guard/is_type.d.ts.map +1 -0
  177. package/cjs/{predicates/isType.js → type-guard/is_type.js} +8 -2
  178. package/cjs/type-guard/is_type.js.map +1 -0
  179. package/esm/array/{array.d.ts → array.at.d.ts} +4 -14
  180. package/esm/array/array.at.d.ts.map +1 -0
  181. package/esm/array/array.at.js +2 -0
  182. package/esm/array/array.at.js.map +1 -0
  183. package/esm/array/array.concat.d.ts +13 -0
  184. package/esm/array/array.concat.d.ts.map +1 -0
  185. package/esm/array/array.concat.js +2 -0
  186. package/esm/array/array.concat.js.map +1 -0
  187. package/esm/array/array.entries.d.ts +17 -0
  188. package/esm/array/array.entries.d.ts.map +1 -0
  189. package/esm/array/array.entries.js +2 -0
  190. package/esm/array/array.entries.js.map +1 -0
  191. package/esm/array/array.find.d.ts +21 -0
  192. package/esm/array/array.find.d.ts.map +1 -0
  193. package/esm/array/array.find.js +2 -0
  194. package/esm/array/array.find.js.map +1 -0
  195. package/esm/array/array.find_last.d.ts +17 -0
  196. package/esm/array/array.find_last.d.ts.map +1 -0
  197. package/esm/array/array.find_last.js +2 -0
  198. package/esm/array/array.find_last.js.map +1 -0
  199. package/esm/array/array.reverse.d.ts +2 -0
  200. package/esm/array/array.reverse.d.ts.map +1 -0
  201. package/esm/array/array.reverse.js +2 -0
  202. package/esm/array/array.reverse.js.map +1 -0
  203. package/esm/array/array.some.d.ts +29 -0
  204. package/esm/array/array.some.d.ts.map +1 -0
  205. package/esm/array/array.some.js +2 -0
  206. package/esm/array/array.some.js.map +1 -0
  207. package/esm/array/array_index.d.ts +8 -8
  208. package/esm/array/array_index.d.ts.map +1 -1
  209. package/esm/array/array_plus.d.ts +9 -1
  210. package/esm/array/array_plus.d.ts.map +1 -1
  211. package/esm/array/array_plus.split_at.d.ts +30 -0
  212. package/esm/array/array_plus.split_at.d.ts.map +1 -0
  213. package/esm/array/array_plus.split_at.js +2 -0
  214. package/esm/array/array_plus.split_at.js.map +1 -0
  215. package/esm/array/drop.d.ts +2 -2
  216. package/esm/array/drop.d.ts.map +1 -1
  217. package/esm/array/index.d.ts +4 -5
  218. package/esm/array/index.d.ts.map +1 -1
  219. package/esm/array/index.js +4 -5
  220. package/esm/array/index.js.map +1 -1
  221. package/esm/array/pad_start.d.ts +32 -0
  222. package/esm/array/pad_start.d.ts.map +1 -0
  223. package/esm/array/pad_start.js +2 -0
  224. package/esm/array/pad_start.js.map +1 -0
  225. package/esm/assertion/assert_type.d.ts +3 -0
  226. package/esm/assertion/assert_type.d.ts.map +1 -1
  227. package/esm/assertion/assert_type.js +3 -0
  228. package/esm/assertion/assert_type.js.map +1 -1
  229. package/esm/bigint/cast.d.ts +10 -0
  230. package/esm/bigint/cast.d.ts.map +1 -0
  231. package/esm/bigint/cast.js +2 -0
  232. package/esm/bigint/cast.js.map +1 -0
  233. package/esm/equal/equal.d.ts +51 -3
  234. package/esm/equal/equal.d.ts.map +1 -1
  235. package/esm/functional/Maybe.d.ts +2 -2
  236. package/esm/functional/Maybe.d.ts.map +1 -1
  237. package/esm/index.d.ts +16 -7
  238. package/esm/index.d.ts.map +1 -1
  239. package/esm/index.js +5 -0
  240. package/esm/index.js.map +1 -1
  241. package/esm/math/abs.d.ts +6 -0
  242. package/esm/math/abs.d.ts.map +1 -0
  243. package/esm/math/abs.js +2 -0
  244. package/esm/math/abs.js.map +1 -0
  245. package/esm/math/add.d.ts +7 -0
  246. package/esm/math/add.d.ts.map +1 -0
  247. package/esm/math/add.js +2 -0
  248. package/esm/math/add.js.map +1 -0
  249. package/esm/math/greater_than.d.ts +4 -0
  250. package/esm/math/greater_than.d.ts.map +1 -0
  251. package/esm/math/greater_than.js +2 -0
  252. package/esm/math/greater_than.js.map +1 -0
  253. package/esm/math/index.d.ts +6 -6
  254. package/esm/math/index.d.ts.map +1 -1
  255. package/esm/math/math_plus.d.ts +5 -0
  256. package/esm/math/math_plus.d.ts.map +1 -0
  257. package/esm/math/math_plus.js +2 -0
  258. package/esm/math/math_plus.js.map +1 -0
  259. package/esm/math/math_plus.to_negative.d.ts +13 -0
  260. package/esm/math/math_plus.to_negative.d.ts.map +1 -0
  261. package/esm/math/math_plus.to_negative.js +2 -0
  262. package/esm/math/math_plus.to_negative.js.map +1 -0
  263. package/esm/math/max.d.ts +4 -0
  264. package/esm/math/max.d.ts.map +1 -0
  265. package/esm/math/max.js +2 -0
  266. package/esm/math/max.js.map +1 -0
  267. package/esm/math/multiply.d.ts +6 -0
  268. package/esm/math/multiply.d.ts.map +1 -0
  269. package/esm/math/multiply.js +2 -0
  270. package/esm/math/multiply.js.map +1 -0
  271. package/esm/math/numeric_struct.d.ts +1469 -0
  272. package/esm/math/numeric_struct.d.ts.map +1 -0
  273. package/esm/math/numeric_struct.js +2 -0
  274. package/esm/math/numeric_struct.js.map +1 -0
  275. package/esm/math/subtract.d.ts +7 -0
  276. package/esm/math/subtract.d.ts.map +1 -0
  277. package/esm/math/subtract.js +2 -0
  278. package/esm/math/subtract.js.map +1 -0
  279. package/esm/nominal/brand.js +1 -1
  280. package/esm/nominal/brand.js.map +1 -1
  281. package/esm/nominal/flavor.js +1 -1
  282. package/esm/nominal/flavor.js.map +1 -1
  283. package/esm/number/cast.d.ts +10 -0
  284. package/esm/number/cast.d.ts.map +1 -0
  285. package/esm/number/cast.js +2 -0
  286. package/esm/number/cast.js.map +1 -0
  287. package/esm/number/number_array.d.ts +1 -2
  288. package/esm/number/number_array.d.ts.map +1 -1
  289. package/esm/number/number_array.js +14 -0
  290. package/esm/number/number_array.js.map +1 -1
  291. package/esm/number/number_plus.d.ts +4 -5
  292. package/esm/number/number_plus.d.ts.map +1 -1
  293. package/esm/number/strict_number_type.d.ts +12 -0
  294. package/esm/number/strict_number_type.d.ts.map +1 -1
  295. package/esm/numeric/cast.d.ts +27 -0
  296. package/esm/numeric/cast.d.ts.map +1 -0
  297. package/esm/numeric/cast.js +2 -0
  298. package/esm/numeric/cast.js.map +1 -0
  299. package/{cjs/number → esm/numeric}/integer.d.ts +2 -0
  300. package/esm/numeric/integer.d.ts.map +1 -0
  301. package/esm/{number → numeric}/integer.js.map +1 -1
  302. package/esm/numeric/negative.d.ts.map +1 -0
  303. package/esm/{number → numeric}/negative.js.map +1 -1
  304. package/esm/numeric/numeric_plus.d.ts +5 -0
  305. package/esm/numeric/numeric_plus.d.ts.map +1 -0
  306. package/esm/numeric/numeric_plus.js +2 -0
  307. package/esm/numeric/numeric_plus.js.map +1 -0
  308. package/esm/numeric/numeric_type.d.ts.map +1 -0
  309. package/esm/{number → numeric}/numeric_type.js.map +1 -1
  310. package/esm/{number → numeric}/positive.d.ts +2 -2
  311. package/esm/numeric/positive.d.ts.map +1 -0
  312. package/esm/{number → numeric}/positive.js.map +1 -1
  313. package/esm/object/ANotB.d.ts +3 -3
  314. package/esm/object/ANotB.d.ts.map +1 -1
  315. package/esm/object/Partial.d.ts +6 -0
  316. package/esm/object/Partial.d.ts.map +1 -1
  317. package/esm/object/Required.d.ts +4 -0
  318. package/esm/object/Required.d.ts.map +1 -1
  319. package/esm/object/index.d.ts +1 -1
  320. package/esm/object/index.d.ts.map +1 -1
  321. package/esm/object/object_type.d.ts +1 -1
  322. package/esm/object/split.d.ts +3 -1
  323. package/esm/object/split.d.ts.map +1 -1
  324. package/esm/object/split.js.map +1 -1
  325. package/esm/predicates/CanAssign.d.ts +35 -0
  326. package/esm/predicates/CanAssign.d.ts.map +1 -1
  327. package/esm/predicates/CanAssign.js.map +1 -1
  328. package/esm/predicates/Extends.d.ts +2 -2
  329. package/esm/predicates/Extends.d.ts.map +1 -1
  330. package/esm/predicates/index.d.ts +0 -1
  331. package/esm/predicates/index.d.ts.map +1 -1
  332. package/esm/predicates/index.js +0 -1
  333. package/esm/predicates/index.js.map +1 -1
  334. package/esm/testing/stub.d.ts.map +1 -1
  335. package/esm/testing/stub.js +4 -3
  336. package/esm/testing/stub.js.map +1 -1
  337. package/esm/testing/test_type.d.ts +125 -50
  338. package/esm/testing/test_type.d.ts.map +1 -1
  339. package/esm/testing/test_type.js +4 -141
  340. package/esm/testing/test_type.js.map +1 -1
  341. package/esm/tuple/create_tuple.d.ts +28 -0
  342. package/esm/tuple/create_tuple.d.ts.map +1 -0
  343. package/esm/{array → tuple}/create_tuple.js.map +1 -1
  344. package/esm/tuple/tuple_plus.d.ts +2 -0
  345. package/esm/tuple/tuple_plus.d.ts.map +1 -0
  346. package/esm/tuple/tuple_plus.js +2 -0
  347. package/esm/tuple/tuple_plus.js.map +1 -0
  348. package/esm/tuple/tuple_plus.pad_start.d.ts +22 -0
  349. package/esm/tuple/tuple_plus.pad_start.d.ts.map +1 -0
  350. package/esm/tuple/tuple_plus.pad_start.js +2 -0
  351. package/esm/tuple/tuple_plus.pad_start.js.map +1 -0
  352. package/esm/{predicates/isType.d.ts → type-guard/is_type.d.ts} +5 -3
  353. package/esm/type-guard/is_type.d.ts.map +1 -0
  354. package/esm/{predicates/isType.js → type-guard/is_type.js} +8 -2
  355. package/esm/type-guard/is_type.js.map +1 -0
  356. package/package.json +3 -3
  357. package/ts/array/{array.ts → array.at.ts} +10 -15
  358. package/ts/array/array.concat.ts +12 -0
  359. package/ts/array/array.entries.ts +24 -0
  360. package/ts/array/array.find.ts +32 -0
  361. package/ts/array/array.find_last.ts +27 -0
  362. package/ts/array/array.reverse.ts +16 -0
  363. package/ts/array/array.some.ts +53 -0
  364. package/ts/array/array_index.ts +16 -10
  365. package/ts/array/array_plus.split_at.ts +47 -0
  366. package/ts/array/array_plus.ts +9 -1
  367. package/ts/array/drop.ts +2 -2
  368. package/ts/array/index.ts +4 -5
  369. package/ts/array/pad_start.ts +43 -0
  370. package/ts/array/readme.md +184 -4
  371. package/ts/assertion/assert_type.ts +6 -0
  372. package/ts/assertion/readme.md +132 -1
  373. package/ts/bigint/cast.ts +13 -0
  374. package/ts/bigint/readme.md +17 -17
  375. package/ts/equal/equal.ts +53 -3
  376. package/ts/equal/readme.md +30 -16
  377. package/ts/functional/Maybe.ts +2 -2
  378. package/ts/index.ts +22 -24
  379. package/ts/math/README.md +97 -7
  380. package/ts/math/abs.ts +18 -0
  381. package/ts/math/add.ts +14 -0
  382. package/ts/math/greater_than.ts +12 -0
  383. package/ts/math/index.ts +7 -6
  384. package/ts/math/math_plus.to_negative.ts +22 -0
  385. package/ts/math/math_plus.ts +4 -0
  386. package/ts/math/max.ts +13 -0
  387. package/ts/math/multiply.ts +12 -0
  388. package/ts/math/numeric_struct.ts +658 -0
  389. package/ts/math/subtract.ts +14 -0
  390. package/ts/nominal/brand.ts +1 -1
  391. package/ts/nominal/flavor.ts +1 -1
  392. package/ts/number/cast.ts +17 -0
  393. package/ts/number/number_array.ts +14 -14
  394. package/ts/number/number_plus.ts +6 -6
  395. package/ts/number/readme.md +0 -108
  396. package/ts/number/strict_number_type.ts +12 -0
  397. package/ts/numeric/cast.ts +28 -0
  398. package/ts/{number → numeric}/integer.ts +2 -0
  399. package/ts/numeric/numeric_plus.ts +12 -0
  400. package/ts/{number → numeric}/positive.ts +2 -2
  401. package/ts/numeric/readme.md +115 -0
  402. package/ts/object/ANotB.ts +3 -3
  403. package/ts/object/Partial.ts +5 -0
  404. package/ts/object/Required.ts +4 -0
  405. package/ts/object/index.ts +1 -1
  406. package/ts/object/object_type.ts +1 -1
  407. package/ts/object/split.ts +3 -1
  408. package/ts/predicates/CanAssign.ts +46 -0
  409. package/ts/predicates/Extends.ts +2 -2
  410. package/ts/predicates/index.ts +0 -1
  411. package/ts/testing/stub.ts +7 -4
  412. package/ts/testing/test_type.ts +131 -88
  413. package/ts/tuple/create_tuple.ts +42 -0
  414. package/ts/tuple/readme.md +11 -10
  415. package/ts/tuple/tuple_plus.pad_start.ts +42 -0
  416. package/ts/tuple/tuple_plus.ts +1 -0
  417. package/ts/{predicates/isType.ts → type-guard/is_type.ts} +11 -3
  418. package/ts/type-guard/readme.md +37 -0
  419. package/cjs/array/array.d.ts.map +0 -1
  420. package/cjs/array/array.js.map +0 -1
  421. package/cjs/array/create_tuple.d.ts +0 -11
  422. package/cjs/array/create_tuple.d.ts.map +0 -1
  423. package/cjs/array/find_first.d.ts +0 -6
  424. package/cjs/array/find_first.d.ts.map +0 -1
  425. package/cjs/array/find_first.js.map +0 -1
  426. package/cjs/array/find_last.d.ts +0 -2
  427. package/cjs/array/find_last.d.ts.map +0 -1
  428. package/cjs/array/find_last.js.map +0 -1
  429. package/cjs/array/pad_left.d.ts +0 -6
  430. package/cjs/array/pad_left.d.ts.map +0 -1
  431. package/cjs/array/pad_left.js.map +0 -1
  432. package/cjs/array/some.d.ts +0 -8
  433. package/cjs/array/some.d.ts.map +0 -1
  434. package/cjs/array/some.js.map +0 -1
  435. package/cjs/math/Abs.d.ts +0 -3
  436. package/cjs/math/Abs.d.ts.map +0 -1
  437. package/cjs/math/Abs.js.map +0 -1
  438. package/cjs/math/Add.d.ts +0 -19
  439. package/cjs/math/Add.d.ts.map +0 -1
  440. package/cjs/math/Add.js.map +0 -1
  441. package/cjs/math/Digit.d.ts +0 -100
  442. package/cjs/math/Digit.d.ts.map +0 -1
  443. package/cjs/math/Digit.js +0 -3
  444. package/cjs/math/Digit.js.map +0 -1
  445. package/cjs/math/GreaterThan.d.ts +0 -13
  446. package/cjs/math/GreaterThan.d.ts.map +0 -1
  447. package/cjs/math/GreaterThan.js +0 -3
  448. package/cjs/math/GreaterThan.js.map +0 -1
  449. package/cjs/math/Max.d.ts +0 -4
  450. package/cjs/math/Max.d.ts.map +0 -1
  451. package/cjs/math/Max.js.map +0 -1
  452. package/cjs/math/Subtract.d.ts +0 -19
  453. package/cjs/math/Subtract.d.ts.map +0 -1
  454. package/cjs/math/Subtract.js +0 -3
  455. package/cjs/math/Subtract.js.map +0 -1
  456. package/cjs/number/integer.d.ts.map +0 -1
  457. package/cjs/number/negative.d.ts.map +0 -1
  458. package/cjs/number/numeric_type.d.ts.map +0 -1
  459. package/cjs/number/positive.d.ts.map +0 -1
  460. package/cjs/predicates/isType.d.ts.map +0 -1
  461. package/cjs/predicates/isType.js.map +0 -1
  462. package/esm/array/array.d.ts.map +0 -1
  463. package/esm/array/array.js +0 -2
  464. package/esm/array/array.js.map +0 -1
  465. package/esm/array/create_tuple.d.ts +0 -11
  466. package/esm/array/create_tuple.d.ts.map +0 -1
  467. package/esm/array/find_first.d.ts +0 -6
  468. package/esm/array/find_first.d.ts.map +0 -1
  469. package/esm/array/find_first.js +0 -2
  470. package/esm/array/find_first.js.map +0 -1
  471. package/esm/array/find_last.d.ts +0 -2
  472. package/esm/array/find_last.d.ts.map +0 -1
  473. package/esm/array/find_last.js +0 -2
  474. package/esm/array/find_last.js.map +0 -1
  475. package/esm/array/pad_left.d.ts +0 -6
  476. package/esm/array/pad_left.d.ts.map +0 -1
  477. package/esm/array/pad_left.js +0 -2
  478. package/esm/array/pad_left.js.map +0 -1
  479. package/esm/array/some.d.ts +0 -8
  480. package/esm/array/some.d.ts.map +0 -1
  481. package/esm/array/some.js +0 -2
  482. package/esm/array/some.js.map +0 -1
  483. package/esm/math/Abs.d.ts +0 -3
  484. package/esm/math/Abs.d.ts.map +0 -1
  485. package/esm/math/Abs.js +0 -2
  486. package/esm/math/Abs.js.map +0 -1
  487. package/esm/math/Add.d.ts +0 -19
  488. package/esm/math/Add.d.ts.map +0 -1
  489. package/esm/math/Add.js +0 -2
  490. package/esm/math/Add.js.map +0 -1
  491. package/esm/math/Digit.d.ts +0 -100
  492. package/esm/math/Digit.d.ts.map +0 -1
  493. package/esm/math/Digit.js +0 -2
  494. package/esm/math/Digit.js.map +0 -1
  495. package/esm/math/GreaterThan.d.ts +0 -13
  496. package/esm/math/GreaterThan.d.ts.map +0 -1
  497. package/esm/math/GreaterThan.js +0 -2
  498. package/esm/math/GreaterThan.js.map +0 -1
  499. package/esm/math/Max.d.ts +0 -4
  500. package/esm/math/Max.d.ts.map +0 -1
  501. package/esm/math/Max.js +0 -2
  502. package/esm/math/Max.js.map +0 -1
  503. package/esm/math/Subtract.d.ts +0 -19
  504. package/esm/math/Subtract.d.ts.map +0 -1
  505. package/esm/math/Subtract.js +0 -2
  506. package/esm/math/Subtract.js.map +0 -1
  507. package/esm/number/integer.d.ts.map +0 -1
  508. package/esm/number/negative.d.ts.map +0 -1
  509. package/esm/number/numeric_type.d.ts.map +0 -1
  510. package/esm/number/positive.d.ts.map +0 -1
  511. package/esm/predicates/isType.d.ts.map +0 -1
  512. package/esm/predicates/isType.js.map +0 -1
  513. package/ts/array/create_tuple.ts +0 -17
  514. package/ts/array/find_first.ts +0 -16
  515. package/ts/array/find_last.ts +0 -11
  516. package/ts/array/pad_left.ts +0 -16
  517. package/ts/array/some.ts +0 -33
  518. package/ts/math/Abs.ts +0 -7
  519. package/ts/math/Add.ts +0 -58
  520. package/ts/math/Digit.ts +0 -152
  521. package/ts/math/GreaterThan.ts +0 -55
  522. package/ts/math/Max.ts +0 -10
  523. package/ts/math/Subtract.ts +0 -57
  524. /package/cjs/{number → numeric}/integer.js +0 -0
  525. /package/cjs/{number → numeric}/negative.d.ts +0 -0
  526. /package/cjs/{number → numeric}/negative.js +0 -0
  527. /package/cjs/{number → numeric}/numeric_type.d.ts +0 -0
  528. /package/cjs/{number → numeric}/numeric_type.js +0 -0
  529. /package/cjs/{number → numeric}/positive.js +0 -0
  530. /package/cjs/{array → tuple}/create_tuple.js +0 -0
  531. /package/esm/{number → numeric}/integer.js +0 -0
  532. /package/esm/{number → numeric}/negative.d.ts +0 -0
  533. /package/esm/{number → numeric}/negative.js +0 -0
  534. /package/esm/{number → numeric}/numeric_type.d.ts +0 -0
  535. /package/esm/{number → numeric}/numeric_type.js +0 -0
  536. /package/esm/{number → numeric}/positive.js +0 -0
  537. /package/esm/{array → tuple}/create_tuple.js +0 -0
  538. /package/ts/{number → numeric}/negative.ts +0 -0
  539. /package/ts/{number → numeric}/numeric_type.ts +0 -0
package/README.md CHANGED
@@ -9,15 +9,46 @@
9
9
  [![Visual Studio Code][vscode_image]][vscode_url]
10
10
  [![Wallaby.js][wallaby_image]][wallaby_url]
11
11
 
12
- Advance type utilities for [TypeScript].
13
-
14
- ## Feature Highlights
15
-
16
- - [Type assertions](#type-assertions)
17
- - [Type Checking](#type-checking)
18
- - [Type Utilities](#type-utilities)
19
- - [Nominal Types](#nominal-types)
20
- - [Functional Types](#functional-types)
12
+ More than 200 type utilities for [TypeScript].
13
+
14
+ ## Table of Contents
15
+
16
+ 1. [Assertion Function](#assertion-function)
17
+ 1. [assertType](#asserttype)
18
+ 2. [Type Guard](#type-guard)
19
+ 3. [Type Utilities](#type-utilities)
20
+ 4. [Type Checking](#type-checking)
21
+ 1. [any](#any)
22
+ 2. [Array](#array)
23
+ 3. [bigint](#bigint)
24
+ 4. [boolean](#boolean)
25
+ 5. [function](#function)
26
+ 6. [never](#never)
27
+ 7. [null](#null)
28
+ 8. [number](#number)
29
+ 9. [numeric](#numeric)
30
+ 10. [object](#object)
31
+ 11. [Promise](#promise)
32
+ 12. [string](#string)
33
+ 13. [symbol](#symbol)
34
+ 14. [tuple](#tuple)
35
+ 15. [undefined](#undefined)
36
+ 16. [unknown](#unknown)
37
+ 17. [void](#void)
38
+ 5. [Constant Types](#constant-types)
39
+ 6. [JSON Support](#json-support)
40
+ 7. [Type manipulation](#type-manipulation)
41
+ 8. [Type Predicates](#type-predicates)
42
+ 1. [Logical](#logical)
43
+ 9. [Math](#math)
44
+ 10. [Utility Functions](#utility-functions)
45
+ 11. [Nominal Types](#nominal-types)
46
+ 12. [Functional Types](#functional-types)
47
+ 13. [Attribution](#attribution)
48
+ 14. [Useful Tips](#useful-tips)
49
+ 15. [Similar projects](#similar-projects)
50
+ 16. [Contribute](#contribute)
51
+ 17. [Wallaby.js](#wallabyjs)
21
52
 
22
53
  ## Installation
23
54
 
@@ -29,38 +60,29 @@ yarn add type-plus
29
60
  pnpm add type-plus
30
61
  ```
31
62
 
32
- ## Type Assertions
63
+ ## Assertion Function
33
64
 
34
- Type assertion is one of the main features of `type-plus`.
65
+ [Assertion Functions][assertion_functions] are special functions that asserts certain conditions of your program.
35
66
 
36
- Type assertions can be `immediate` compile time check, or they can have `runtime` behavior.
67
+ It is introduced in TypeScript 3.7.
37
68
 
38
- There are 4 kinds of type assertions:
69
+ They throw an error if the condition is not met, and return nothing otherwise.
39
70
 
40
- - `type guard`: [User-defined type guard functions][type_guard] (`if (isBool(s))`) introduced in TypeScript 1.6.
41
- - `assertion function`: [assertion functions][assertion_function] (`assertIsBool(a)`) introduced in TypeScript 3.7.
42
- - `logical`: functions or generic types that returns `true` or `false` type to be used in type level programming.
43
- - `filter`: generic type that returns `never` if the test fails.
71
+ These assertion functions are typically used in runtime,
72
+ so that that type of the value can be narrowed down.
44
73
 
45
- Here are the type assertions provided in `type-plus`.
46
- Use the one that fits your specific needs.
74
+ ### assertType
47
75
 
48
- `assertType<T>(subject)`:
76
+ [`assertType`](./ts/assertion/assert_type.ts) provides a generic assertion function,
77
+ as well as many assertion functions for builtin types.
49
78
 
50
- ✔️ `immediate`
79
+ > [`assertType<T>(subject)`](./ts/assertion/readme.md#asserttype)
51
80
 
52
- It ensures `subject` satisfies `T`.
53
- It is similar to `const x: T = subject` without introducing an unused variable.
54
- You need to specify `T` for it to work.
81
+ 💀 deprecated. Use `assertType.as()` instead.
55
82
 
56
83
  `assertType<T>(subject, validator)`:
57
84
 
58
- `assertType<T>(subject, Class)`:
59
-
60
- ✔️ `assertion function`, `runtime`
61
-
62
- These overloads of `assertType` allow you to specify a `validator`.
63
- With these overloads, `subject` can be `unknown` or `any`.
85
+ 🚦`assertion`: assert the `subject` is type `T` with the specified `validator`.
64
86
 
65
87
  If `subject` fails the assertion,
66
88
  a standard `TypeError` will be thrown and provide better error info.
@@ -75,189 +97,169 @@ assertType<boolean>(s, s => typeof s === 'boolean')
75
97
 
76
98
  The message beautification is provided by [`tersify`](https://github.com/unional/tersify).
77
99
 
78
- `assertType.isUndefined(subject)`:
100
+ > [`assertType.isUndefined()`](./ts/assertion/readme.md#asserttype)
79
101
 
80
- `assertType.isNull(subject)`:
102
+ 🚦`assertion`: assert the `subject` is `undefined`.
81
103
 
82
- `assertType.isNumber(subject)`:
104
+ > [`assertType.noUndefined()`](./ts/assertion/readme.md#asserttype)
83
105
 
84
- `assertType.isBoolean(subject)`:
106
+ 🚦`assertion`: assert the `subject` is not `undefined`.
85
107
 
86
- `assertType.isTrue(subject)`:
108
+ > [`assertType.isNull()`](./ts/assertion/readme.md#asserttype)
87
109
 
88
- `assertType.isFalse(subject)`:
110
+ 🚦`assertion`: assert the `subject` is `null`.
89
111
 
90
- `assertType.isString(subject)`:
112
+ > [`assertType.noNull()`](./ts/assertion/readme.md#asserttype)
91
113
 
92
- `assertType.isFunction(subject)`:
114
+ 🚦`assertion`: assert the `subject` is not `null`.
93
115
 
94
- `assertType.isConstructor(subject)`:
116
+ > [`assertType.isNumber()`](./ts/assertion/readme.md#asserttype)
95
117
 
96
- `assertType.isError(subject)`:
118
+ 🚦`assertion`: assert the `subject` is `number`.
97
119
 
98
- ✔️ `immediate`, `assertion function`, `runtime`
120
+ > [`assertType.noNumber()`](./ts/assertion/readme.md#asserttype)
99
121
 
100
- Compiler and runtime assertion with type narrowing from `any`.
101
- They assert the type of `subject` is that specific type.
102
- i.e. union type will fail at type level:
122
+ 🚦`assertion`: assert the `subject` is not `number`.
103
123
 
104
- ```ts
105
- const s: number | undefined = undefined
106
- assertType.isUndefined(s) // TypeScript complains
107
- ```
124
+ > [`assertType.isBoolean()`](./ts/assertion/readme.md#asserttype)
108
125
 
109
- They accept `any` and will be narrowed to the specific type.
126
+ 🚦`assertion`: assert the `subject` is `boolean`.
110
127
 
111
- ```ts
112
- const s: any = undefined
113
- assertType.isUndefined(s)
114
- s // type is undefined
115
- ```
128
+ > [`assertType.noBoolean()`](./ts/assertion/readme.md#asserttype)
116
129
 
117
- `assertType.isNever(subject)`:
130
+ 🚦`assertion`: assert the `subject` is not `boolean`.
118
131
 
119
- ✔️ `immediate`
132
+ > [`assertType.isTrue()`](./ts/assertion/readme.md#asserttype)
120
133
 
121
- Check if the subject type is `never`.
122
- This function is not very useful in actual code as TypeScript will indicate the error.
123
- But it can be useful when writing tests for types.
134
+ 🚦`assertion`: assert the `subject` is `true`.
124
135
 
125
- This is useful for variables. For type level only check, do the following:
136
+ > [`assertType.noTrue()`](./ts/assertion/readme.md#asserttype)
126
137
 
127
- ```ts
128
- assertType.isTrue(true as Equal<YourType, never>)
129
- ```
138
+ 🚦`assertion`: assert the `subject` is not `true`.
130
139
 
131
- `assertType.noUndefined(subject)`:
140
+ > [`assertType.isFalse()`](./ts/assertion/readme.md#asserttype)
132
141
 
133
- `assertType.noNull(subject)`:
142
+ 🚦`assertion`: assert the `subject` is `false`.
134
143
 
135
- `assertType.noNumber(subject)`:
144
+ > [`assertType.noFalse()`](./ts/assertion/readme.md#asserttype)
136
145
 
137
- `assertType.noBoolean(subject)`:
146
+ 🚦`assertion`: assert the `subject` is not `false`.
138
147
 
139
- `assertType.noTrue(subject)`:
148
+ > [`assertType.isString()`](./ts/assertion/readme.md#asserttype)
140
149
 
141
- `assertType.noFalse(subject)`:
150
+ 🚦`assertion`: assert the `subject` is `string`.
142
151
 
143
- `assertType.noString(subject)`:
152
+ > [`assertType.noString()`](./ts/assertion/readme.md#asserttype)
144
153
 
145
- `assertType.noFunction(subject)`:
154
+ 🚦`assertion`: assert the `subject` is not `string`.
146
155
 
147
- `assertType.noError(subject)`:
156
+ > [`assertType.isFunction()`](./ts/assertion/readme.md#asserttype)
148
157
 
149
- ✔️ `immediate`, `runtime`
158
+ 🚦`assertion`: assert the `subject` is `function`.
150
159
 
151
- Compiler and runtime assertion.
152
- Assert `subject` type does not contain the specific type.
153
- Work against unions.
160
+ > [`assertType.noFunction()`](./ts/assertion/readme.md#asserttype)
154
161
 
155
- ```ts
156
- const s: number | undefined = 1
157
- assertType.noUndefined(s) // TypeScript complains
158
- ```
162
+ 🚦`assertion`: assert the `subject` is not `function`.
159
163
 
160
- They accept `subject` with type `any` or `unknown`,
161
- the assertion will happen in runtime to ensure `subject` is the specific type.
164
+ > [`assertType.isError()`](./ts/assertion/readme.md#asserttype)
162
165
 
163
- `assertType.as<T>(subject)`:
166
+ 🚦`assertion`: assert the `subject` is an `Error`.
164
167
 
165
- ✔️ `immediate`
168
+ > [`assertType.noError()`](./ts/assertion/readme.md#asserttype)
166
169
 
167
- Assert `subject` as `T` inline.
168
- This is useful to help TypeScript to adjust the type on the fly.
170
+ 🚦`assertion`: assert the `subject` is not an `Error`.
169
171
 
170
- ```ts
171
- let s: number | undefined = 1
172
- assertType.as<1>(s) // `s` type is now `1`
173
- ```
172
+ > [`assertType.isConstructor()`](./ts/assertion/readme.md#asserttype)
174
173
 
175
- `isType<T>(subject: T)`:
174
+ 💀 deprecated. It does not work in all cases.
176
175
 
177
- ✔️ `immediate`
176
+ It passes for function that can be called with `new`.
177
+ If the subject is an arrow function, it can still return true after compilation.
178
178
 
179
- It ensures `subject` satisfies `T`.
180
- It is identical to `assertType<T>(subject: T)`.
181
- You need to specify `T`.
179
+ > [`assertType.isNever()`](./ts/assertion/readme.md#asserttype)
182
180
 
183
- `isType<T>(subject, validator)`:
181
+ 🚦`assertion`: assert the `subject` is `never`.
184
182
 
185
- `isType<T>(subject, Class)`:
183
+ > [`assertType.custom()`](./ts/assertion/readme.md#asserttype)
186
184
 
187
- `isType.t<T>(subject?: T)`:
185
+ 🚦`assertion`: creates a custom assertion function.
188
186
 
189
- ✔️ `immediate`, `runtime`
187
+ Using it to create a custom assertion function that provides better error messages.
190
188
 
191
- It can be used as type check: `isType.t<Equal<A, B>>()`,
192
- or value type check: `isType.t(valueTypeIsTrue)`.
193
- It returns `true` when passes (which is the only case when used in TypeScript).
189
+ The message beautification is provided by [`tersify`](https://github.com/unional/tersify).
194
190
 
195
- `isType.f<T>(subject?: T)`:
191
+ > [`assertType.as<T>()`](./ts/assertion/readme.md#asserttype)
196
192
 
197
- ✔️ `immediate`, `runtime`
193
+ 🚦`assertion`: assert the `subject` as `T` without validator.
198
194
 
199
- It can be used as type check: `isType.f<Equal<A, B>>()`,
200
- or value type check: `isType.f(valueTypeIsFalse)`.
201
- It returns `true` when passes (which is the only case when used in TypeScript).
195
+ This works similar to manual assertion `;(subject as T)`
202
196
 
203
- `isType.equal<true|false, A, B>()`:
197
+ ## Type Guard
204
198
 
205
- ✔️ `immediate`
199
+ [User-defined type guard functions][type_guard] is a function which its return type is specified as `x is T`.
206
200
 
207
- Slightly easier to use then `isType.t<>()` and `isType.f<>()`,
208
- when doing type-level only equality comparison as you don't have to import `Equal<>`.
201
+ > [`isType()`](./ts/type-guard/readme.md#istype)
209
202
 
210
- ✔️ `type guard`, `runtime`
203
+ 🛡️ `guard`: a generic type guard function
211
204
 
212
- These overloads of `isType` allow you to specify a `validator`.
213
- With these overloads, `subject` can be `unknown` or `any`.
205
+ > [`isType.t()`](./ts/type-guard/readme.md#istype)
214
206
 
215
- [`isType.never<S>()`](ts/predicates/isType.ts#L25):
207
+ 💀 `deprecated`: use `testType.true()` instead.
216
208
 
217
- ✔️ `immediate`
209
+ > [`isType.f()`](./ts/type-guard/readme.md#istype)
218
210
 
219
- Check is the type `never`.
211
+ 💀 `deprecated`: use `testType.false()` instead.
220
212
 
221
- [`isType.never(s)`](ts/predicates/isType.ts#L29):
213
+ > [`isType.never()`](./ts/type-guard/readme.md#istype)
222
214
 
223
- ✔️ `immediate`
215
+ 💀 `deprecated`: use `testType.never()` instead.
224
216
 
225
- Check is the value is type `never`.
217
+ > [`isType.equal()`](./ts/type-guard/readme.md#istype)
226
218
 
227
- `Equal<A, B>`:
228
- `IsEqual<A, B>`:
219
+ 💀 `deprecated`: use `testType.equal()` instead.
229
220
 
230
- ✔️ `logical`
221
+ ## Type Utilities
231
222
 
232
- Check if `A` and `B` are the same.
223
+ > `Equal<A, B, Then = true, Else = false>`
233
224
 
234
- `NotEqual<A, B>`:
235
- `IsNotEqual<A, B>`:
225
+ 💀 deprecated. use `IsEqual` instead. This will be converted to a ↪️ `parse`.
236
226
 
237
- ✔️ `logical`
227
+ > `IsEqual<A, B, Then = true, Else = false>`
238
228
 
239
- Check if `A` and `B` are not the same.
229
+ `predicate`: if `A` and `B` are the same.
240
230
 
241
- `IsExtend<A, B>`:
242
- `IsNotExtend<A, B>`:
231
+ > `NotEqual<A, B, Then = true, Else = false>`
243
232
 
244
- ✔️ `logical`
233
+ 💀 deprecated. use `IsNotEqual` instead. This will be converted to a ↪️ `parse`.
245
234
 
246
- Check if `A` extends or not extends `B`.
235
+ > `IsNotEqual<A, B, Then = true, Else = false>`:
247
236
 
248
- `Extendable<A, B>`:
249
- `NotExtendable<A, B>`:
237
+ `predicate`: check if `A` and `B` are not the same.
250
238
 
251
- ✔️ `filter`
239
+ > `Extendable<A, B, Then = A, Else = never>`
252
240
 
253
- Check if `A` extends or not extends `B`.
241
+ ↪️ `parse`: check if `A` extends `B`.
254
242
 
255
- `IsAssign<A, B>`:
256
- `CanAssign<A, B>`:
243
+ > `IsExtend<A, B, Then = true, Else = false>`
257
244
 
258
- ✔️ `logical`
245
+ `predicate`: check if `A` extends `B`.
246
+
247
+ > `NotExtendable<A, B, Then = A, Else = never>`:
248
+
249
+ ↪️ `parse`: check if `A` not extends `B`.
250
+
251
+ > `IsNotExtend<A, B, Then = true, Else = false>`:
252
+
253
+ ⭕ `predicate`: check if `A` not extends `B`.
254
+
255
+ > `IsAssign<A, B, Then = true, Else = false>`
256
+
257
+ 💀 `deprecated`: use `CanAssign` instead.
258
+
259
+ > `CanAssign<A, B, Then = true, Else = false>`:
260
+
261
+ ⭕ `predicate`: check can `A` assign to `B`.
259
262
 
260
- Check if `A` can be assigned to `B`.
261
263
  A typical usage is using it with `assertType`:
262
264
 
263
265
  ```ts
@@ -265,9 +267,20 @@ assertType.isFalse(false as CanAssign<boolean, { a: string }>)
265
267
  assertType.isTrue(true as CanAssign<{ a:string, b:number }, { a: string }>)
266
268
  ```
267
269
 
268
- `canAssign<T>(): (subject) => true`:
270
+ > `StrictCanAssign<A, B, Then = true, Else = false>`
269
271
 
270
- ✔️ `immediate`, `logical`
272
+ `predicate`: can `A` strictly assign to `B`
273
+
274
+ When `A` is a union, all branches must be assignable to `B`.
275
+
276
+ ```ts
277
+ StrictCanAssign<number | string, number> // false
278
+ StrictCanAssign<number | string, number | string> // true
279
+ ```
280
+
281
+ > `canAssign<T>(): (subject) => true`
282
+
283
+ ⭕💻 `predicate`, `compile-time`
271
284
 
272
285
  Returns a compile-time validating function to ensure `subject` is assignable to `T`.
273
286
 
@@ -276,9 +289,9 @@ const isConfig = canAssign<{ a: string }>()
276
289
  assertType.isTrue(isConfig({ a: 'a' }))
277
290
  ```
278
291
 
279
- `canAssign<T>(false): (subject) => false`:
292
+ > `canAssign<T>(false): (subject) => false`:
280
293
 
281
- ✔️ `immediate`, `logical`
294
+ ⭕💻 `predicate`, `compile-time`
282
295
 
283
296
  Returns a compile-time validating function to ensure `subject` is not assignable to `T`.
284
297
 
@@ -289,17 +302,6 @@ assertType.isTrue(notA({ a: 1 }))
289
302
  notA({ a: '' }) // TypeScript complains
290
303
  ```
291
304
 
292
- `IsNever<T>`:
293
-
294
- ✔️ `logical`
295
-
296
- Check if `A` is `never`.
297
-
298
- ```ts
299
- IsNever<never> // true
300
- IsNever<1> // false
301
- ```
302
-
303
305
  ## Type Checking
304
306
 
305
307
  [type-plus](./README.md) privides type checking utilities for every type.
@@ -327,73 +329,600 @@ You can learn more in their respective sections:
327
329
  - [unknown](./ts/unknown/readme.md)
328
330
  - [void](./ts/void/readme.md)
329
331
 
330
- These checks
332
+ ### any
331
333
 
332
- ## Type Utilities
334
+ > [`AnyType<T>`](./ts/any/readme.md#type-checking)
333
335
 
334
- `type-plus` also provides additional type utilities.
335
- These utilities include utility types and type-adjusted functions.
336
+ ↪️ `parse`: `T === any`.
336
337
 
337
- Note that most `predicate` types (such as `IsAny<>`) have a `Then` and `Else` that you can override.
338
+ > [`IsAny<T>`](./ts/any/readme.md#type-checking)
338
339
 
339
- e.g.:
340
+ ⭕ `predicate`: `T === any`.
340
341
 
341
- ```ts
342
- type Yes = IsAny<any, 'yes', 'no'> // 'yes'
343
- type No = IsAny<1, 'yes', 'no'> // 'no'
344
- ```
342
+ > [`NotAnyType<T>`](./ts/any/readme.md#type-checking)
343
+
344
+ ↪️ `parse`: `T !== any`.
345
+
346
+ > [`IsNotAny<T>`](./ts/any/readme.md#type-checking)
347
+
348
+ ⭕ `predicate`: `T !== any`.
345
349
 
346
- ### Any
350
+ > [`IsAnyOrNever<T>`](./ts/any/readme.md#type-utilities)
347
351
 
348
- - [`AnyType<T, Then = T, Else = never>`](ts/any_plus/any.ts#L14): `T === any`.
349
- - [`IsAny<T, Then = true, Else = false>`](ts/any_plus/any.ts#L29): `T === any` (origin: [ts-essentials]).
352
+ `predicate`: `T === any || T === never`.
350
353
 
351
354
  ### Array
352
355
 
353
- - [`At<A, N, Fail = never>`](ts/array_plus/array.ts#L19): gets the element type at index `N` in the array `A`.
354
- - `CommonPropKeys<A>`: gets common keys inside the records in the array `A` (deprecate `CommonKeys`).
355
- - [`Concat<A, B>`](ts/array_plus/array.ts#L38): `[...A, ...B]`.
356
- - `CreateTuple<L, T>`: Creates `Tuple<T>` with `L` number of elements.
357
- - `drop(array, value)`: drop a particular value from an array.
358
- - `DropFirst<A>`: drops the first value type of `A`.
359
- - `DropLast<A>`: drops the last value type of `A`.
360
- - `DropMatch<A, Criteria>`: drops entries matching `Criteria` in array or tuple `A`.
361
- - `DropUndefined<A>`: drop undefined entries from array of tuple `A`.
362
- - `Filter<A, Criteria>`: filter the array or tuple `A`, keeping entries satisfying `Criteria`. **Deprecated. Renaming to `KeepMatch`**
363
- - `FindFirst<A, Criteria>`: gets the first type satisfying `Criteria`.
364
- - `FindLast<A, Criteria>`: gets the last type satisfying `Criteria`.
365
- - `Head<A>`: gets the first entry in the array.
366
- - `IntersectOfProps<A, K>`: gets the intersect of `A[K]` types (deprecate `MapToProp`)
367
- - `IsArray<T>`: `logical` predicate for `Array`.
368
- - `KeepMatch<A, Criteria>`: keeps entries satisfying `Criteria` in array or tuple `A`.
369
- - `Last<A>`: gets the last type of array or tuple.
370
- - `literalArray(...entries)`: return an array whose items are restricted to the provided literals.
371
- - `PadLeft<A, Total, PadWith>`: pads `A` with `PadWith` if the length of `A` is less than `L`.
372
- - `reduceWhile()`: `reduce()` with predicate for early termination. \
356
+ > [`ArrayType<T>`](./ts/array/readme.md#type-checking)
357
+
358
+ ↪️ `parse`: is the type `T` exactly an array and not a tuple.
359
+
360
+ > [`IsArray<T>`](./ts/array/readme.md#type-checking)
361
+
362
+ `predicate`: is the type `T` exactly an array and not a tuple.
363
+
364
+ > [`NotArrayType<T>`](./ts/array/readme.md#type-checking)
365
+
366
+ ↪️ `parse`: is the type `T` not an array or tuple.
367
+
368
+ > [`IsNotArray<T>`](./ts/array/readme.md#type-checking)
369
+
370
+ `predicate`: is the type `T` exactly an array and not a tuple.
371
+
372
+ > [`At<A, N, Fail = never>`](ts/array_plus/array.ts#L19)
373
+
374
+ 🔨 `utilities`: gets the element type at index `N` in the array `A`.
375
+
376
+ > `CommonPropKeys<A>`
377
+
378
+ 🔨 `utilities`: gets common keys inside the records in the array `A` (deprecate `CommonKeys`).
379
+
380
+ > [`Concat<A, B>`](ts/array_plus/array.ts#L38)
381
+
382
+ 🔨 `utilities`: `[...A, ...B]`.
383
+
384
+ > `CreateTuple<L, T>`
385
+
386
+ 🔨 `utilities`: creates `tuple<T>` with `L` number of elements.
387
+
388
+ > `drop(array, value)`
389
+
390
+ 🔨 `utilities`: drop a particular value from an array.
391
+
392
+ > `DropFirst<A>`
393
+
394
+ 🔨 `utilities`: drops the first value type of `A`.
395
+
396
+ > `DropLast<A>`
397
+
398
+ 🔨 `utilities`: drops the last value type of `A`.
399
+
400
+ > `DropMatch<A, Criteria>`
401
+
402
+ 🔨 `utilities`: drops entries matching `Criteria` in array or tuple `A`.
403
+
404
+ > `DropUndefined<A>`
405
+
406
+ 🔨 `utilities`: drop undefined entries from array of tuple `A`.
407
+
408
+ > `Filter<A, Criteria>`
409
+
410
+ 💀🔨 `deprecated`,`utilities`: filter the array or tuple `A`, keeping entries satisfying `Criteria`. **Deprecated. Renaming to `KeepMatch`**
411
+
412
+ > `FindFirst<A, Criteria>`
413
+
414
+ 🔨 `utilities`: gets the first type satisfying `Criteria`.
415
+
416
+ > `FindLast<A, Criteria>`
417
+
418
+ 🔨 `utilities`: gets the last type satisfying `Criteria`.
419
+
420
+ > `Head<A>`
421
+
422
+ 🔨 `utilities`: gets the first entry in the array.
423
+
424
+ > `IntersectOfProps<A, K>`
425
+
426
+ 🔨 `utilities`: gets the intersect of `A[K]` types (deprecate `MapToProp`)
427
+
428
+ > `KeepMatch<A, Criteria>`
429
+
430
+ 🔨 `utilities`: keeps entries satisfying `Criteria` in array or tuple `A`.
431
+
432
+ > `Last<A>`
433
+
434
+ 🔨 `utilities`: gets the last type of array or tuple.
435
+
436
+ > `literalArray(...entries)`
437
+
438
+ 🔨 `utilities`: return an array whose items are restricted to the provided literals.
439
+
440
+ > `PadLeft<A, Total, PadWith>`
441
+
442
+ 🔨 `utilities`: pads `A` with `PadWith` if the length of `A` is less than `L`.
443
+
444
+ > `reduceWhile()`
445
+
446
+ 🔨 `utilities`: `reduce()` with predicate for early termination. \
373
447
  A simple version of the same function in the `ramda` package.
374
- - `Reverse<A>`: reverses the order of `A`.
375
- - `Some<A, Criteria>`: true if some elements in `A` matches `Criteria`.
376
- - `Tail<A>`: Gets the types of a tuple except the first entry.
377
- - `UnionOfProps<A, K>`: gets the union of `A[K]` types (deprecate `PropUnion`).
378
- - `UnionOfValues<A>`: gets the union of value types in `A` (deprecate `ArrayValue`).
379
- - [`ArrayPlus.IndexAt<A, N, Fail = never>`](ts/array_plus/array_plus.ts#L23): gets the normalized index for `A`.
380
- - [`ArrayPlus.IsIndexOutOfBound<A, N, Then = true, Else = false>`](ts/array_plus/array_plus.ts#L62): Is `N` an out of bound index of `A`. Supports negative numbers.
381
- - [`ArrayType<T, Then = N, Else = never>`](ts/array_plus/array.ts#L48): Is the type `T` exactly an array and not a tuple.
382
-
383
- ### Constant Types
384
-
385
- - `KeyTypes`: type of all keys.
386
- - `PrimitiveTypes`: all primitive types, including `Function`, `symbol`, and `bigint`.
387
- - `ComposableTypes`: Types that can contain custom properties. i.e. `object`, `array`, `function`.
388
- - `NonComposableTypes`: Types that cannot contain custom properties. i.e. not composable.
389
-
390
- ### JSON Support
391
-
392
- - `JSONPrimitive`: primitive types valid in JSON
393
- - `JSONObject`: JSON object
394
- - `JSONArray`: JSON array
395
- - `JSONTypes`: all JSON compatible types.
396
- - `JSONTypes.get<T>(obj, ...props)`: get a cast value in JSON
448
+
449
+ > `Reverse<A>`
450
+
451
+ 🔨 `utilities`: reverses the order of `A`.
452
+
453
+ > `Some<A, Criteria>`
454
+
455
+ 🔨 `utilities`: true if some elements in `A` matches `Criteria`.
456
+
457
+ > `Tail<A>`
458
+
459
+ 🔨 `utilities`: Gets the types of a tuple except the first entry.
460
+
461
+ > `UnionOfProps<A, K>`
462
+
463
+ 🔨 `utilities`: gets the union of `A[K]` types (deprecate `PropUnion`).
464
+
465
+ > `UnionOfValues<A>`
466
+
467
+ 🔨 `utilities`: gets the union of value types in `A` (deprecate `ArrayValue`).
468
+
469
+ > [`ArrayPlus.IndexAt<A, N, Fail = never>`](ts/array_plus/array_plus.ts#L23)
470
+
471
+ 🔨 `utilities`: gets the normalized index for `A`.
472
+
473
+ > [`ArrayPlus.IsIndexOutOfBound<A, N, Then = true, Else = false>`](ts/array_plus/array_plus.ts#L62)
474
+
475
+ ⭕ `predicate`: is `N` an out of bound index of `A`. Supports negative numbers.
476
+
477
+ ### bigint
478
+
479
+ > [`BigintType<T, Then = T, Else = never>`](./ts/bigint/bigint_type.ts#L15)
480
+
481
+ ↪️ `parse`: if `T` is `bigint` or bigint literal.
482
+
483
+ > [`IsBigint<T, Then = true, Else = false>`](./ts/bigint/bigint_type.ts#L33)
484
+
485
+ ⭕ `predicate`: if `T` is `bigint` or bigint literal.
486
+
487
+ > [`NotBigintType<T, Then = T, Else = never>`](./ts/bigint/bigint_type.ts#L47)
488
+
489
+ ↪️ `parse`: if `T` is not `bigint` or bigint literal.
490
+
491
+ > [`IsNotBigInt<T, Then = true, Else = false>`](./ts/bigint/bigint_type.ts#L61)
492
+
493
+ ⭕ `predicate`: if `T` is not `bigint` or bigint literal.
494
+
495
+ > [`StrictBigintType<T, Then = T, Else = never>`](./ts/bigint/strict_bigint_type.ts#L15)
496
+
497
+ ↪️ `parse`: if `T` is exactly `bigint`.
498
+
499
+ > [`IsStrictBigint<T, Then = true, Else = false>`](./ts/bigint/strict_bigint_type.ts#L33)
500
+
501
+ ⭕ `predicate`: if `T` is exactly `bigint`.
502
+
503
+ > [`NotStrictBigintType<T, Then = T, Else = never>`](./ts/bigint/strict_bigint_type.ts#L47)
504
+
505
+ ↪️ `parse`: if `T` is not exactly `bigint`.
506
+
507
+ > [`IsNotStrictBigint<T, Then = true, Else = false>`](./ts/bigint/strict_bigint_type.ts#L61)
508
+
509
+ ⭕ `predicate`: if `T` is not exactly `bigint`.
510
+
511
+ ### boolean
512
+
513
+ > [`BooleanType<T>`](./ts/boolean/readme.md#type-checking)
514
+
515
+ ↪️ `parse`: `T === boolean`.
516
+
517
+ > [`IsBoolean<T>`](./ts/boolean/readme.md#type-checking)
518
+
519
+ ⭕ `predicate`: `T === boolean`
520
+
521
+ > [`NotBooleanType<T>`](./ts/boolean/readme.md#type-checking)
522
+
523
+ ↪️ `parse`: `T !== boolean`.
524
+
525
+ > [`IsNotBoolean<T>`](./ts/boolean/readme.md#type-checking)
526
+
527
+ ⭕ `predicate`: `T !== boolean`
528
+
529
+ ### function
530
+
531
+ > [`FunctionType<T>`](./ts/function/readme.md#type-checking)
532
+
533
+ ↪️ `parse`: `T === function`.
534
+
535
+ > [`IsFunction<T>`](./ts/function/readme.md#type-checking)
536
+
537
+ ⭕ `predicate`: `T === function`
538
+
539
+ > [`NotFunctionType<T>`](./ts/function/readme.md#type-checking)
540
+
541
+ ↪️ `parse`: `T !== function`.
542
+
543
+ > [`IsNotFunction<T>`](./ts/function/readme.md#type-checking)
544
+
545
+ ⭕ `predicate`: `T !== function`
546
+
547
+ > `AnyFunction<P, R>`
548
+
549
+ 🔨 `utilities`: a generic type for any function
550
+
551
+ > `ExtractFunction<F>`
552
+
553
+ 🔨 `utilities`: extract the function signature from a type `F`.
554
+
555
+ > `extractFunction(fn: F)`
556
+
557
+ 🔨 `utilities`: adjust type of `fn` to its function signature only.
558
+
559
+ > `inspect<T>(value: T, inspector?: (v: T) => void)`
560
+
561
+ 🔨 `utilities`: inspect a value and return it. Inspector defaults to `console.dir()`
562
+
563
+ ### never
564
+
565
+ > [`NeverType<T>`](./ts/never/readme.md#type-checking)
566
+
567
+ ↪️ `parse`: `T === never`.
568
+
569
+ > [`IsNever<T>`](./ts/never/readme.md#type-checking)
570
+
571
+ ⭕ `predicate`: `T === never`
572
+
573
+ > [`NotNeverType<T>`](./ts/never/readme.md#type-checking)
574
+
575
+ ↪️ `parse`: `T !== never`.
576
+
577
+ > [`IsNotNever<T>`](./ts/never/readme.md#type-checking)
578
+
579
+ ⭕ `predicate`: `T !== never`
580
+
581
+ ### null
582
+
583
+ > [`NullType<T>`](./ts/null/readme.md#type-checking)
584
+
585
+ ↪️ `parse`: `T === null`.
586
+
587
+ > [`IsNull<T>`](./ts/null/readme.md#type-checking)
588
+
589
+ ⭕ `predicate`: `T === null`
590
+
591
+ > [`NotNullType<T>`](./ts/null/readme.md#type-checking)
592
+
593
+ ↪️ `parse`: `T !== null`.
594
+
595
+ > [`IsNotNull<T>`](./ts/null/readme.md#type-checking)
596
+
597
+ ⭕ `predicate`: `T !== null`
598
+
599
+ ### number
600
+
601
+ > [`NumberType<T, Then = N, Else = never>`](./ts/number/number_type.ts#L14)
602
+
603
+ ↪️ `parse`: is the type `T` `number`.
604
+
605
+ > [`IsNumber<T, Then = true, Else = false>`](./ts/number/number_type.ts#L27)
606
+
607
+ ⭕ `predicate`: is the type `T` `number`.
608
+
609
+ > [`NotNumberType<T, Then = T, Else = never>`](./ts/number/number_type.ts#L40)
610
+
611
+ ↪️ `parse`: is the type `T` not `number`.
612
+
613
+ > [`IsNotNumber<T, Then = true, Else = false>`](./ts/number/number_type.ts#L53)
614
+
615
+ ⭕ `predicate`: is the type `T` not `number`.
616
+
617
+ > [`StrictNumberType<T, Then = N, Else = never>`](./ts/number/strict_number_type.ts#L19)
618
+
619
+ ↪️ `parse`: is the type `T` exactly `number`.
620
+
621
+ > [`IsStrictNumber<T, Then = true, Else = false>`](./ts/number/strict_number_type.ts#L41)
622
+
623
+ ⭕ `predicate`: is the type `T` exactly `number`.
624
+
625
+ > [`NotStrictNumberType<T, Then = T, Else = never>`](./ts/number/strict_number_type.ts#L55)
626
+
627
+ ↪️ `parse`: is the type `T` not exactly `number`.
628
+
629
+ > [`IsNotStrictNumber<T, Then = true, Else = false>`](./ts/number/strict_number_type.ts#L69)
630
+
631
+ ⭕ `predicate`: is the type `T` not exactly `number`.
632
+
633
+ ### numeric
634
+
635
+ > [`Numeric`](./ts/numeric/numeric_type.ts#L4)
636
+
637
+ 📘 `definition`: `number | bigint`.
638
+
639
+ > [`Zero`](ts/numeric_plus/numeric_type.ts#L9)
640
+
641
+ 📘 `definition`: `0 | 0n`
642
+
643
+ > [`Integer<N, Then = N, Else = never>`](./ts/numeric/integer.ts#L15)
644
+
645
+ ↪️ `parse`: is integer.
646
+
647
+ > [`IsInteger<N, Then = true, Else = false>`](./ts/numeric/integer.ts#L32)
648
+
649
+ ⭕ `predicate`: is integer.
650
+
651
+ > [`NotInteger<N, Then = N, Else = never>`](./ts/numeric/integer.ts#L45)
652
+
653
+ ↪️ `parse`: is not integer.
654
+
655
+ > [`IsNotInteger<N, Then = true, Else = false>`](./ts/numeric/integer.ts#L60)
656
+
657
+ ⭕ `predicate`: is not integer.
658
+
659
+ > [`IsWhole<N, Then = true, Else = false>`](./ts/numeric/integer.ts#L75)
660
+
661
+ 💀⭕ `deprecated`, `predicate`: is integer. Use `IsInteger` instead.
662
+
663
+ > [`Negative<N, Then = N, Else = never>`](./ts/numeric/negative.ts#L19)
664
+
665
+ ↪️ `parse`: is negative.
666
+
667
+ > [`IsNegative<N, Then = true, Else = false>`](./ts/numeric/negative.ts#L53)
668
+
669
+ ⭕ `predicate`: is negative.
670
+
671
+ > [`NonNegative<N, Then = N, Else = never>`](./ts/numeric/negative.ts#L69)
672
+
673
+ ↪️ `parse`: is not negative.
674
+
675
+ > [`IsNonNegative<N, Then = N, Else = never>`](./ts/numeric/negative.ts#L101)
676
+
677
+ ⭕ `predicate`: is not negative.
678
+
679
+ > [`Positive<N, Then = N, Else = never>`](./ts/numeric/positive.ts#15)
680
+
681
+ ↪️ `parse`: is positive.
682
+
683
+ > [`IsPositive<N, Then = true, Else = false>`](./ts/numeric/positive.ts#L36)
684
+
685
+ ⭕ `predicate`: is positive.
686
+
687
+ > [`NotPositive<N, Then = N, Else = never>`](./ts/numeric/positive.ts#48)
688
+
689
+ ↪️ `parse`: is not positive.
690
+
691
+ > [`IsNotPositive<N, Then = true, Else = false>`](./ts/numeric/positive.ts#L60)
692
+
693
+ ⭕ `predicate`: is not positive.
694
+
695
+ ### object
696
+
697
+ > `filterKey()`
698
+
699
+ 🔨 `utilities`: type adjusted filter by key.
700
+
701
+ > `findKey()`
702
+
703
+ 🔨 `utilities`: type adjusted find by key.
704
+
705
+ > `forEachKey()`
706
+
707
+ 🔨 `utilities`: type adjusted for each by key.
708
+
709
+ > `HasKey<T, K>`
710
+
711
+ 🔨 `utilities`: predicate type checking `T` has key `K`.
712
+
713
+ > `hasKey()`
714
+
715
+ 🔨 `utilities`: function of `HasKey`.
716
+
717
+ > `IsRecord<T>`
718
+
719
+ 🔨 `utilities`: `logical` predicate for `Record`.
720
+
721
+ > `KeysWithDiffTypes<A, B>`
722
+
723
+ 🔨 `utilities`: gets the keys common in `A` and `B` but with different value type.
724
+
725
+ > `mapKey()`
726
+
727
+ 🔨 `utilities`: type adjusted map by key.
728
+
729
+ > `RecordValue<R>`
730
+
731
+ 🔨 `utilities`: gets the value type `T`from `Record<any, T>`
732
+
733
+ [video](https://www.youtube.com/watch?v=1J7xK6FUqPw).
734
+
735
+ > `reduceByKey()`
736
+
737
+ 🔨 `utilities`: type adjusted reduce by key.
738
+
739
+ > `someKey()`
740
+
741
+ 🔨 `utilities`: type adjusted some by key.
742
+
743
+ > `SpreadRecord<A, B>`
744
+
745
+ 🔨 `utilities`: type for `{...a, ...b}` when both `a` and `b` are `Record`\
746
+ for array, just do `[...A, ...B]`.
747
+
748
+ ### Promise
749
+
750
+ > `AwaitedProp<T, V>`
751
+
752
+ 🔨 `utilities`: `Awaited` on specified props `P` in `T`.
753
+
754
+ > `isPromise<R>(subject: any)`
755
+
756
+ 🔨 `utilities`: `isPromise()` type guard.
757
+
758
+ > `MaybePromise<T>`
759
+
760
+ 🔨 `utilities`: Alias of `T | Promise<T>`.
761
+
762
+ > `PromiseValue<P>`
763
+
764
+ 🔨 `utilities`: Gets the type within the Promise.
765
+
766
+ > `PromiseValueMerge<P1, P2, ...P9>`
767
+
768
+ 🔨 `utilities`: Merge the values of multiple promises.
769
+
770
+ > `mapSeries()`
771
+
772
+ 🔨 `utilities`: Similar to `bluebird.mapSeries()` but works with `async`/`await`.
773
+
774
+ > `transformMaybePromise(value, transformer)`
775
+
776
+ 🔨 `utilities`: Apply the `transformer` to the `value`.\
777
+ It is also exported under `MaybePromise.transform()`.
778
+
779
+ ### string
780
+
781
+ > [`StringType<T>`](ts/string/readme.md#type-checking)
782
+
783
+ ↪️ `parse`: is `string`.
784
+
785
+ > [`IsString<T>`](ts/string/readme.md#type-checking)
786
+
787
+ ⭕ `predicate`: is `string`.
788
+
789
+ > [`NotStringType<T>`](ts/string/readme.md#type-checking)
790
+
791
+ ↪️ `parse`: is not `string`.
792
+
793
+ > [`IsNotString<T>`](ts/string/readme.md#type-checking)
794
+
795
+ ⭕ `predicate`: is not `string`.
796
+
797
+ ### symbol
798
+
799
+ > [`SymbolType<T>`](ts/symbol/readme.md#type-checking)
800
+
801
+ ↪️ `parse`: is `symbol`.
802
+
803
+ > [`IsSymbol<T>`](ts/symbol/readme.md#type-checking)
804
+
805
+ ⭕ `predicate`: is `symbol`.
806
+
807
+ > [`NotSymbolType<T>`](ts/symbol/readme.md#type-checking)
808
+
809
+ ↪️ `parse`: is not `symbol`.
810
+
811
+ > [`IsNotSymbol<T>`](ts/symbol/readme.md#type-checking)
812
+
813
+ ⭕ `predicate`: is not `symbol`.
814
+
815
+ ### tuple
816
+
817
+ > [`TupleType<T>`](ts/tuple/readme.md#type-checking)
818
+
819
+ ↪️ `parse`: is a tuple.
820
+
821
+ > [`IsTuple<T>`](ts/tuple/readme.md#type-checking)
822
+
823
+ ⭕ `predicate`: is a tuple.
824
+
825
+ > [`NotTupleType<T>`](ts/tuple/readme.md#type-checking)
826
+
827
+ ↪️ `parse`: is not a tuple.
828
+
829
+ > [`IsNotTuple<T>`](ts/tuple/readme.md#type-checking)
830
+
831
+ ⭕ `predicate`: is not a tuple.
832
+
833
+ ### undefined
834
+
835
+ > [`UndefinedType<T>`](./ts/undefined/readme.md#type-checking)
836
+
837
+ ↪️ `parse`: `T === undefined`.
838
+
839
+ > [`IsUndefined<T>`](./ts/undefined/readme.md#type-checking)
840
+
841
+ ⭕ `predicate`: `T === undefined`
842
+
843
+ > [`NotUndefinedType<T>`](./ts/undefined/readme.md#type-checking)
844
+
845
+ ↪️ `parse`: `T !== undefined`.
846
+
847
+ > [`IsNotUndefined<T>`](./ts/undefined/readme.md#type-checking)
848
+
849
+ ⭕ `predicate`: `T !== undefined`
850
+
851
+ ### unknown
852
+
853
+ > [`UnknownType<T>`](./ts/unknown/readme.md#type-checking)
854
+
855
+ ↪️ `parse`: `T === unknown`.
856
+
857
+ > [`IsUnknown<T>`](./ts/unknown/readme.md#type-checking)
858
+
859
+ ⭕ `predicate`: `T === unknown`
860
+
861
+ > [`NotUnknownType<T>`](./ts/unknown/readme.md#type-checking)
862
+
863
+ ↪️ `parse`: `T !== unknown`.
864
+
865
+ > [`IsNotUnknown<T>`](./ts/unknown/readme.md#type-checking)
866
+
867
+ ⭕ `predicate`: `T !== unknown`
868
+
869
+ ### void
870
+
871
+ > [`VoidType<T>`](./ts/void/readme.md#type-checking)
872
+
873
+ ↪️ `parse`: `T === void`.
874
+
875
+ > [`IsVoid<T>`](./ts/void/readme.md#type-checking)
876
+
877
+ ⭕ `predicate`: `T === void`
878
+
879
+ > [`NotVoidType<T>`](./ts/void/readme.md#type-checking)
880
+
881
+ ↪️ `parse`: `T !== void`.
882
+
883
+ > [`IsNotVoid<T>`](./ts/void/readme.md#type-checking)
884
+
885
+ ⭕ `predicate`: `T !== void`
886
+
887
+ ## Constant Types
888
+
889
+ > `KeyTypes`
890
+
891
+ 📘 `definition`: type of all keys.
892
+
893
+ > `PrimitiveTypes`
894
+
895
+ 📘 `definition`: all primitive types, including `Function`, `symbol`, and `bigint`.
896
+
897
+ > `ComposableTypes`
898
+
899
+ 📘 `definition`: Types that can contain custom properties. i.e. `object`, `array`, `function`.
900
+
901
+ > `NonComposableTypes`
902
+
903
+ 📘 `definition`: Types that cannot contain custom properties. i.e. not composable.
904
+
905
+ ## JSON Support
906
+
907
+ > `JSONPrimitive`
908
+
909
+ 📘 `definition`: primitive types valid in JSON
910
+
911
+ > `JSONObject`
912
+
913
+ 📘 `definition`: JSON object
914
+
915
+ > `JSONArray`
916
+
917
+ 📘 `definition`: JSON array
918
+
919
+ > `JSONTypes`
920
+
921
+ 📘 `definition`: all JSON compatible types.
922
+
923
+ > `JSONTypes.get<T>(obj, ...props)`
924
+
925
+ 🔨 `utilities`: get a cast value in JSON
397
926
 
398
927
  ```ts
399
928
  import { JSONTypes } from 'type-plus'
@@ -403,144 +932,303 @@ const someJson: JSONTypes = { a: { b: ['z', { c: 'miku' }]}}
403
932
  JSONTypes.get<string>(someJson, 'a', 'b', 1, 'c') // miku
404
933
  ```
405
934
 
406
- ### Object utilities
407
-
408
- - `filterKey()`: type adjusted filter by key.
409
- - `findKey()`: type adjusted find by key.
410
- - `forEachKey()`: type adjusted for each by key.
411
- - `HasKey<T, K>`: predicate type checking `T` has key `K`.
412
- - `hasKey()`: function of `HasKey`.
413
- - `IsRecord<T>`: `logical` predicate for `Record`.
414
- - `KeysWithDiffTypes<A, B>`: gets the keys common in `A` and `B` but with different value type.
415
- - `mapKey()`: type adjusted map by key.
416
- - `RecordValue<R>`: gets the value type `T`from `Record<any, T>` [video](https://www.youtube.com/watch?v=1J7xK6FUqPw).
417
- - `reduceByKey()`: type adjusted reduce by key.
418
- - `someKey()`: type adjusted some by key.
419
- - `SpreadRecord<A, B>`: type for `{...a, ...b}` when both `a` and `b` are `Record`\
420
- for array, just do `[...A, ...B]`.
935
+ ## Type manipulation
421
936
 
422
- ### Promise utilities
937
+ > `ANotB<A, B>`
423
938
 
424
- - `AwaitedProp<T, V>`: `Awaited` on specified props `P` in `T`.
425
- - `isPromise<R>(subject: any)`: `isPromise()` type guard.
426
- - `MaybePromise<T>`: Alias of `T | Promise<T>`.
427
- - `PromiseValue<P>`: Gets the type within the Promise.
428
- - `PromiseValueMerge<P1, P2, ...P9>`: Merge the values of multiple promises.
429
- - `mapSeries()`: Similar to `bluebird.mapSeries()` but works with `async`/`await`.
430
- - `transformMaybePromise(value, transformer)`: Apply the `transformer` to the `value`.\
431
- It is also exported under `MaybePromise.transform()`.
939
+ 🔨 `utilities`: get object with properties in `A` and not in `B`, including properties with a different value type.
940
+
941
+ > `BNotA<A, B>`
942
+
943
+ 🔨 `utilities`: flip of `ANotB`
944
+
945
+ > `as<T>(subject)`
946
+
947
+ 🔨 `utilities`: assert `subject` as `T`. Avoid ASI issues such as `;(x as T).abc`
948
+
949
+ > `asAny(subject)`
950
+
951
+ 🔨 `utilities`: assert `subject` as `any`. Avoid ASI issue such as `;(x as any).abc`
952
+
953
+ > `EitherAnd<A, B, [C, D]>`
954
+
955
+ 💀🔨 `deprecated`,`utilities`: Renamed to `EitherOrBoth`. combines 2 to 4 types as `A | B | (A & B)`.
956
+
957
+ This is useful for combining options.
958
+
959
+ > `EitherOrBoth<A, B, [C, D]>`
960
+
961
+ 🔨 `utilities`: combines 2 to 4 types as `A | B | (A & B)`.
962
+
963
+ This is useful for combining options [video](https://youtu.be/jBxx03NT4Ik).
964
+
965
+ > `Except<T, K>`
966
+
967
+ 💀🔨 `deprecated`,`utilities`: same as `Omit<T, K>`.
968
+
969
+ > `ExcludePropType<T, U>`
970
+
971
+ 🔨 `utilities`: excludes type `U` from properties in `T`.
972
+
973
+ > `KeyofOptional<T>`
974
+
975
+ 🔨 `utilities`: `keyof` that works with `Record<any, any> | undefined`.
976
+
977
+ > `KnownKeys<T>`
978
+
979
+ 🔨 `utilities`: extract known (defined) keys from type `T`.
980
+
981
+ > `LeftJoin<A, B>`
982
+
983
+ 🔨 `utilities`: left join `A` with `B`
984
+
985
+ > `NonNull<T>`
986
+
987
+ 🔨 `utilities`: remove `null`
988
+
989
+ > `NonNullable<T>` (built-in)
990
+
991
+ 🔨 `utilities`: adjust the type not to nullable
992
+
993
+ > `NonUndefined<T>`
994
+
995
+ 🔨 `utilities`: remove `undefined`
996
+
997
+ > `Omit<T, K>`
998
+
999
+ 🔨 `utilities`: From `T`, pick a set of properties whose keys are not in the union `K`. This is the opposite of `Pick<T, K>`.
1000
+
1001
+ > `OptionalKeys<T>`
1002
+
1003
+ 🔨 `utilities`: gets keys of optional properties in `T`.
1004
+
1005
+ > `PartialExcept<T, U>`
1006
+
1007
+ 💀🔨 `deprecated`,`utilities`: same as `PartialOmit<T, U>`.
1008
+
1009
+ > `PartialOmit<T, U>`
1010
+
1011
+ 🔨 `utilities`: makes the properties not specified in `U` becomes optional.
1012
+
1013
+ > `PartialPick<T, U>`
1014
+
1015
+ 🔨 `utilities`: makes the properties specified in `U` becomes optional.
1016
+
1017
+ > `Pick<T, K>`
1018
+
1019
+ 🔨 `utilities`: pick properties `K` from `T`. Works with unions.
1020
+
1021
+ > `RecursivePartial<T>`
1022
+
1023
+ 🔨 `utilities`: make type `T` optional recursively.
432
1024
 
433
- ### Type manipulation
434
-
435
- - `ANotB<A, B>`: get object with properties in `A` and not in `B`, including properties with a different value type.
436
- - `BNotA<A, B>`: flip of `ANotB`
437
- - `as<T>(subject)`: assert `subject` as `T`. Avoid ASI issues such as `;(x as T).abc`
438
- - `asAny(subject)`: assert `subject` as `any`. Avoid ASI issue such as `;(x as any).abc`
439
- - `EitherAnd<A, B, [C, D]>`: combines 2 to 4 types as `A | B | (A & B)`. This is useful for combining options. **Deprecated**. Renamed to `EitherOrBoth`.
440
- - `EitherOrBoth<A, B, [C, D]>`: combines 2 to 4 types as `A | B | (A & B)`. This is useful for combining options [video](https://youtu.be/jBxx03NT4Ik).
441
- - `Except<T, K>`: Deprecated. Same as `Omit<T, K>`.
442
- - `ExcludePropType<T, U>`: excludes type `U` from properties in `T`.
443
- - `KeyofOptional<T>`: `keyof` that works with `Record<any, any> | undefined`.
444
- - `KnownKeys<T>`: extract known (defined) keys from type `T`.
445
- - `LeftJoin<A, B>`: left join `A` with `B`
446
- - `NonNull<T>`: remove `null`
447
- - `NonUndefined<T>`: remove `undefined`
448
- - `Omit<T, K>`: From `T`, pick a set of properties whose keys are not in the union `K`. This is the opposite of `Pick<T, K>`.
449
- - `OptionalKeys<T>`: gets keys of optional properties in `T`.
450
- - `PartialExcept<T, U>`: Deprecated. Same as `PartialOmit<T, U>`.
451
- - `PartialOmit<T, U>`: makes the properties not specified in `U` becomes optional.
452
- - `PartialPick<T, U>`: makes the properties specified in `U` becomes optional.
453
- - `Pick<T, K>`: pick properties `K` from `T`. Works with unions.
454
- - `RecursivePartial<T>`: make type `T` optional recursively.
455
- - `RecursiveRequired<T>`: make type `T` required recursively.
456
- - `ReplaceProperty<T, K, V>`: replace property `K` in `T` with `V`.
457
- - `RequiredKeys<T>`: gets keys of required properties in `T`.
458
- - `RequiredPick<T, U>`: makes the properties specified in `U` become required.
459
- - `RequiredExcept<T, U>`: makes the properties not specified in `U` become required.
460
- - `RecursiveIntersect<T, U>`: intersect type `U` onto `T` recursively.
461
- - `ValueOf<T>`: type of the value of the properties of `T`.
462
- - `Widen<T>`: widen literal types.
463
- - PropType: ...no helper type for this. Just do `YourType['propName']`.
464
-
465
- ### Type Predicates
1025
+ > `RecursiveRequired<T>`
1026
+
1027
+ 🔨 `utilities`: make type `T` required recursively.
1028
+
1029
+ > `ReplaceProperty<T, K, V>`
1030
+
1031
+ 🔨 `utilities`: replace property `K` in `T` with `V`.
1032
+
1033
+ > `RequiredKeys<T>`
1034
+
1035
+ 🔨 `utilities`: gets keys of required properties in `T`.
1036
+
1037
+ > `RequiredPick<T, U>`
1038
+
1039
+ 🔨 `utilities`: makes the properties specified in `U` become required.
1040
+
1041
+ > `RequiredExcept<T, U>`
1042
+
1043
+ 🔨 `utilities`: makes the properties not specified in `U` become required.
1044
+
1045
+ > `RecursiveIntersect<T, U>`
1046
+
1047
+ 🔨 `utilities`: intersect type `U` onto `T` recursively.
1048
+
1049
+ > `ValueOf<T>`
1050
+
1051
+ 🔨 `utilities`: type of the value of the properties of `T`.
1052
+
1053
+ > `Widen<T>`
1054
+
1055
+ 🔨 `utilities`: widen literal types.
1056
+
1057
+ PropType
1058
+
1059
+ 💀 ...no helper type for this. Just do `YourType['propName']`.
1060
+
1061
+ ## Type Predicates
466
1062
 
467
1063
  Type predicates are type alias that returns `true` or `false`.
468
1064
  They can be used to compose complex types.
469
1065
 
470
- - `HasKey<T, K>`: predicate type checking `T` has key `K`.
471
- - `IsAny<T>`: `T === any` (updated to impl: [expect-type]).
472
- - `IsBoolean<T>`: check for `boolean`, but not for `true` nor `false`.
473
- - `IsDisjoint<A, B>`: is `A` and `B` is a disjoint set.
474
- - `IsEmptyObject<T>`: is `T === {}`.
475
- - `IsLiteral<T>`: is `T` a literal type (literal string or number).
1066
+ > `HasKey<T, K>`
1067
+
1068
+ 🔨 `utilities`: predicate type checking `T` has key `K`.
1069
+
1070
+ > `IsAny<T>`
1071
+
1072
+ 🔨 `utilities`: `T === any` (updated to impl: [expect-type]).
1073
+
1074
+ > `IsBoolean<T>`
1075
+
1076
+ 🔨 `utilities`: check for `boolean`, but not for `true` nor `false`.
1077
+
1078
+ > `IsDisjoint<A, B>`
1079
+
1080
+ 🔨 `utilities`: is `A` and `B` is a disjoint set.
1081
+
1082
+ > `IsEmptyObject<T>`
1083
+
1084
+ 🔨 `utilities`: is `T === {}`.
1085
+
1086
+ > `IsLiteral<T>`
1087
+
1088
+ 🔨 `utilities`: is `T` a literal type (literal string or number).
1089
+
1090
+ ### Logical
1091
+
1092
+ > `If<Condition, Then = true, Else = false>`
476
1093
 
477
- #### Logical
1094
+ 🔨 `utilities`: if statement
478
1095
 
479
- - `If<Condition, Then = true, Else = false>`: if statement.
480
- - `And<A, B, Then = true, Else = false>`: logical `AND`.
481
- - `Or<A, B, Then = true, Else = false>`: logical `OR`.
482
- - `Xor<A, B, Then = true, Else = false>`: logical `XOR`.
483
- - `Not<X, Then = true, Else = false>`: logical `NOT`.
1096
+ > `And<A, B, Then = true, Else = false>`
1097
+
1098
+ 🔨 `utilities`: logical `AND`
1099
+
1100
+ > `Or<A, B, Then = true, Else = false>`
1101
+
1102
+ 🔨 `utilities`: logical `OR`
1103
+
1104
+ > `Xor<A, B, Then = true, Else = false>`
1105
+
1106
+ 🔨 `utilities`: logical `XOR`
1107
+
1108
+ > `Not<X, Then = true, Else = false>`
1109
+
1110
+ 🔨 `utilities`: logical `NOT`
484
1111
 
485
1112
  Note that these types work correctly with the `boolean` type.
486
1113
  e.g.:
487
1114
 
488
- - `And<boolean, true> -> boolean`
489
- - `Not<boolean> -> boolean`
1115
+ ```ts
1116
+ type R = And<boolean, true> // boolean
1117
+ type R = Not<boolean> // boolean`
1118
+ ```
490
1119
 
491
1120
  There is a problem with generic distribution: <https://github.com/microsoft/TypeScript/issues/41053>
492
1121
  So you may encounter some weird behavior if your logic is complex.
493
1122
 
494
- ### Number
495
-
496
- - [`Numeric`](ts/number_plus/number.ts#L4): either `number` or `bigint` (origin: [type-fest]).
497
- - [`Zero`](ts/number_plus/number.ts#L9): `0` in `number` or `bigint` (origin: [type-fest]).
498
- - [`Integer<N, Then = N, Else = never>`](ts/number_plus/number.ts#L27): is integer (origin: [type-fest]).
499
- - [`IsInteger<N, Then = true, Else = false>`](ts/number_plus/number.ts#L46): is integer.
500
- - [`IsWhole<N, Then = true, Else = false>`](ts/number_plus/number.ts#L62): is integer.
501
- - [`Negative<N, Then = N, Else = never>`](ts/number_plus/number.ts#L77): is negative (origin: [type-fest]).
502
- - [`NonNegative<N, Then = N, Else = never>`](ts/number_plus/number.ts#L96): is non-negative (origin: [type-fest])
503
- - [`NumberType<T, Then = N, Else = never>`](ts/number_plus/number.ts#L108): Is the type `T` exactly `number`.
504
- - [`Positive<N, Then = N, Else = never>`](ts/number_plus/number.ts#L124): is positive.
505
- - [`IsPositive<N, Then = N, Else = never>`](ts/number_plus/number.ts#L144): is positive.
506
-
507
- ### Math
508
-
509
- - `Abs<N, Fail=never>`: `Abs(N)`, `Abs<number>` returns `Fail`.
510
- - `Max<A, B, Fail=never>`: `max(A, B)`, for whole number, `Fail` otherwise.
511
- - `GreaterThan<A, B, Fail=never>`: `A > B` for whole numbers, `Fail` otherwise.
512
-
513
- #### Arithmetic
514
-
515
- - `Add<A, B, Fail=never>`: `A + B` for positive and whole numbers, `Fail` otherwise.
516
- - `Subtract<A, B, Fail=never>`: `A - B` for positive and whole numbers, `Fail` otherwise.
517
- - `Increment<A, Fail=never>`: alias of `Add<A, 1, Fail>`.
518
- - `Decrement<A, Fail=never>`: alias of `Subtract<A, 1, Fail>`.
519
-
520
- ### Tuple
521
-
522
- - [`TupleType`](ts/tuple/readme.md#tupletype)
523
-
524
- ### Utility Functions
525
-
526
- - `amend(subject)...`: amend subject as union or intersect of `T`.
527
- - `facade(subject, ...props)`: create a facade of `subject`.
528
- - `getField(subject, key, defaultValue)`: get a field from a subject. Works against nullable and optional subject.
529
- - `hasKey()`: function of `HasKey`.
530
- - `hasProperty(value, prop)`: assert `value` has property `prop`. This will pick the correct union type.
531
- - `isConstructor(subject)`: type guard `subject` is a constructor.
532
- - `isSystemError(code, err)`: type guard `err` with NodeJS error code.
533
- - `omit(obj, ...props)`: omit properties from `obj`.
534
- - `pick(obj, ...props)`: pick properties from `obj`.
535
- - `record<K, V>(value?)`: create a `Record<K, V>` without extra object prototype.
536
- - `record<R>(value?)`: create a record `R` (e.g. `{ a: number }`) without extra object prototype.
537
- - `required(...)`: merge options and remove `Partial<T>`. From [`unpartial`](https://github.com/unional/unpartial)
538
- - `requiredDeep(...)`: merge options deeply and remove `Partial<T>`. From [`unpartial`](https://github.com/unional/unpartial)
539
- - `split(target, ...splitters)`: split one object into multiple objects.
540
- - `stub<T>(value)`: stub a particular type `T`.
541
- - `stub.build<T>(init?)`: build a stub for particular type `T`.
542
- - `typeOverrideIncompatible<T>()`: override only the incompatible portion between two types.
543
- - `unpartial()`: merge options and remove `Partial<T>` values. From [`unpartial`](https://github.com/unional/unpartial)
1123
+ ## Math
1124
+
1125
+ The math types in `type-plus` works with most numeric types.
1126
+
1127
+ It works with `number` and `bigint`, positive and negative number, including floating point numbers.
1128
+
1129
+ It will cast the type between `number` and `bigint` if needed.
1130
+
1131
+ > `Abs<N, Fail = never>`
1132
+
1133
+ 🔨 `utilities`: `Abs(N)`.
1134
+
1135
+ > `Max<A, B, Fail = never>`
1136
+
1137
+ 🔨 `utilities`: `max(A, B)`
1138
+
1139
+ > `GreaterThan<A, B>`
1140
+
1141
+ 🔨 `utilities`: `A > B`.
1142
+
1143
+ > `Add<A, B>`
1144
+
1145
+ 🔨 `utilities`: `A + B`.
1146
+
1147
+ > `Subtract<A, B>`
1148
+
1149
+ 🔨 `utilities`: `A > B`.
1150
+
1151
+ > `Increment<A>`
1152
+
1153
+ 🔨 `utilities`: alias of `Add<A, 1>`.
1154
+
1155
+ > `Decrement<A>`
1156
+
1157
+ 🔨 `utilities`: alias of `Subtract<A, 1>`.
1158
+
1159
+ > `Multiply<A, B`
1160
+
1161
+ 🔨 `utilities`: `A * B`.
1162
+
1163
+ ## Utility Functions
1164
+
1165
+ > `amend(subject)...`
1166
+
1167
+ 🔨 `utilities`: amend subject as union or intersect of `T`.
1168
+
1169
+ > `facade(subject, ...props)`
1170
+
1171
+ 🔨 `utilities`: create a facade of `subject`.
1172
+
1173
+ > `getField(subject, key, defaultValue)`
1174
+
1175
+ 🔨 `utilities`: get a field from a subject. Works against nullable and optional subject.
1176
+
1177
+ > `hasKey()`
1178
+
1179
+ 🔨 `utilities`: function of `HasKey`.
1180
+
1181
+ > `hasProperty(value, prop)`
1182
+
1183
+ 🔨 `utilities`: assert `value` has property `prop`. This will pick the correct union type.
1184
+
1185
+ > `isConstructor(subject)`
1186
+
1187
+ 🔨 `utilities`: type guard `subject` is a constructor.
1188
+
1189
+ > `isSystemError(code, err)`
1190
+
1191
+ 🔨 `utilities`: type guard `err` with NodeJS error code.
1192
+
1193
+ > `omit(obj, ...props)`
1194
+
1195
+ 🔨 `utilities`: omit properties from `obj`.
1196
+
1197
+ > `pick(obj, ...props)`
1198
+
1199
+ 🔨 `utilities`: pick properties from `obj`.
1200
+
1201
+ > `record<K, V>(value?)`
1202
+
1203
+ 🔨 `utilities`: create a `Record<K, V>` without extra object prototype.
1204
+
1205
+ > `record<R>(value?)`
1206
+
1207
+ 🔨 `utilities`: create a record `R` (e.g. `{ a: number }`) without extra object prototype.
1208
+
1209
+ > `required(...)`
1210
+
1211
+ 🔨 `utilities`: merge options and remove `Partial<T>`. From [`unpartial`](https://github.com/unional/unpartial)
1212
+
1213
+ > `requiredDeep(...)`
1214
+
1215
+ 🔨 `utilities`: merge options deeply and remove `Partial<T>`. From [`unpartial`](https://github.com/unional/unpartial)
1216
+
1217
+ > `split(target, ...splitters)`
1218
+
1219
+ 🔨 `utilities`: split one object into multiple objects.
1220
+
1221
+ > `stub<T>(value)`
1222
+
1223
+ 🔨 `utilities`: stub a particular type `T`.
1224
+
1225
+ > `stub.build<T>(init?)`
1226
+
1227
+ 🔨 `utilities`: build a stub for particular type `T`.
1228
+
1229
+ > `typeOverrideIncompatible<T>()`
1230
+
1231
+ 🔨 `utilities`: override only the incompatible portion between two types.
544
1232
 
545
1233
  ```ts
546
1234
  type A = {
@@ -560,6 +1248,26 @@ const source = {
560
1248
  overrider(source, { foo: !!source.foo })
561
1249
  ```
562
1250
 
1251
+ > `unpartial()`
1252
+
1253
+ 🔨 `utilities`: merge options and remove `Partial<T>` values. From [`unpartial`](https://github.com/unional/unpartial)
1254
+
1255
+ > `context()`
1256
+
1257
+ 🔨 `utilities`: a context builder.
1258
+
1259
+ This is useful to build context for functional programming.
1260
+ It is a sync version of the `AsyncContext` from [async-fp](https://unional/async-fp).
1261
+
1262
+ ```ts
1263
+ import { context } from 'type-plus'
1264
+
1265
+ // { a: 1, b: 2 }
1266
+ const ctx = context({ a: 1 })
1267
+ .extend(c => ({ b: c.a + 1 }))
1268
+ .build()
1269
+ ```
1270
+
563
1271
  ## Nominal Types
564
1272
 
565
1273
  The TypeScript type system is structural.
@@ -610,7 +1318,9 @@ but `Flavor` of the same name cannot be assigned to `Brand`.
610
1318
 
611
1319
  `nominalMatch(a, b)`:
612
1320
 
613
- `nominalMatch()` can be used to compare `Brand` or `Flavor`.
1321
+ 🔨 `utilities`: compare if the two values are nominally equal.
1322
+
1323
+ Works with both `Brand` and `Flavor`.
614
1324
 
615
1325
  ```ts
616
1326
  const b1 = brand('x', 1)
@@ -619,32 +1329,15 @@ const b2 = brand('y', 1)
619
1329
  nominalMatch(b1, b2) // false
620
1330
  ```
621
1331
 
622
- ## Function Utilties
623
-
624
- - `AnyFunction<P, R>`: a generic type for any function
625
- - `ExtractFunction<F>`: extract the function signature from a type `F`.
626
- - `extractFunction(fn: F)`: adjust type of `fn` to its function signature only.
627
- - `inspect<T>(value: T, inspector?: (v: T) => void)`: inspect a value and return it.\
628
- Inspector defaults to `console.dir()`
629
-
630
1332
  ## Functional Types
631
1333
 
632
- - `ChainFn<T>: T`: chain function that returns the input type.
633
- - `compose(...fns): F`: compose functions
1334
+ > `ChainFn<T>: T`
634
1335
 
635
- ## Context Builder
1336
+ 🔨 `utilities`: chain function that returns the input type.
636
1337
 
637
- - `context()`: a context builder. This is useful to build context for functional programming.\
638
- It is a sync version of the `AsyncContext` from [async-fp](https://unional/async-fp).
1338
+ > `compose(...fns): F`
639
1339
 
640
- ```ts
641
- import { context } from 'type-plus'
642
-
643
- // { a: 1, b: 2 }
644
- const ctx = context({ a: 1 })
645
- .extend(c => ({ b: c.a + 1 }))
646
- .build()
647
- ```
1340
+ 🔨 `utilities`: compose functions
648
1341
 
649
1342
  ## Attribution
650
1343
 
@@ -652,6 +1345,10 @@ Some code in this library is created by other people in the TypeScript community
652
1345
  I'm merely adding them in and maybe making some adjustments.
653
1346
  Whenever possible, I add attribution to the person who created those **codes** in the file.
654
1347
 
1348
+ ## Useful Tips
1349
+
1350
+ > <https://github.com/microsoft/TypeScript/wiki/Performance>
1351
+
655
1352
  ## Similar projects
656
1353
 
657
1354
  - [expect-type]: Compile-time tests for types
@@ -694,7 +1391,6 @@ test results immediately as you type, and see the results in
694
1391
  your editor right next to your code.
695
1392
 
696
1393
  [@gcanti]: https://github.com/gcanti
697
- [assertion_function]: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#assertion-functions
698
1394
  [codecov_image]: https://codecov.io/gh/unional/type-plus/branch/master/graph/badge.svg
699
1395
  [codecov_url]: https://codecov.io/gh/unional/type-plus
700
1396
  [downloads_image]: https://img.shields.io/npm/dm/type-plus.svg?style=flat
@@ -708,7 +1404,6 @@ your editor right next to your code.
708
1404
  [ts-essentials]: https://github.com/ts-essentials/ts-essentials
709
1405
  [ts-expect]: https://github.com/TypeStrong/ts-expect
710
1406
  [ts-toolbelt]: https://github.com/millsp/ts-toolbelt
711
- [type_guard]: https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates
712
1407
  [type-fest]: https://github.com/sindresorhus/type-fest
713
1408
  [type-zoo]: https://github.com/pelotom/type-zoo
714
1409
  [typelevel-ts]: https://github.com/gcanti/typelevel-ts
@@ -721,3 +1416,5 @@ your editor right next to your code.
721
1416
  [wallaby_image]: https://img.shields.io/badge/wallaby.js-powered-blue.svg?style=flat&logo=github
722
1417
  [wallaby_image_lg]: https://img.shields.io/badge/wallaby.js-powered-blue.svg?style=for-the-badge&logo=github
723
1418
  [wallaby_url]: https://wallabyjs.com/oss/
1419
+ [assertion_functions]: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#assertion-functions
1420
+ [type_guard]: https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates