type-plus 6.8.1 → 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 (531) hide show
  1. package/README.md +1054 -355
  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/test_type.d.ts +125 -50
  158. package/cjs/testing/test_type.d.ts.map +1 -1
  159. package/cjs/testing/test_type.js +4 -141
  160. package/cjs/testing/test_type.js.map +1 -1
  161. package/cjs/tuple/create_tuple.d.ts +28 -0
  162. package/cjs/tuple/create_tuple.d.ts.map +1 -0
  163. package/cjs/{array → tuple}/create_tuple.js.map +1 -1
  164. package/cjs/tuple/tuple_plus.d.ts +2 -0
  165. package/cjs/tuple/tuple_plus.d.ts.map +1 -0
  166. package/cjs/tuple/tuple_plus.js +18 -0
  167. package/cjs/tuple/tuple_plus.js.map +1 -0
  168. package/cjs/tuple/tuple_plus.pad_start.d.ts +22 -0
  169. package/cjs/tuple/tuple_plus.pad_start.d.ts.map +1 -0
  170. package/cjs/tuple/tuple_plus.pad_start.js +3 -0
  171. package/cjs/tuple/tuple_plus.pad_start.js.map +1 -0
  172. package/cjs/{predicates/isType.d.ts → type-guard/is_type.d.ts} +5 -3
  173. package/cjs/type-guard/is_type.d.ts.map +1 -0
  174. package/cjs/{predicates/isType.js → type-guard/is_type.js} +8 -2
  175. package/cjs/type-guard/is_type.js.map +1 -0
  176. package/esm/array/{array.d.ts → array.at.d.ts} +4 -14
  177. package/esm/array/array.at.d.ts.map +1 -0
  178. package/esm/array/array.at.js +2 -0
  179. package/esm/array/array.at.js.map +1 -0
  180. package/esm/array/array.concat.d.ts +13 -0
  181. package/esm/array/array.concat.d.ts.map +1 -0
  182. package/esm/array/array.concat.js +2 -0
  183. package/esm/array/array.concat.js.map +1 -0
  184. package/esm/array/array.entries.d.ts +17 -0
  185. package/esm/array/array.entries.d.ts.map +1 -0
  186. package/esm/array/array.entries.js +2 -0
  187. package/esm/array/array.entries.js.map +1 -0
  188. package/esm/array/array.find.d.ts +21 -0
  189. package/esm/array/array.find.d.ts.map +1 -0
  190. package/esm/array/array.find.js +2 -0
  191. package/esm/array/array.find.js.map +1 -0
  192. package/esm/array/array.find_last.d.ts +17 -0
  193. package/esm/array/array.find_last.d.ts.map +1 -0
  194. package/esm/array/array.find_last.js +2 -0
  195. package/esm/array/array.find_last.js.map +1 -0
  196. package/esm/array/array.reverse.d.ts +2 -0
  197. package/esm/array/array.reverse.d.ts.map +1 -0
  198. package/esm/array/array.reverse.js +2 -0
  199. package/esm/array/array.reverse.js.map +1 -0
  200. package/esm/array/array.some.d.ts +29 -0
  201. package/esm/array/array.some.d.ts.map +1 -0
  202. package/esm/array/array.some.js +2 -0
  203. package/esm/array/array.some.js.map +1 -0
  204. package/esm/array/array_index.d.ts +8 -8
  205. package/esm/array/array_index.d.ts.map +1 -1
  206. package/esm/array/array_plus.d.ts +9 -1
  207. package/esm/array/array_plus.d.ts.map +1 -1
  208. package/esm/array/array_plus.split_at.d.ts +30 -0
  209. package/esm/array/array_plus.split_at.d.ts.map +1 -0
  210. package/esm/array/array_plus.split_at.js +2 -0
  211. package/esm/array/array_plus.split_at.js.map +1 -0
  212. package/esm/array/drop.d.ts +2 -2
  213. package/esm/array/drop.d.ts.map +1 -1
  214. package/esm/array/index.d.ts +4 -5
  215. package/esm/array/index.d.ts.map +1 -1
  216. package/esm/array/index.js +4 -5
  217. package/esm/array/index.js.map +1 -1
  218. package/esm/array/pad_start.d.ts +32 -0
  219. package/esm/array/pad_start.d.ts.map +1 -0
  220. package/esm/array/pad_start.js +2 -0
  221. package/esm/array/pad_start.js.map +1 -0
  222. package/esm/assertion/assert_type.d.ts +3 -0
  223. package/esm/assertion/assert_type.d.ts.map +1 -1
  224. package/esm/assertion/assert_type.js +3 -0
  225. package/esm/assertion/assert_type.js.map +1 -1
  226. package/esm/bigint/cast.d.ts +10 -0
  227. package/esm/bigint/cast.d.ts.map +1 -0
  228. package/esm/bigint/cast.js +2 -0
  229. package/esm/bigint/cast.js.map +1 -0
  230. package/esm/equal/equal.d.ts +51 -3
  231. package/esm/equal/equal.d.ts.map +1 -1
  232. package/esm/functional/Maybe.d.ts +2 -2
  233. package/esm/functional/Maybe.d.ts.map +1 -1
  234. package/esm/index.d.ts +16 -7
  235. package/esm/index.d.ts.map +1 -1
  236. package/esm/index.js +5 -0
  237. package/esm/index.js.map +1 -1
  238. package/esm/math/abs.d.ts +6 -0
  239. package/esm/math/abs.d.ts.map +1 -0
  240. package/esm/math/abs.js +2 -0
  241. package/esm/math/abs.js.map +1 -0
  242. package/esm/math/add.d.ts +7 -0
  243. package/esm/math/add.d.ts.map +1 -0
  244. package/esm/math/add.js +2 -0
  245. package/esm/math/add.js.map +1 -0
  246. package/esm/math/greater_than.d.ts +4 -0
  247. package/esm/math/greater_than.d.ts.map +1 -0
  248. package/esm/math/greater_than.js +2 -0
  249. package/esm/math/greater_than.js.map +1 -0
  250. package/esm/math/index.d.ts +6 -6
  251. package/esm/math/index.d.ts.map +1 -1
  252. package/esm/math/math_plus.d.ts +5 -0
  253. package/esm/math/math_plus.d.ts.map +1 -0
  254. package/esm/math/math_plus.js +2 -0
  255. package/esm/math/math_plus.js.map +1 -0
  256. package/esm/math/math_plus.to_negative.d.ts +13 -0
  257. package/esm/math/math_plus.to_negative.d.ts.map +1 -0
  258. package/esm/math/math_plus.to_negative.js +2 -0
  259. package/esm/math/math_plus.to_negative.js.map +1 -0
  260. package/esm/math/max.d.ts +4 -0
  261. package/esm/math/max.d.ts.map +1 -0
  262. package/esm/math/max.js +2 -0
  263. package/esm/math/max.js.map +1 -0
  264. package/esm/math/multiply.d.ts +6 -0
  265. package/esm/math/multiply.d.ts.map +1 -0
  266. package/esm/math/multiply.js +2 -0
  267. package/esm/math/multiply.js.map +1 -0
  268. package/esm/math/numeric_struct.d.ts +1469 -0
  269. package/esm/math/numeric_struct.d.ts.map +1 -0
  270. package/esm/math/numeric_struct.js +2 -0
  271. package/esm/math/numeric_struct.js.map +1 -0
  272. package/esm/math/subtract.d.ts +7 -0
  273. package/esm/math/subtract.d.ts.map +1 -0
  274. package/esm/math/subtract.js +2 -0
  275. package/esm/math/subtract.js.map +1 -0
  276. package/esm/nominal/brand.js +1 -1
  277. package/esm/nominal/brand.js.map +1 -1
  278. package/esm/nominal/flavor.js +1 -1
  279. package/esm/nominal/flavor.js.map +1 -1
  280. package/esm/number/cast.d.ts +10 -0
  281. package/esm/number/cast.d.ts.map +1 -0
  282. package/esm/number/cast.js +2 -0
  283. package/esm/number/cast.js.map +1 -0
  284. package/esm/number/number_array.d.ts +1 -2
  285. package/esm/number/number_array.d.ts.map +1 -1
  286. package/esm/number/number_array.js +14 -0
  287. package/esm/number/number_array.js.map +1 -1
  288. package/esm/number/number_plus.d.ts +4 -5
  289. package/esm/number/number_plus.d.ts.map +1 -1
  290. package/esm/number/strict_number_type.d.ts +12 -0
  291. package/esm/number/strict_number_type.d.ts.map +1 -1
  292. package/esm/numeric/cast.d.ts +27 -0
  293. package/esm/numeric/cast.d.ts.map +1 -0
  294. package/esm/numeric/cast.js +2 -0
  295. package/esm/numeric/cast.js.map +1 -0
  296. package/{cjs/number → esm/numeric}/integer.d.ts +2 -0
  297. package/esm/numeric/integer.d.ts.map +1 -0
  298. package/esm/{number → numeric}/integer.js.map +1 -1
  299. package/esm/numeric/negative.d.ts.map +1 -0
  300. package/esm/{number → numeric}/negative.js.map +1 -1
  301. package/esm/numeric/numeric_plus.d.ts +5 -0
  302. package/esm/numeric/numeric_plus.d.ts.map +1 -0
  303. package/esm/numeric/numeric_plus.js +2 -0
  304. package/esm/numeric/numeric_plus.js.map +1 -0
  305. package/esm/numeric/numeric_type.d.ts.map +1 -0
  306. package/esm/{number → numeric}/numeric_type.js.map +1 -1
  307. package/esm/{number → numeric}/positive.d.ts +2 -2
  308. package/esm/numeric/positive.d.ts.map +1 -0
  309. package/esm/{number → numeric}/positive.js.map +1 -1
  310. package/esm/object/ANotB.d.ts +3 -3
  311. package/esm/object/ANotB.d.ts.map +1 -1
  312. package/esm/object/Partial.d.ts +6 -0
  313. package/esm/object/Partial.d.ts.map +1 -1
  314. package/esm/object/Required.d.ts +4 -0
  315. package/esm/object/Required.d.ts.map +1 -1
  316. package/esm/object/index.d.ts +1 -1
  317. package/esm/object/index.d.ts.map +1 -1
  318. package/esm/object/object_type.d.ts +1 -1
  319. package/esm/object/split.d.ts +3 -1
  320. package/esm/object/split.d.ts.map +1 -1
  321. package/esm/object/split.js.map +1 -1
  322. package/esm/predicates/CanAssign.d.ts +35 -0
  323. package/esm/predicates/CanAssign.d.ts.map +1 -1
  324. package/esm/predicates/CanAssign.js.map +1 -1
  325. package/esm/predicates/Extends.d.ts +2 -2
  326. package/esm/predicates/Extends.d.ts.map +1 -1
  327. package/esm/predicates/index.d.ts +0 -1
  328. package/esm/predicates/index.d.ts.map +1 -1
  329. package/esm/predicates/index.js +0 -1
  330. package/esm/predicates/index.js.map +1 -1
  331. package/esm/testing/test_type.d.ts +125 -50
  332. package/esm/testing/test_type.d.ts.map +1 -1
  333. package/esm/testing/test_type.js +4 -141
  334. package/esm/testing/test_type.js.map +1 -1
  335. package/esm/tuple/create_tuple.d.ts +28 -0
  336. package/esm/tuple/create_tuple.d.ts.map +1 -0
  337. package/esm/{array → tuple}/create_tuple.js.map +1 -1
  338. package/esm/tuple/tuple_plus.d.ts +2 -0
  339. package/esm/tuple/tuple_plus.d.ts.map +1 -0
  340. package/esm/tuple/tuple_plus.js +2 -0
  341. package/esm/tuple/tuple_plus.js.map +1 -0
  342. package/esm/tuple/tuple_plus.pad_start.d.ts +22 -0
  343. package/esm/tuple/tuple_plus.pad_start.d.ts.map +1 -0
  344. package/esm/tuple/tuple_plus.pad_start.js +2 -0
  345. package/esm/tuple/tuple_plus.pad_start.js.map +1 -0
  346. package/esm/{predicates/isType.d.ts → type-guard/is_type.d.ts} +5 -3
  347. package/esm/type-guard/is_type.d.ts.map +1 -0
  348. package/esm/{predicates/isType.js → type-guard/is_type.js} +8 -2
  349. package/esm/type-guard/is_type.js.map +1 -0
  350. package/package.json +1 -1
  351. package/ts/array/{array.ts → array.at.ts} +10 -15
  352. package/ts/array/array.concat.ts +12 -0
  353. package/ts/array/array.entries.ts +24 -0
  354. package/ts/array/array.find.ts +32 -0
  355. package/ts/array/array.find_last.ts +27 -0
  356. package/ts/array/array.reverse.ts +16 -0
  357. package/ts/array/array.some.ts +53 -0
  358. package/ts/array/array_index.ts +16 -10
  359. package/ts/array/array_plus.split_at.ts +47 -0
  360. package/ts/array/array_plus.ts +9 -1
  361. package/ts/array/drop.ts +2 -2
  362. package/ts/array/index.ts +4 -5
  363. package/ts/array/pad_start.ts +43 -0
  364. package/ts/array/readme.md +184 -4
  365. package/ts/assertion/assert_type.ts +6 -0
  366. package/ts/assertion/readme.md +132 -1
  367. package/ts/bigint/cast.ts +13 -0
  368. package/ts/bigint/readme.md +17 -17
  369. package/ts/equal/equal.ts +53 -3
  370. package/ts/equal/readme.md +30 -16
  371. package/ts/functional/Maybe.ts +2 -2
  372. package/ts/index.ts +22 -24
  373. package/ts/math/README.md +97 -7
  374. package/ts/math/abs.ts +18 -0
  375. package/ts/math/add.ts +14 -0
  376. package/ts/math/greater_than.ts +12 -0
  377. package/ts/math/index.ts +7 -6
  378. package/ts/math/math_plus.to_negative.ts +22 -0
  379. package/ts/math/math_plus.ts +4 -0
  380. package/ts/math/max.ts +13 -0
  381. package/ts/math/multiply.ts +12 -0
  382. package/ts/math/numeric_struct.ts +658 -0
  383. package/ts/math/subtract.ts +14 -0
  384. package/ts/nominal/brand.ts +1 -1
  385. package/ts/nominal/flavor.ts +1 -1
  386. package/ts/number/cast.ts +17 -0
  387. package/ts/number/number_array.ts +14 -14
  388. package/ts/number/number_plus.ts +6 -6
  389. package/ts/number/readme.md +0 -108
  390. package/ts/number/strict_number_type.ts +12 -0
  391. package/ts/numeric/cast.ts +28 -0
  392. package/ts/{number → numeric}/integer.ts +2 -0
  393. package/ts/numeric/numeric_plus.ts +12 -0
  394. package/ts/{number → numeric}/positive.ts +2 -2
  395. package/ts/numeric/readme.md +115 -0
  396. package/ts/object/ANotB.ts +3 -3
  397. package/ts/object/Partial.ts +5 -0
  398. package/ts/object/Required.ts +4 -0
  399. package/ts/object/index.ts +1 -1
  400. package/ts/object/object_type.ts +1 -1
  401. package/ts/object/split.ts +3 -1
  402. package/ts/predicates/CanAssign.ts +46 -0
  403. package/ts/predicates/Extends.ts +2 -2
  404. package/ts/predicates/index.ts +0 -1
  405. package/ts/testing/test_type.ts +131 -88
  406. package/ts/tuple/create_tuple.ts +42 -0
  407. package/ts/tuple/tuple_plus.pad_start.ts +42 -0
  408. package/ts/tuple/tuple_plus.ts +1 -0
  409. package/ts/{predicates/isType.ts → type-guard/is_type.ts} +11 -3
  410. package/ts/type-guard/readme.md +37 -0
  411. package/cjs/array/array.d.ts.map +0 -1
  412. package/cjs/array/array.js.map +0 -1
  413. package/cjs/array/create_tuple.d.ts +0 -11
  414. package/cjs/array/create_tuple.d.ts.map +0 -1
  415. package/cjs/array/find_first.d.ts +0 -6
  416. package/cjs/array/find_first.d.ts.map +0 -1
  417. package/cjs/array/find_first.js.map +0 -1
  418. package/cjs/array/find_last.d.ts +0 -2
  419. package/cjs/array/find_last.d.ts.map +0 -1
  420. package/cjs/array/find_last.js.map +0 -1
  421. package/cjs/array/pad_left.d.ts +0 -6
  422. package/cjs/array/pad_left.d.ts.map +0 -1
  423. package/cjs/array/pad_left.js.map +0 -1
  424. package/cjs/array/some.d.ts +0 -8
  425. package/cjs/array/some.d.ts.map +0 -1
  426. package/cjs/array/some.js.map +0 -1
  427. package/cjs/math/Abs.d.ts +0 -3
  428. package/cjs/math/Abs.d.ts.map +0 -1
  429. package/cjs/math/Abs.js.map +0 -1
  430. package/cjs/math/Add.d.ts +0 -19
  431. package/cjs/math/Add.d.ts.map +0 -1
  432. package/cjs/math/Add.js.map +0 -1
  433. package/cjs/math/Digit.d.ts +0 -100
  434. package/cjs/math/Digit.d.ts.map +0 -1
  435. package/cjs/math/Digit.js +0 -3
  436. package/cjs/math/Digit.js.map +0 -1
  437. package/cjs/math/GreaterThan.d.ts +0 -13
  438. package/cjs/math/GreaterThan.d.ts.map +0 -1
  439. package/cjs/math/GreaterThan.js +0 -3
  440. package/cjs/math/GreaterThan.js.map +0 -1
  441. package/cjs/math/Max.d.ts +0 -4
  442. package/cjs/math/Max.d.ts.map +0 -1
  443. package/cjs/math/Max.js.map +0 -1
  444. package/cjs/math/Subtract.d.ts +0 -19
  445. package/cjs/math/Subtract.d.ts.map +0 -1
  446. package/cjs/math/Subtract.js +0 -3
  447. package/cjs/math/Subtract.js.map +0 -1
  448. package/cjs/number/integer.d.ts.map +0 -1
  449. package/cjs/number/negative.d.ts.map +0 -1
  450. package/cjs/number/numeric_type.d.ts.map +0 -1
  451. package/cjs/number/positive.d.ts.map +0 -1
  452. package/cjs/predicates/isType.d.ts.map +0 -1
  453. package/cjs/predicates/isType.js.map +0 -1
  454. package/esm/array/array.d.ts.map +0 -1
  455. package/esm/array/array.js +0 -2
  456. package/esm/array/array.js.map +0 -1
  457. package/esm/array/create_tuple.d.ts +0 -11
  458. package/esm/array/create_tuple.d.ts.map +0 -1
  459. package/esm/array/find_first.d.ts +0 -6
  460. package/esm/array/find_first.d.ts.map +0 -1
  461. package/esm/array/find_first.js +0 -2
  462. package/esm/array/find_first.js.map +0 -1
  463. package/esm/array/find_last.d.ts +0 -2
  464. package/esm/array/find_last.d.ts.map +0 -1
  465. package/esm/array/find_last.js +0 -2
  466. package/esm/array/find_last.js.map +0 -1
  467. package/esm/array/pad_left.d.ts +0 -6
  468. package/esm/array/pad_left.d.ts.map +0 -1
  469. package/esm/array/pad_left.js +0 -2
  470. package/esm/array/pad_left.js.map +0 -1
  471. package/esm/array/some.d.ts +0 -8
  472. package/esm/array/some.d.ts.map +0 -1
  473. package/esm/array/some.js +0 -2
  474. package/esm/array/some.js.map +0 -1
  475. package/esm/math/Abs.d.ts +0 -3
  476. package/esm/math/Abs.d.ts.map +0 -1
  477. package/esm/math/Abs.js +0 -2
  478. package/esm/math/Abs.js.map +0 -1
  479. package/esm/math/Add.d.ts +0 -19
  480. package/esm/math/Add.d.ts.map +0 -1
  481. package/esm/math/Add.js +0 -2
  482. package/esm/math/Add.js.map +0 -1
  483. package/esm/math/Digit.d.ts +0 -100
  484. package/esm/math/Digit.d.ts.map +0 -1
  485. package/esm/math/Digit.js +0 -2
  486. package/esm/math/Digit.js.map +0 -1
  487. package/esm/math/GreaterThan.d.ts +0 -13
  488. package/esm/math/GreaterThan.d.ts.map +0 -1
  489. package/esm/math/GreaterThan.js +0 -2
  490. package/esm/math/GreaterThan.js.map +0 -1
  491. package/esm/math/Max.d.ts +0 -4
  492. package/esm/math/Max.d.ts.map +0 -1
  493. package/esm/math/Max.js +0 -2
  494. package/esm/math/Max.js.map +0 -1
  495. package/esm/math/Subtract.d.ts +0 -19
  496. package/esm/math/Subtract.d.ts.map +0 -1
  497. package/esm/math/Subtract.js +0 -2
  498. package/esm/math/Subtract.js.map +0 -1
  499. package/esm/number/integer.d.ts.map +0 -1
  500. package/esm/number/negative.d.ts.map +0 -1
  501. package/esm/number/numeric_type.d.ts.map +0 -1
  502. package/esm/number/positive.d.ts.map +0 -1
  503. package/esm/predicates/isType.d.ts.map +0 -1
  504. package/esm/predicates/isType.js.map +0 -1
  505. package/ts/array/create_tuple.ts +0 -17
  506. package/ts/array/find_first.ts +0 -16
  507. package/ts/array/find_last.ts +0 -11
  508. package/ts/array/pad_left.ts +0 -16
  509. package/ts/array/some.ts +0 -33
  510. package/ts/math/Abs.ts +0 -7
  511. package/ts/math/Add.ts +0 -58
  512. package/ts/math/Digit.ts +0 -152
  513. package/ts/math/GreaterThan.ts +0 -55
  514. package/ts/math/Max.ts +0 -10
  515. package/ts/math/Subtract.ts +0 -57
  516. /package/cjs/{number → numeric}/integer.js +0 -0
  517. /package/cjs/{number → numeric}/negative.d.ts +0 -0
  518. /package/cjs/{number → numeric}/negative.js +0 -0
  519. /package/cjs/{number → numeric}/numeric_type.d.ts +0 -0
  520. /package/cjs/{number → numeric}/numeric_type.js +0 -0
  521. /package/cjs/{number → numeric}/positive.js +0 -0
  522. /package/cjs/{array → tuple}/create_tuple.js +0 -0
  523. /package/esm/{number → numeric}/integer.js +0 -0
  524. /package/esm/{number → numeric}/negative.d.ts +0 -0
  525. /package/esm/{number → numeric}/negative.js +0 -0
  526. /package/esm/{number → numeric}/numeric_type.d.ts +0 -0
  527. /package/esm/{number → numeric}/numeric_type.js +0 -0
  528. /package/esm/{number → numeric}/positive.js +0 -0
  529. /package/esm/{array → tuple}/create_tuple.js +0 -0
  530. /package/ts/{number → numeric}/negative.ts +0 -0
  531. /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,71 +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
- ## Type Utilities
332
+ ### any
331
333
 
332
- `type-plus` also provides additional type utilities.
333
- These utilities include utility types and type-adjusted functions.
334
+ > [`AnyType<T>`](./ts/any/readme.md#type-checking)
334
335
 
335
- Note that most `predicate` types (such as `IsAny<>`) have a `Then` and `Else` that you can override.
336
+ ↪️ `parse`: `T === any`.
336
337
 
337
- e.g.:
338
+ > [`IsAny<T>`](./ts/any/readme.md#type-checking)
338
339
 
339
- ```ts
340
- type Yes = IsAny<any, 'yes', 'no'> // 'yes'
341
- type No = IsAny<1, 'yes', 'no'> // 'no'
342
- ```
340
+ ⭕ `predicate`: `T === any`.
341
+
342
+ > [`NotAnyType<T>`](./ts/any/readme.md#type-checking)
343
+
344
+ ↪️ `parse`: `T !== any`.
345
+
346
+ > [`IsNotAny<T>`](./ts/any/readme.md#type-checking)
343
347
 
344
- ### Any
348
+ `predicate`: `T !== any`.
345
349
 
346
- - [`AnyType<T, Then = T, Else = never>`](ts/any_plus/any.ts#L14): `T === any`.
347
- - [`IsAny<T, Then = true, Else = false>`](ts/any_plus/any.ts#L29): `T === any` (origin: [ts-essentials]).
350
+ > [`IsAnyOrNever<T>`](./ts/any/readme.md#type-utilities)
351
+
352
+ ⭕ `predicate`: `T === any || T === never`.
348
353
 
349
354
  ### Array
350
355
 
351
- - [`At<A, N, Fail = never>`](ts/array_plus/array.ts#L19): gets the element type at index `N` in the array `A`.
352
- - `CommonPropKeys<A>`: gets common keys inside the records in the array `A` (deprecate `CommonKeys`).
353
- - [`Concat<A, B>`](ts/array_plus/array.ts#L38): `[...A, ...B]`.
354
- - `CreateTuple<L, T>`: Creates `Tuple<T>` with `L` number of elements.
355
- - `drop(array, value)`: drop a particular value from an array.
356
- - `DropFirst<A>`: drops the first value type of `A`.
357
- - `DropLast<A>`: drops the last value type of `A`.
358
- - `DropMatch<A, Criteria>`: drops entries matching `Criteria` in array or tuple `A`.
359
- - `DropUndefined<A>`: drop undefined entries from array of tuple `A`.
360
- - `Filter<A, Criteria>`: filter the array or tuple `A`, keeping entries satisfying `Criteria`. **Deprecated. Renaming to `KeepMatch`**
361
- - `FindFirst<A, Criteria>`: gets the first type satisfying `Criteria`.
362
- - `FindLast<A, Criteria>`: gets the last type satisfying `Criteria`.
363
- - `Head<A>`: gets the first entry in the array.
364
- - `IntersectOfProps<A, K>`: gets the intersect of `A[K]` types (deprecate `MapToProp`)
365
- - `IsArray<T>`: `logical` predicate for `Array`.
366
- - `KeepMatch<A, Criteria>`: keeps entries satisfying `Criteria` in array or tuple `A`.
367
- - `Last<A>`: gets the last type of array or tuple.
368
- - `literalArray(...entries)`: return an array whose items are restricted to the provided literals.
369
- - `PadLeft<A, Total, PadWith>`: pads `A` with `PadWith` if the length of `A` is less than `L`.
370
- - `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. \
371
447
  A simple version of the same function in the `ramda` package.
372
- - `Reverse<A>`: reverses the order of `A`.
373
- - `Some<A, Criteria>`: true if some elements in `A` matches `Criteria`.
374
- - `Tail<A>`: Gets the types of a tuple except the first entry.
375
- - `UnionOfProps<A, K>`: gets the union of `A[K]` types (deprecate `PropUnion`).
376
- - `UnionOfValues<A>`: gets the union of value types in `A` (deprecate `ArrayValue`).
377
- - [`ArrayPlus.IndexAt<A, N, Fail = never>`](ts/array_plus/array_plus.ts#L23): gets the normalized index for `A`.
378
- - [`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.
379
- - [`ArrayType<T, Then = N, Else = never>`](ts/array_plus/array.ts#L48): Is the type `T` exactly an array and not a tuple.
380
-
381
- ### Constant Types
382
-
383
- - `KeyTypes`: type of all keys.
384
- - `PrimitiveTypes`: all primitive types, including `Function`, `symbol`, and `bigint`.
385
- - `ComposableTypes`: Types that can contain custom properties. i.e. `object`, `array`, `function`.
386
- - `NonComposableTypes`: Types that cannot contain custom properties. i.e. not composable.
387
-
388
- ### JSON Support
389
-
390
- - `JSONPrimitive`: primitive types valid in JSON
391
- - `JSONObject`: JSON object
392
- - `JSONArray`: JSON array
393
- - `JSONTypes`: all JSON compatible types.
394
- - `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
395
926
 
396
927
  ```ts
397
928
  import { JSONTypes } from 'type-plus'
@@ -401,144 +932,303 @@ const someJson: JSONTypes = { a: { b: ['z', { c: 'miku' }]}}
401
932
  JSONTypes.get<string>(someJson, 'a', 'b', 1, 'c') // miku
402
933
  ```
403
934
 
404
- ### Object utilities
405
-
406
- - `filterKey()`: type adjusted filter by key.
407
- - `findKey()`: type adjusted find by key.
408
- - `forEachKey()`: type adjusted for each by key.
409
- - `HasKey<T, K>`: predicate type checking `T` has key `K`.
410
- - `hasKey()`: function of `HasKey`.
411
- - `IsRecord<T>`: `logical` predicate for `Record`.
412
- - `KeysWithDiffTypes<A, B>`: gets the keys common in `A` and `B` but with different value type.
413
- - `mapKey()`: type adjusted map by key.
414
- - `RecordValue<R>`: gets the value type `T`from `Record<any, T>` [video](https://www.youtube.com/watch?v=1J7xK6FUqPw).
415
- - `reduceByKey()`: type adjusted reduce by key.
416
- - `someKey()`: type adjusted some by key.
417
- - `SpreadRecord<A, B>`: type for `{...a, ...b}` when both `a` and `b` are `Record`\
418
- for array, just do `[...A, ...B]`.
935
+ ## Type manipulation
419
936
 
420
- ### Promise utilities
937
+ > `ANotB<A, B>`
421
938
 
422
- - `AwaitedProp<T, V>`: `Awaited` on specified props `P` in `T`.
423
- - `isPromise<R>(subject: any)`: `isPromise()` type guard.
424
- - `MaybePromise<T>`: Alias of `T | Promise<T>`.
425
- - `PromiseValue<P>`: Gets the type within the Promise.
426
- - `PromiseValueMerge<P1, P2, ...P9>`: Merge the values of multiple promises.
427
- - `mapSeries()`: Similar to `bluebird.mapSeries()` but works with `async`/`await`.
428
- - `transformMaybePromise(value, transformer)`: Apply the `transformer` to the `value`.\
429
- 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>`
430
1022
 
431
- ### Type manipulation
432
-
433
- - `ANotB<A, B>`: get object with properties in `A` and not in `B`, including properties with a different value type.
434
- - `BNotA<A, B>`: flip of `ANotB`
435
- - `as<T>(subject)`: assert `subject` as `T`. Avoid ASI issues such as `;(x as T).abc`
436
- - `asAny(subject)`: assert `subject` as `any`. Avoid ASI issue such as `;(x as any).abc`
437
- - `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`.
438
- - `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).
439
- - `Except<T, K>`: Deprecated. Same as `Omit<T, K>`.
440
- - `ExcludePropType<T, U>`: excludes type `U` from properties in `T`.
441
- - `KeyofOptional<T>`: `keyof` that works with `Record<any, any> | undefined`.
442
- - `KnownKeys<T>`: extract known (defined) keys from type `T`.
443
- - `LeftJoin<A, B>`: left join `A` with `B`
444
- - `NonNull<T>`: remove `null`
445
- - `NonUndefined<T>`: remove `undefined`
446
- - `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>`.
447
- - `OptionalKeys<T>`: gets keys of optional properties in `T`.
448
- - `PartialExcept<T, U>`: Deprecated. Same as `PartialOmit<T, U>`.
449
- - `PartialOmit<T, U>`: makes the properties not specified in `U` becomes optional.
450
- - `PartialPick<T, U>`: makes the properties specified in `U` becomes optional.
451
- - `Pick<T, K>`: pick properties `K` from `T`. Works with unions.
452
- - `RecursivePartial<T>`: make type `T` optional recursively.
453
- - `RecursiveRequired<T>`: make type `T` required recursively.
454
- - `ReplaceProperty<T, K, V>`: replace property `K` in `T` with `V`.
455
- - `RequiredKeys<T>`: gets keys of required properties in `T`.
456
- - `RequiredPick<T, U>`: makes the properties specified in `U` become required.
457
- - `RequiredExcept<T, U>`: makes the properties not specified in `U` become required.
458
- - `RecursiveIntersect<T, U>`: intersect type `U` onto `T` recursively.
459
- - `ValueOf<T>`: type of the value of the properties of `T`.
460
- - `Widen<T>`: widen literal types.
461
- - PropType: ...no helper type for this. Just do `YourType['propName']`.
462
-
463
- ### Type Predicates
1023
+ 🔨 `utilities`: make type `T` optional recursively.
1024
+
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
464
1062
 
465
1063
  Type predicates are type alias that returns `true` or `false`.
466
1064
  They can be used to compose complex types.
467
1065
 
468
- - `HasKey<T, K>`: predicate type checking `T` has key `K`.
469
- - `IsAny<T>`: `T === any` (updated to impl: [expect-type]).
470
- - `IsBoolean<T>`: check for `boolean`, but not for `true` nor `false`.
471
- - `IsDisjoint<A, B>`: is `A` and `B` is a disjoint set.
472
- - `IsEmptyObject<T>`: is `T === {}`.
473
- - `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
474
1091
 
475
- #### Logical
1092
+ > `If<Condition, Then = true, Else = false>`
476
1093
 
477
- - `If<Condition, Then = true, Else = false>`: if statement.
478
- - `And<A, B, Then = true, Else = false>`: logical `AND`.
479
- - `Or<A, B, Then = true, Else = false>`: logical `OR`.
480
- - `Xor<A, B, Then = true, Else = false>`: logical `XOR`.
481
- - `Not<X, Then = true, Else = false>`: logical `NOT`.
1094
+ 🔨 `utilities`: if statement
1095
+
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`
482
1111
 
483
1112
  Note that these types work correctly with the `boolean` type.
484
1113
  e.g.:
485
1114
 
486
- - `And<boolean, true> -> boolean`
487
- - `Not<boolean> -> boolean`
1115
+ ```ts
1116
+ type R = And<boolean, true> // boolean
1117
+ type R = Not<boolean> // boolean`
1118
+ ```
488
1119
 
489
1120
  There is a problem with generic distribution: <https://github.com/microsoft/TypeScript/issues/41053>
490
1121
  So you may encounter some weird behavior if your logic is complex.
491
1122
 
492
- ### Number
493
-
494
- - [`Numeric`](ts/number_plus/number.ts#L4): either `number` or `bigint` (origin: [type-fest]).
495
- - [`Zero`](ts/number_plus/number.ts#L9): `0` in `number` or `bigint` (origin: [type-fest]).
496
- - [`Integer<N, Then = N, Else = never>`](ts/number_plus/number.ts#L27): is integer (origin: [type-fest]).
497
- - [`IsInteger<N, Then = true, Else = false>`](ts/number_plus/number.ts#L46): is integer.
498
- - [`IsWhole<N, Then = true, Else = false>`](ts/number_plus/number.ts#L62): is integer.
499
- - [`Negative<N, Then = N, Else = never>`](ts/number_plus/number.ts#L77): is negative (origin: [type-fest]).
500
- - [`NonNegative<N, Then = N, Else = never>`](ts/number_plus/number.ts#L96): is non-negative (origin: [type-fest])
501
- - [`NumberType<T, Then = N, Else = never>`](ts/number_plus/number.ts#L108): Is the type `T` exactly `number`.
502
- - [`Positive<N, Then = N, Else = never>`](ts/number_plus/number.ts#L124): is positive.
503
- - [`IsPositive<N, Then = N, Else = never>`](ts/number_plus/number.ts#L144): is positive.
504
-
505
- ### Math
506
-
507
- - `Abs<N, Fail=never>`: `Abs(N)`, `Abs<number>` returns `Fail`.
508
- - `Max<A, B, Fail=never>`: `max(A, B)`, for whole number, `Fail` otherwise.
509
- - `GreaterThan<A, B, Fail=never>`: `A > B` for whole numbers, `Fail` otherwise.
510
-
511
- #### Arithmetic
512
-
513
- - `Add<A, B, Fail=never>`: `A + B` for positive and whole numbers, `Fail` otherwise.
514
- - `Subtract<A, B, Fail=never>`: `A - B` for positive and whole numbers, `Fail` otherwise.
515
- - `Increment<A, Fail=never>`: alias of `Add<A, 1, Fail>`.
516
- - `Decrement<A, Fail=never>`: alias of `Subtract<A, 1, Fail>`.
517
-
518
- ### Tuple
519
-
520
- - [`TupleType`](ts/tuple/readme.md#tupletype)
521
-
522
- ### Utility Functions
523
-
524
- - `amend(subject)...`: amend subject as union or intersect of `T`.
525
- - `facade(subject, ...props)`: create a facade of `subject`.
526
- - `getField(subject, key, defaultValue)`: get a field from a subject. Works against nullable and optional subject.
527
- - `hasKey()`: function of `HasKey`.
528
- - `hasProperty(value, prop)`: assert `value` has property `prop`. This will pick the correct union type.
529
- - `isConstructor(subject)`: type guard `subject` is a constructor.
530
- - `isSystemError(code, err)`: type guard `err` with NodeJS error code.
531
- - `omit(obj, ...props)`: omit properties from `obj`.
532
- - `pick(obj, ...props)`: pick properties from `obj`.
533
- - `record<K, V>(value?)`: create a `Record<K, V>` without extra object prototype.
534
- - `record<R>(value?)`: create a record `R` (e.g. `{ a: number }`) without extra object prototype.
535
- - `required(...)`: merge options and remove `Partial<T>`. From [`unpartial`](https://github.com/unional/unpartial)
536
- - `requiredDeep(...)`: merge options deeply and remove `Partial<T>`. From [`unpartial`](https://github.com/unional/unpartial)
537
- - `split(target, ...splitters)`: split one object into multiple objects.
538
- - `stub<T>(value)`: stub a particular type `T`.
539
- - `stub.build<T>(init?)`: build a stub for particular type `T`.
540
- - `typeOverrideIncompatible<T>()`: override only the incompatible portion between two types.
541
- - `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.
542
1232
 
543
1233
  ```ts
544
1234
  type A = {
@@ -558,6 +1248,26 @@ const source = {
558
1248
  overrider(source, { foo: !!source.foo })
559
1249
  ```
560
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
+
561
1271
  ## Nominal Types
562
1272
 
563
1273
  The TypeScript type system is structural.
@@ -608,7 +1318,9 @@ but `Flavor` of the same name cannot be assigned to `Brand`.
608
1318
 
609
1319
  `nominalMatch(a, b)`:
610
1320
 
611
- `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`.
612
1324
 
613
1325
  ```ts
614
1326
  const b1 = brand('x', 1)
@@ -617,32 +1329,15 @@ const b2 = brand('y', 1)
617
1329
  nominalMatch(b1, b2) // false
618
1330
  ```
619
1331
 
620
- ## Function Utilties
621
-
622
- - `AnyFunction<P, R>`: a generic type for any function
623
- - `ExtractFunction<F>`: extract the function signature from a type `F`.
624
- - `extractFunction(fn: F)`: adjust type of `fn` to its function signature only.
625
- - `inspect<T>(value: T, inspector?: (v: T) => void)`: inspect a value and return it.\
626
- Inspector defaults to `console.dir()`
627
-
628
1332
  ## Functional Types
629
1333
 
630
- - `ChainFn<T>: T`: chain function that returns the input type.
631
- - `compose(...fns): F`: compose functions
1334
+ > `ChainFn<T>: T`
632
1335
 
633
- ## Context Builder
1336
+ 🔨 `utilities`: chain function that returns the input type.
634
1337
 
635
- - `context()`: a context builder. This is useful to build context for functional programming.\
636
- It is a sync version of the `AsyncContext` from [async-fp](https://unional/async-fp).
1338
+ > `compose(...fns): F`
637
1339
 
638
- ```ts
639
- import { context } from 'type-plus'
640
-
641
- // { a: 1, b: 2 }
642
- const ctx = context({ a: 1 })
643
- .extend(c => ({ b: c.a + 1 }))
644
- .build()
645
- ```
1340
+ 🔨 `utilities`: compose functions
646
1341
 
647
1342
  ## Attribution
648
1343
 
@@ -650,6 +1345,10 @@ Some code in this library is created by other people in the TypeScript community
650
1345
  I'm merely adding them in and maybe making some adjustments.
651
1346
  Whenever possible, I add attribution to the person who created those **codes** in the file.
652
1347
 
1348
+ ## Useful Tips
1349
+
1350
+ > <https://github.com/microsoft/TypeScript/wiki/Performance>
1351
+
653
1352
  ## Similar projects
654
1353
 
655
1354
  - [expect-type]: Compile-time tests for types
@@ -692,7 +1391,6 @@ test results immediately as you type, and see the results in
692
1391
  your editor right next to your code.
693
1392
 
694
1393
  [@gcanti]: https://github.com/gcanti
695
- [assertion_function]: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#assertion-functions
696
1394
  [codecov_image]: https://codecov.io/gh/unional/type-plus/branch/master/graph/badge.svg
697
1395
  [codecov_url]: https://codecov.io/gh/unional/type-plus
698
1396
  [downloads_image]: https://img.shields.io/npm/dm/type-plus.svg?style=flat
@@ -706,7 +1404,6 @@ your editor right next to your code.
706
1404
  [ts-essentials]: https://github.com/ts-essentials/ts-essentials
707
1405
  [ts-expect]: https://github.com/TypeStrong/ts-expect
708
1406
  [ts-toolbelt]: https://github.com/millsp/ts-toolbelt
709
- [type_guard]: https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates
710
1407
  [type-fest]: https://github.com/sindresorhus/type-fest
711
1408
  [type-zoo]: https://github.com/pelotom/type-zoo
712
1409
  [typelevel-ts]: https://github.com/gcanti/typelevel-ts
@@ -719,3 +1416,5 @@ your editor right next to your code.
719
1416
  [wallaby_image]: https://img.shields.io/badge/wallaby.js-powered-blue.svg?style=flat&logo=github
720
1417
  [wallaby_image_lg]: https://img.shields.io/badge/wallaby.js-powered-blue.svg?style=for-the-badge&logo=github
721
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