pull-request-split-advisor 3.1.2

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 (375) hide show
  1. package/LICENSE +52 -0
  2. package/README.md +168 -0
  3. package/dist/ai/config-wizard.js +282 -0
  4. package/dist/ai/enricher.js +290 -0
  5. package/dist/ai/prompts.js +231 -0
  6. package/dist/ai/provider.js +265 -0
  7. package/dist/cli.js +442 -0
  8. package/dist/config/config.js +315 -0
  9. package/dist/config/default-config.js +223 -0
  10. package/dist/core/blocks.js +145 -0
  11. package/dist/core/commit-planner.js +273 -0
  12. package/dist/core/dependency.js +284 -0
  13. package/dist/core/file-stats.js +341 -0
  14. package/dist/core/history.js +72 -0
  15. package/dist/core/planner.js +25 -0
  16. package/dist/core/scoring.js +166 -0
  17. package/dist/core/strategy.js +486 -0
  18. package/dist/git/branch-naming.js +120 -0
  19. package/dist/git/executor.js +378 -0
  20. package/dist/git/git.js +239 -0
  21. package/dist/output/report-styles.generated.js +10 -0
  22. package/dist/output/report.js +726 -0
  23. package/dist/output/ui.js +417 -0
  24. package/dist/shared/constants.js +59 -0
  25. package/dist/shared/types.js +7 -0
  26. package/dist/shared/utils.js +73 -0
  27. package/node_modules/@colors/colors/LICENSE +26 -0
  28. package/node_modules/@colors/colors/README.md +219 -0
  29. package/node_modules/@colors/colors/examples/normal-usage.js +83 -0
  30. package/node_modules/@colors/colors/examples/safe-string.js +80 -0
  31. package/node_modules/@colors/colors/index.d.ts +136 -0
  32. package/node_modules/@colors/colors/lib/colors.js +211 -0
  33. package/node_modules/@colors/colors/lib/custom/trap.js +46 -0
  34. package/node_modules/@colors/colors/lib/custom/zalgo.js +110 -0
  35. package/node_modules/@colors/colors/lib/extendStringPrototype.js +110 -0
  36. package/node_modules/@colors/colors/lib/index.js +13 -0
  37. package/node_modules/@colors/colors/lib/maps/america.js +10 -0
  38. package/node_modules/@colors/colors/lib/maps/rainbow.js +12 -0
  39. package/node_modules/@colors/colors/lib/maps/random.js +11 -0
  40. package/node_modules/@colors/colors/lib/maps/zebra.js +5 -0
  41. package/node_modules/@colors/colors/lib/styles.js +95 -0
  42. package/node_modules/@colors/colors/lib/system/has-flag.js +35 -0
  43. package/node_modules/@colors/colors/lib/system/supports-colors.js +151 -0
  44. package/node_modules/@colors/colors/package.json +45 -0
  45. package/node_modules/@colors/colors/safe.d.ts +48 -0
  46. package/node_modules/@colors/colors/safe.js +10 -0
  47. package/node_modules/@colors/colors/themes/generic-logging.js +12 -0
  48. package/node_modules/ansi-align/LICENSE +13 -0
  49. package/node_modules/ansi-align/README.md +80 -0
  50. package/node_modules/ansi-align/index.js +61 -0
  51. package/node_modules/ansi-align/node_modules/ansi-regex/index.d.ts +37 -0
  52. package/node_modules/ansi-align/node_modules/ansi-regex/index.js +10 -0
  53. package/node_modules/ansi-align/node_modules/ansi-regex/license +9 -0
  54. package/node_modules/ansi-align/node_modules/ansi-regex/package.json +55 -0
  55. package/node_modules/ansi-align/node_modules/ansi-regex/readme.md +78 -0
  56. package/node_modules/ansi-align/node_modules/emoji-regex/LICENSE-MIT.txt +20 -0
  57. package/node_modules/ansi-align/node_modules/emoji-regex/README.md +73 -0
  58. package/node_modules/ansi-align/node_modules/emoji-regex/es2015/index.js +6 -0
  59. package/node_modules/ansi-align/node_modules/emoji-regex/es2015/text.js +6 -0
  60. package/node_modules/ansi-align/node_modules/emoji-regex/index.d.ts +23 -0
  61. package/node_modules/ansi-align/node_modules/emoji-regex/index.js +6 -0
  62. package/node_modules/ansi-align/node_modules/emoji-regex/package.json +50 -0
  63. package/node_modules/ansi-align/node_modules/emoji-regex/text.js +6 -0
  64. package/node_modules/ansi-align/node_modules/string-width/index.d.ts +29 -0
  65. package/node_modules/ansi-align/node_modules/string-width/index.js +47 -0
  66. package/node_modules/ansi-align/node_modules/string-width/license +9 -0
  67. package/node_modules/ansi-align/node_modules/string-width/package.json +56 -0
  68. package/node_modules/ansi-align/node_modules/string-width/readme.md +50 -0
  69. package/node_modules/ansi-align/node_modules/strip-ansi/index.d.ts +17 -0
  70. package/node_modules/ansi-align/node_modules/strip-ansi/index.js +4 -0
  71. package/node_modules/ansi-align/node_modules/strip-ansi/license +9 -0
  72. package/node_modules/ansi-align/node_modules/strip-ansi/package.json +54 -0
  73. package/node_modules/ansi-align/node_modules/strip-ansi/readme.md +46 -0
  74. package/node_modules/ansi-align/package.json +43 -0
  75. package/node_modules/ansi-regex/index.d.ts +33 -0
  76. package/node_modules/ansi-regex/index.js +14 -0
  77. package/node_modules/ansi-regex/license +9 -0
  78. package/node_modules/ansi-regex/package.json +61 -0
  79. package/node_modules/ansi-regex/readme.md +66 -0
  80. package/node_modules/ansi-styles/index.d.ts +236 -0
  81. package/node_modules/ansi-styles/index.js +223 -0
  82. package/node_modules/ansi-styles/license +9 -0
  83. package/node_modules/ansi-styles/package.json +54 -0
  84. package/node_modules/ansi-styles/readme.md +173 -0
  85. package/node_modules/boxen/index.d.ts +267 -0
  86. package/node_modules/boxen/index.js +376 -0
  87. package/node_modules/boxen/license +9 -0
  88. package/node_modules/boxen/package.json +69 -0
  89. package/node_modules/boxen/readme.md +300 -0
  90. package/node_modules/camelcase/index.d.ts +102 -0
  91. package/node_modules/camelcase/index.js +110 -0
  92. package/node_modules/camelcase/license +9 -0
  93. package/node_modules/camelcase/package.json +47 -0
  94. package/node_modules/camelcase/readme.md +135 -0
  95. package/node_modules/chalk/license +9 -0
  96. package/node_modules/chalk/package.json +83 -0
  97. package/node_modules/chalk/readme.md +297 -0
  98. package/node_modules/chalk/source/index.d.ts +325 -0
  99. package/node_modules/chalk/source/index.js +225 -0
  100. package/node_modules/chalk/source/utilities.js +33 -0
  101. package/node_modules/chalk/source/vendor/ansi-styles/index.d.ts +236 -0
  102. package/node_modules/chalk/source/vendor/ansi-styles/index.js +223 -0
  103. package/node_modules/chalk/source/vendor/supports-color/browser.d.ts +1 -0
  104. package/node_modules/chalk/source/vendor/supports-color/browser.js +34 -0
  105. package/node_modules/chalk/source/vendor/supports-color/index.d.ts +55 -0
  106. package/node_modules/chalk/source/vendor/supports-color/index.js +190 -0
  107. package/node_modules/cli-boxes/boxes.json +82 -0
  108. package/node_modules/cli-boxes/index.d.ts +127 -0
  109. package/node_modules/cli-boxes/index.js +6 -0
  110. package/node_modules/cli-boxes/license +9 -0
  111. package/node_modules/cli-boxes/package.json +42 -0
  112. package/node_modules/cli-boxes/readme.md +115 -0
  113. package/node_modules/cli-table3/LICENSE +21 -0
  114. package/node_modules/cli-table3/README.md +236 -0
  115. package/node_modules/cli-table3/index.d.ts +96 -0
  116. package/node_modules/cli-table3/index.js +1 -0
  117. package/node_modules/cli-table3/node_modules/ansi-regex/index.d.ts +37 -0
  118. package/node_modules/cli-table3/node_modules/ansi-regex/index.js +10 -0
  119. package/node_modules/cli-table3/node_modules/ansi-regex/license +9 -0
  120. package/node_modules/cli-table3/node_modules/ansi-regex/package.json +55 -0
  121. package/node_modules/cli-table3/node_modules/ansi-regex/readme.md +78 -0
  122. package/node_modules/cli-table3/node_modules/emoji-regex/LICENSE-MIT.txt +20 -0
  123. package/node_modules/cli-table3/node_modules/emoji-regex/README.md +73 -0
  124. package/node_modules/cli-table3/node_modules/emoji-regex/es2015/index.js +6 -0
  125. package/node_modules/cli-table3/node_modules/emoji-regex/es2015/text.js +6 -0
  126. package/node_modules/cli-table3/node_modules/emoji-regex/index.d.ts +23 -0
  127. package/node_modules/cli-table3/node_modules/emoji-regex/index.js +6 -0
  128. package/node_modules/cli-table3/node_modules/emoji-regex/package.json +50 -0
  129. package/node_modules/cli-table3/node_modules/emoji-regex/text.js +6 -0
  130. package/node_modules/cli-table3/node_modules/string-width/index.d.ts +29 -0
  131. package/node_modules/cli-table3/node_modules/string-width/index.js +47 -0
  132. package/node_modules/cli-table3/node_modules/string-width/license +9 -0
  133. package/node_modules/cli-table3/node_modules/string-width/package.json +56 -0
  134. package/node_modules/cli-table3/node_modules/string-width/readme.md +50 -0
  135. package/node_modules/cli-table3/node_modules/strip-ansi/index.d.ts +17 -0
  136. package/node_modules/cli-table3/node_modules/strip-ansi/index.js +4 -0
  137. package/node_modules/cli-table3/node_modules/strip-ansi/license +9 -0
  138. package/node_modules/cli-table3/node_modules/strip-ansi/package.json +54 -0
  139. package/node_modules/cli-table3/node_modules/strip-ansi/readme.md +46 -0
  140. package/node_modules/cli-table3/package.json +100 -0
  141. package/node_modules/cli-table3/src/cell.js +409 -0
  142. package/node_modules/cli-table3/src/debug.js +28 -0
  143. package/node_modules/cli-table3/src/layout-manager.js +254 -0
  144. package/node_modules/cli-table3/src/table.js +106 -0
  145. package/node_modules/cli-table3/src/utils.js +344 -0
  146. package/node_modules/commander/LICENSE +22 -0
  147. package/node_modules/commander/Readme.md +1157 -0
  148. package/node_modules/commander/esm.mjs +16 -0
  149. package/node_modules/commander/index.js +24 -0
  150. package/node_modules/commander/lib/argument.js +149 -0
  151. package/node_modules/commander/lib/command.js +2509 -0
  152. package/node_modules/commander/lib/error.js +39 -0
  153. package/node_modules/commander/lib/help.js +520 -0
  154. package/node_modules/commander/lib/option.js +330 -0
  155. package/node_modules/commander/lib/suggestSimilar.js +101 -0
  156. package/node_modules/commander/package-support.json +16 -0
  157. package/node_modules/commander/package.json +84 -0
  158. package/node_modules/commander/typings/esm.d.mts +3 -0
  159. package/node_modules/commander/typings/index.d.ts +969 -0
  160. package/node_modules/emoji-regex/LICENSE-MIT.txt +20 -0
  161. package/node_modules/emoji-regex/README.md +107 -0
  162. package/node_modules/emoji-regex/index.d.ts +3 -0
  163. package/node_modules/emoji-regex/index.js +4 -0
  164. package/node_modules/emoji-regex/index.mjs +4 -0
  165. package/node_modules/emoji-regex/package.json +45 -0
  166. package/node_modules/get-east-asian-width/index.d.ts +60 -0
  167. package/node_modules/get-east-asian-width/index.js +30 -0
  168. package/node_modules/get-east-asian-width/license +9 -0
  169. package/node_modules/get-east-asian-width/lookup-data.js +18 -0
  170. package/node_modules/get-east-asian-width/lookup.js +135 -0
  171. package/node_modules/get-east-asian-width/package.json +71 -0
  172. package/node_modules/get-east-asian-width/readme.md +65 -0
  173. package/node_modules/get-east-asian-width/utilities.js +24 -0
  174. package/node_modules/is-fullwidth-code-point/index.d.ts +17 -0
  175. package/node_modules/is-fullwidth-code-point/index.js +50 -0
  176. package/node_modules/is-fullwidth-code-point/license +9 -0
  177. package/node_modules/is-fullwidth-code-point/package.json +42 -0
  178. package/node_modules/is-fullwidth-code-point/readme.md +39 -0
  179. package/node_modules/isbinaryfile/LICENSE.txt +22 -0
  180. package/node_modules/isbinaryfile/README.md +70 -0
  181. package/node_modules/isbinaryfile/lib/index.d.ts +3 -0
  182. package/node_modules/isbinaryfile/lib/index.js +256 -0
  183. package/node_modules/isbinaryfile/package.json +64 -0
  184. package/node_modules/string-width/index.d.ts +39 -0
  185. package/node_modules/string-width/index.js +82 -0
  186. package/node_modules/string-width/license +9 -0
  187. package/node_modules/string-width/package.json +64 -0
  188. package/node_modules/string-width/readme.md +66 -0
  189. package/node_modules/strip-ansi/index.d.ts +15 -0
  190. package/node_modules/strip-ansi/index.js +19 -0
  191. package/node_modules/strip-ansi/license +9 -0
  192. package/node_modules/strip-ansi/package.json +59 -0
  193. package/node_modules/strip-ansi/readme.md +37 -0
  194. package/node_modules/type-fest/index.d.ts +178 -0
  195. package/node_modules/type-fest/license-cc0 +121 -0
  196. package/node_modules/type-fest/license-mit +9 -0
  197. package/node_modules/type-fest/package.json +91 -0
  198. package/node_modules/type-fest/readme.md +1060 -0
  199. package/node_modules/type-fest/source/all-union-fields.d.ts +88 -0
  200. package/node_modules/type-fest/source/and.d.ts +25 -0
  201. package/node_modules/type-fest/source/array-indices.d.ts +23 -0
  202. package/node_modules/type-fest/source/array-slice.d.ts +109 -0
  203. package/node_modules/type-fest/source/array-splice.d.ts +99 -0
  204. package/node_modules/type-fest/source/array-tail.d.ts +76 -0
  205. package/node_modules/type-fest/source/array-values.d.ts +22 -0
  206. package/node_modules/type-fest/source/arrayable.d.ts +29 -0
  207. package/node_modules/type-fest/source/async-return-type.d.ts +23 -0
  208. package/node_modules/type-fest/source/asyncify.d.ts +32 -0
  209. package/node_modules/type-fest/source/basic.d.ts +68 -0
  210. package/node_modules/type-fest/source/camel-case.d.ts +89 -0
  211. package/node_modules/type-fest/source/camel-cased-properties-deep.d.ts +97 -0
  212. package/node_modules/type-fest/source/camel-cased-properties.d.ts +43 -0
  213. package/node_modules/type-fest/source/conditional-except.d.ts +45 -0
  214. package/node_modules/type-fest/source/conditional-keys.d.ts +47 -0
  215. package/node_modules/type-fest/source/conditional-pick-deep.d.ts +118 -0
  216. package/node_modules/type-fest/source/conditional-pick.d.ts +44 -0
  217. package/node_modules/type-fest/source/conditional-simplify.d.ts +32 -0
  218. package/node_modules/type-fest/source/delimiter-case.d.ts +78 -0
  219. package/node_modules/type-fest/source/delimiter-cased-properties-deep.d.ts +106 -0
  220. package/node_modules/type-fest/source/delimiter-cased-properties.d.ts +46 -0
  221. package/node_modules/type-fest/source/distributed-omit.d.ts +89 -0
  222. package/node_modules/type-fest/source/distributed-pick.d.ts +85 -0
  223. package/node_modules/type-fest/source/empty-object.d.ts +46 -0
  224. package/node_modules/type-fest/source/enforce-optional.d.ts +47 -0
  225. package/node_modules/type-fest/source/entries.d.ts +62 -0
  226. package/node_modules/type-fest/source/entry.d.ts +65 -0
  227. package/node_modules/type-fest/source/exact.d.ts +68 -0
  228. package/node_modules/type-fest/source/except.d.ts +108 -0
  229. package/node_modules/type-fest/source/find-global-type.d.ts +64 -0
  230. package/node_modules/type-fest/source/fixed-length-array.d.ts +43 -0
  231. package/node_modules/type-fest/source/get.d.ts +219 -0
  232. package/node_modules/type-fest/source/global-this.d.ts +21 -0
  233. package/node_modules/type-fest/source/greater-than-or-equal.d.ts +22 -0
  234. package/node_modules/type-fest/source/greater-than.d.ts +56 -0
  235. package/node_modules/type-fest/source/has-optional-keys.d.ts +21 -0
  236. package/node_modules/type-fest/source/has-readonly-keys.d.ts +21 -0
  237. package/node_modules/type-fest/source/has-required-keys.d.ts +59 -0
  238. package/node_modules/type-fest/source/has-writable-keys.d.ts +21 -0
  239. package/node_modules/type-fest/source/if-any.d.ts +24 -0
  240. package/node_modules/type-fest/source/if-empty-object.d.ts +26 -0
  241. package/node_modules/type-fest/source/if-never.d.ts +24 -0
  242. package/node_modules/type-fest/source/if-null.d.ts +24 -0
  243. package/node_modules/type-fest/source/if-unknown.d.ts +24 -0
  244. package/node_modules/type-fest/source/includes.d.ts +22 -0
  245. package/node_modules/type-fest/source/int-closed-range.d.ts +35 -0
  246. package/node_modules/type-fest/source/int-range.d.ts +55 -0
  247. package/node_modules/type-fest/source/internal/array.d.ts +126 -0
  248. package/node_modules/type-fest/source/internal/characters.d.ts +67 -0
  249. package/node_modules/type-fest/source/internal/index.d.ts +8 -0
  250. package/node_modules/type-fest/source/internal/keys.d.ts +97 -0
  251. package/node_modules/type-fest/source/internal/numeric.d.ts +118 -0
  252. package/node_modules/type-fest/source/internal/object.d.ts +236 -0
  253. package/node_modules/type-fest/source/internal/string.d.ts +210 -0
  254. package/node_modules/type-fest/source/internal/tuple.d.ts +90 -0
  255. package/node_modules/type-fest/source/internal/type.d.ts +139 -0
  256. package/node_modules/type-fest/source/invariant-of.d.ts +76 -0
  257. package/node_modules/type-fest/source/is-any.d.ts +33 -0
  258. package/node_modules/type-fest/source/is-equal.d.ts +31 -0
  259. package/node_modules/type-fest/source/is-float.d.ts +41 -0
  260. package/node_modules/type-fest/source/is-integer.d.ts +58 -0
  261. package/node_modules/type-fest/source/is-literal.d.ts +296 -0
  262. package/node_modules/type-fest/source/is-never.d.ts +42 -0
  263. package/node_modules/type-fest/source/is-null.d.ts +20 -0
  264. package/node_modules/type-fest/source/is-tuple.d.ts +89 -0
  265. package/node_modules/type-fest/source/is-unknown.d.ts +52 -0
  266. package/node_modules/type-fest/source/iterable-element.d.ts +64 -0
  267. package/node_modules/type-fest/source/join.d.ts +68 -0
  268. package/node_modules/type-fest/source/jsonifiable.d.ts +37 -0
  269. package/node_modules/type-fest/source/jsonify.d.ts +122 -0
  270. package/node_modules/type-fest/source/kebab-case.d.ts +44 -0
  271. package/node_modules/type-fest/source/kebab-cased-properties-deep.d.ts +63 -0
  272. package/node_modules/type-fest/source/kebab-cased-properties.d.ts +40 -0
  273. package/node_modules/type-fest/source/keys-of-union.d.ts +42 -0
  274. package/node_modules/type-fest/source/last-array-element.d.ts +38 -0
  275. package/node_modules/type-fest/source/less-than-or-equal.d.ts +22 -0
  276. package/node_modules/type-fest/source/less-than.d.ts +26 -0
  277. package/node_modules/type-fest/source/literal-to-primitive-deep.d.ts +36 -0
  278. package/node_modules/type-fest/source/literal-to-primitive.d.ts +36 -0
  279. package/node_modules/type-fest/source/literal-union.d.ts +37 -0
  280. package/node_modules/type-fest/source/merge-deep.d.ts +486 -0
  281. package/node_modules/type-fest/source/merge-exclusive.d.ts +41 -0
  282. package/node_modules/type-fest/source/merge.d.ts +48 -0
  283. package/node_modules/type-fest/source/multidimensional-array.d.ts +44 -0
  284. package/node_modules/type-fest/source/multidimensional-readonly-array.d.ts +48 -0
  285. package/node_modules/type-fest/source/non-empty-object.d.ts +35 -0
  286. package/node_modules/type-fest/source/non-empty-string.d.ts +28 -0
  287. package/node_modules/type-fest/source/non-empty-tuple.d.ts +21 -0
  288. package/node_modules/type-fest/source/numeric.d.ts +222 -0
  289. package/node_modules/type-fest/source/observable-like.d.ts +63 -0
  290. package/node_modules/type-fest/source/omit-deep.d.ts +167 -0
  291. package/node_modules/type-fest/source/omit-index-signature.d.ts +95 -0
  292. package/node_modules/type-fest/source/opaque.d.ts +1 -0
  293. package/node_modules/type-fest/source/optional-keys-of.d.ts +39 -0
  294. package/node_modules/type-fest/source/or.d.ts +25 -0
  295. package/node_modules/type-fest/source/override-properties.d.ts +36 -0
  296. package/node_modules/type-fest/source/package-json.d.ts +676 -0
  297. package/node_modules/type-fest/source/partial-deep.d.ts +151 -0
  298. package/node_modules/type-fest/source/partial-on-undefined-deep.d.ts +78 -0
  299. package/node_modules/type-fest/source/pascal-case.d.ts +42 -0
  300. package/node_modules/type-fest/source/pascal-cased-properties-deep.d.ts +62 -0
  301. package/node_modules/type-fest/source/pascal-cased-properties.d.ts +36 -0
  302. package/node_modules/type-fest/source/paths.d.ts +262 -0
  303. package/node_modules/type-fest/source/pick-deep.d.ts +149 -0
  304. package/node_modules/type-fest/source/pick-index-signature.d.ts +50 -0
  305. package/node_modules/type-fest/source/primitive.d.ts +13 -0
  306. package/node_modules/type-fest/source/promisable.d.ts +25 -0
  307. package/node_modules/type-fest/source/readonly-deep.d.ts +81 -0
  308. package/node_modules/type-fest/source/readonly-keys-of.d.ts +30 -0
  309. package/node_modules/type-fest/source/readonly-tuple.d.ts +41 -0
  310. package/node_modules/type-fest/source/replace.d.ts +85 -0
  311. package/node_modules/type-fest/source/require-all-or-none.d.ts +51 -0
  312. package/node_modules/type-fest/source/require-at-least-one.d.ts +47 -0
  313. package/node_modules/type-fest/source/require-exactly-one.d.ts +45 -0
  314. package/node_modules/type-fest/source/require-one-or-none.d.ts +46 -0
  315. package/node_modules/type-fest/source/required-deep.d.ts +78 -0
  316. package/node_modules/type-fest/source/required-keys-of.d.ts +30 -0
  317. package/node_modules/type-fest/source/schema.d.ts +114 -0
  318. package/node_modules/type-fest/source/screaming-snake-case.d.ts +28 -0
  319. package/node_modules/type-fest/source/set-field-type.d.ts +65 -0
  320. package/node_modules/type-fest/source/set-non-nullable-deep.d.ts +83 -0
  321. package/node_modules/type-fest/source/set-non-nullable.d.ts +39 -0
  322. package/node_modules/type-fest/source/set-optional.d.ts +38 -0
  323. package/node_modules/type-fest/source/set-parameter-type.d.ts +117 -0
  324. package/node_modules/type-fest/source/set-readonly.d.ts +39 -0
  325. package/node_modules/type-fest/source/set-required-deep.d.ts +68 -0
  326. package/node_modules/type-fest/source/set-required.d.ts +70 -0
  327. package/node_modules/type-fest/source/set-return-type.d.ts +29 -0
  328. package/node_modules/type-fest/source/shared-union-fields-deep.d.ts +178 -0
  329. package/node_modules/type-fest/source/shared-union-fields.d.ts +76 -0
  330. package/node_modules/type-fest/source/simplify-deep.d.ts +115 -0
  331. package/node_modules/type-fest/source/simplify.d.ts +58 -0
  332. package/node_modules/type-fest/source/single-key-object.d.ts +29 -0
  333. package/node_modules/type-fest/source/snake-case.d.ts +45 -0
  334. package/node_modules/type-fest/source/snake-cased-properties-deep.d.ts +63 -0
  335. package/node_modules/type-fest/source/snake-cased-properties.d.ts +40 -0
  336. package/node_modules/type-fest/source/split.d.ts +88 -0
  337. package/node_modules/type-fest/source/spread.d.ts +84 -0
  338. package/node_modules/type-fest/source/string-key-of.d.ts +25 -0
  339. package/node_modules/type-fest/source/string-repeat.d.ts +47 -0
  340. package/node_modules/type-fest/source/string-slice.d.ts +37 -0
  341. package/node_modules/type-fest/source/stringified.d.ts +23 -0
  342. package/node_modules/type-fest/source/structured-cloneable.d.ts +92 -0
  343. package/node_modules/type-fest/source/subtract.d.ts +83 -0
  344. package/node_modules/type-fest/source/sum.d.ts +78 -0
  345. package/node_modules/type-fest/source/tagged-union.d.ts +51 -0
  346. package/node_modules/type-fest/source/tagged.d.ts +256 -0
  347. package/node_modules/type-fest/source/trim.d.ts +27 -0
  348. package/node_modules/type-fest/source/tsconfig-json.d.ts +1294 -0
  349. package/node_modules/type-fest/source/tuple-to-object.d.ts +42 -0
  350. package/node_modules/type-fest/source/tuple-to-union.d.ts +51 -0
  351. package/node_modules/type-fest/source/typed-array.d.ts +17 -0
  352. package/node_modules/type-fest/source/undefined-on-partial-deep.d.ts +80 -0
  353. package/node_modules/type-fest/source/union-to-intersection.d.ts +61 -0
  354. package/node_modules/type-fest/source/union-to-tuple.d.ts +56 -0
  355. package/node_modules/type-fest/source/unknown-array.d.ts +25 -0
  356. package/node_modules/type-fest/source/unknown-map.d.ts +24 -0
  357. package/node_modules/type-fest/source/unknown-record.d.ts +31 -0
  358. package/node_modules/type-fest/source/unknown-set.d.ts +24 -0
  359. package/node_modules/type-fest/source/value-of.d.ts +42 -0
  360. package/node_modules/type-fest/source/words.d.ts +118 -0
  361. package/node_modules/type-fest/source/writable-deep.d.ts +83 -0
  362. package/node_modules/type-fest/source/writable-keys-of.d.ts +33 -0
  363. package/node_modules/type-fest/source/writable.d.ts +68 -0
  364. package/node_modules/widest-line/index.d.ts +12 -0
  365. package/node_modules/widest-line/index.js +11 -0
  366. package/node_modules/widest-line/license +9 -0
  367. package/node_modules/widest-line/package.json +60 -0
  368. package/node_modules/widest-line/readme.md +26 -0
  369. package/node_modules/wrap-ansi/index.d.ts +41 -0
  370. package/node_modules/wrap-ansi/index.js +222 -0
  371. package/node_modules/wrap-ansi/license +9 -0
  372. package/node_modules/wrap-ansi/package.json +69 -0
  373. package/node_modules/wrap-ansi/readme.md +75 -0
  374. package/package.json +78 -0
  375. package/scripts/postinstall.cjs +122 -0
@@ -0,0 +1,42 @@
1
+ import type {IsTuple} from './is-tuple';
2
+ import type {UnknownArray} from './unknown-array';
3
+ import type {IfAny} from './if-any';
4
+
5
+ /**
6
+ Transforms a tuple into an object, mapping each tuple index to its corresponding type as a key-value pair.
7
+
8
+ Note: Tuple labels are [lost in the transformation process](https://stackoverflow.com/a/70398429/11719314). For example, `TupleToObject<[x: number, y: number]>` produces `{0: number; 1: number}`, and not `{x: number; y: number}`.
9
+
10
+ @example
11
+ ```
12
+ type Example1 = TupleToObject<[number, string, boolean]>;
13
+ //=> { 0: number; 1: string; 2: boolean }
14
+
15
+ // Tuples with optional indices
16
+ type Example2 = TupleToObject<[number, string?, boolean?]>;
17
+ //=> { 0: number; 1?: string; 2?: boolean }
18
+
19
+ // Readonly tuples
20
+ type Example3 = TupleToObject<readonly [number, string?]>;
21
+ //=> { readonly 0: number; readonly 1?: string }
22
+
23
+ // Non-tuple arrays get transformed into index signatures
24
+ type Example4 = TupleToObject<string[]>;
25
+ //=> { [x: number]: string }
26
+
27
+ // Tuples with rest elements
28
+ type Example5 = TupleToObject<[number, string, ...boolean[]]>;
29
+ //=> { [x: number]: number | string | boolean; 0: number; 1: string }
30
+
31
+ // Tuple labels are not preserved
32
+ type Example6 = TupleToObject<[x: number, y: number]>;
33
+ //=> { 0: number; 1: number }
34
+ ```
35
+
36
+ @category Array
37
+ */
38
+ export type TupleToObject<TArray extends UnknownArray> = IfAny<TArray, any, {
39
+ [
40
+ Key in keyof TArray as Key & (`${number}` | (IsTuple<TArray> extends true ? never : number))
41
+ ]: TArray[Key];
42
+ }>;
@@ -0,0 +1,51 @@
1
+ /**
2
+ Convert a tuple/array into a union type of its elements.
3
+
4
+ This can be useful when you have a fixed set of allowed values and want a type defining only the allowed values, but do not want to repeat yourself.
5
+
6
+ @example
7
+ ```
8
+ import type {TupleToUnion} from 'type-fest';
9
+
10
+ const destinations = ['a', 'b', 'c'] as const;
11
+
12
+ type Destination = TupleToUnion<typeof destinations>;
13
+ //=> 'a' | 'b' | 'c'
14
+
15
+ function verifyDestination(destination: unknown): destination is Destination {
16
+ return destinations.includes(destination as any);
17
+ }
18
+
19
+ type RequestBody = {
20
+ deliverTo: Destination;
21
+ };
22
+
23
+ function verifyRequestBody(body: unknown): body is RequestBody {
24
+ const deliverTo = (body as any).deliverTo;
25
+ return typeof body === 'object' && body !== null && verifyDestination(deliverTo);
26
+ }
27
+ ```
28
+
29
+ Alternatively, you may use `typeof destinations[number]`. If `destinations` is a tuple, there is no difference. However if `destinations` is a string, the resulting type will the union of the characters in the string. Other types of `destinations` may result in a compile error. In comparison, TupleToUnion will return `never` if a tuple is not provided.
30
+
31
+ @example
32
+ ```
33
+ const destinations = ['a', 'b', 'c'] as const;
34
+
35
+ type Destination = typeof destinations[number];
36
+ //=> 'a' | 'b' | 'c'
37
+
38
+ const erroringType = new Set(['a', 'b', 'c']);
39
+
40
+ type ErroringType = typeof erroringType[number];
41
+ //=> Type 'Set<string>' has no matching index signature for type 'number'. ts(2537)
42
+
43
+ const numberBool: { [n: number]: boolean } = { 1: true };
44
+
45
+ type NumberBool = typeof numberBool[number];
46
+ //=> boolean
47
+ ```
48
+
49
+ @category Array
50
+ */
51
+ export type TupleToUnion<ArrayType> = ArrayType extends readonly unknown[] ? ArrayType[number] : never;
@@ -0,0 +1,17 @@
1
+ /**
2
+ Matches any [typed array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray), like `Uint8Array` or `Float64Array`.
3
+
4
+ @category Array
5
+ */
6
+ export type TypedArray =
7
+ | Int8Array
8
+ | Uint8Array
9
+ | Uint8ClampedArray
10
+ | Int16Array
11
+ | Uint16Array
12
+ | Int32Array
13
+ | Uint32Array
14
+ | Float32Array
15
+ | Float64Array
16
+ | BigInt64Array
17
+ | BigUint64Array;
@@ -0,0 +1,80 @@
1
+ import type {BuiltIns} from './internal';
2
+
3
+ /**
4
+ Create a deep version of another type where all optional keys are set to also accept `undefined`.
5
+
6
+ Note: This is only needed when the [`exactOptionalPropertyTypes`](https://www.typescriptlang.org/tsconfig#exactOptionalPropertyTypes) TSConfig setting is enabled.
7
+
8
+ Use-cases:
9
+ - When `exactOptionalPropertyTypes` is enabled, an object like `{a: undefined}` is not assignable to the type `{a?: number}`. You can use `UndefinedOnPartialDeep<{a?: number}>` to make it assignable.
10
+
11
+ @example
12
+ ```
13
+ import type {UndefinedOnPartialDeep} from 'type-fest';
14
+
15
+ interface Settings {
16
+ optionA: string;
17
+ optionB?: number;
18
+ subOption: {
19
+ subOptionA: boolean;
20
+ subOptionB?: boolean;
21
+ }
22
+ };
23
+
24
+ const testSettingsA: Settings = {
25
+ optionA: 'foo',
26
+ optionB: undefined, // TypeScript error if `exactOptionalPropertyTypes` is true.
27
+ subOption: {
28
+ subOptionA: true,
29
+ subOptionB: undefined, // TypeScript error if `exactOptionalPropertyTypes` is true
30
+ },
31
+ };
32
+
33
+ const testSettingsB: UndefinedOnPartialDeep<Settings> = {
34
+ optionA: 'foo',
35
+ optionB: undefined, // 👉 `optionB` can be set to undefined now.
36
+ subOption: {
37
+ subOptionA: true,
38
+ subOptionB: undefined, // 👉 `subOptionB` can be set to undefined now.
39
+ },
40
+ };
41
+ ```
42
+ */
43
+ export type UndefinedOnPartialDeep<T> =
44
+ // Handle built-in type and function
45
+ T extends BuiltIns | Function
46
+ ? T
47
+ // Handle tuple and array
48
+ : T extends readonly unknown[]
49
+ ? UndefinedOnPartialList<T>
50
+ // Handle map and readonly map
51
+ : T extends Map<infer K, infer V>
52
+ ? Map<K, UndefinedOnPartialDeep<V>>
53
+ : T extends ReadonlyMap<infer K, infer V>
54
+ ? ReadonlyMap<K, UndefinedOnPartialDeep<V>>
55
+ // Handle set and readonly set
56
+ : T extends Set<infer K>
57
+ ? Set<UndefinedOnPartialDeep<K>>
58
+ : T extends ReadonlySet<infer K>
59
+ ? ReadonlySet<UndefinedOnPartialDeep<K>>
60
+ // Handle object
61
+ : T extends Record<any, any>
62
+ ? {
63
+ [KeyType in keyof T]: undefined extends T[KeyType]
64
+ ? UndefinedOnPartialDeep<T[KeyType]> | undefined
65
+ : UndefinedOnPartialDeep<T[KeyType]>
66
+ }
67
+ : T; // If T is not builtins / function / array / map / set / object, return T
68
+
69
+ // Handle tuples and arrays
70
+ type UndefinedOnPartialList<T extends readonly unknown[]> = T extends []
71
+ ? []
72
+ : T extends [infer F, ...infer R]
73
+ ? [UndefinedOnPartialDeep<F>, ...UndefinedOnPartialDeep<R>]
74
+ : T extends readonly [infer F, ...infer R]
75
+ ? readonly [UndefinedOnPartialDeep<F>, ...UndefinedOnPartialDeep<R>]
76
+ : T extends Array<infer F>
77
+ ? Array<UndefinedOnPartialDeep<F>>
78
+ : T extends ReadonlyArray<infer F>
79
+ ? ReadonlyArray<UndefinedOnPartialDeep<F>>
80
+ : never;
@@ -0,0 +1,61 @@
1
+ /**
2
+ Convert a union type to an intersection type using [distributive conditional types](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
3
+
4
+ Inspired by [this Stack Overflow answer](https://stackoverflow.com/a/50375286/2172153).
5
+
6
+ @example
7
+ ```
8
+ import type {UnionToIntersection} from 'type-fest';
9
+
10
+ type Union = {the(): void} | {great(arg: string): void} | {escape: boolean};
11
+
12
+ type Intersection = UnionToIntersection<Union>;
13
+ //=> {the(): void; great(arg: string): void; escape: boolean};
14
+ ```
15
+
16
+ A more applicable example which could make its way into your library code follows.
17
+
18
+ @example
19
+ ```
20
+ import type {UnionToIntersection} from 'type-fest';
21
+
22
+ class CommandOne {
23
+ commands: {
24
+ a1: () => undefined,
25
+ b1: () => undefined,
26
+ }
27
+ }
28
+
29
+ class CommandTwo {
30
+ commands: {
31
+ a2: (argA: string) => undefined,
32
+ b2: (argB: string) => undefined,
33
+ }
34
+ }
35
+
36
+ const union = [new CommandOne(), new CommandTwo()].map(instance => instance.commands);
37
+ type Union = typeof union;
38
+ //=> {a1(): void; b1(): void} | {a2(argA: string): void; b2(argB: string): void}
39
+
40
+ type Intersection = UnionToIntersection<Union>;
41
+ //=> {a1(): void; b1(): void; a2(argA: string): void; b2(argB: string): void}
42
+ ```
43
+
44
+ @category Type
45
+ */
46
+ export type UnionToIntersection<Union> = (
47
+ // `extends unknown` is always going to be the case and is used to convert the
48
+ // `Union` into a [distributive conditional
49
+ // type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
50
+ Union extends unknown
51
+ // The union type is used as the only argument to a function since the union
52
+ // of function arguments is an intersection.
53
+ ? (distributedUnion: Union) => void
54
+ // This won't happen.
55
+ : never
56
+ // Infer the `Intersection` type since TypeScript represents the positional
57
+ // arguments of unions of functions as an intersection of the union.
58
+ ) extends ((mergedIntersection: infer Intersection) => void)
59
+ // The `& Union` is to allow indexing by the resulting type
60
+ ? Intersection & Union
61
+ : never;
@@ -0,0 +1,56 @@
1
+ import type {IsNever} from './is-never';
2
+ import type {UnionToIntersection} from './union-to-intersection';
3
+
4
+ /**
5
+ Returns the last element of a union type.
6
+
7
+ @example
8
+ ```
9
+ type Last = LastOfUnion<1 | 2 | 3>;
10
+ //=> 3
11
+ ```
12
+ */
13
+ type LastOfUnion<T> =
14
+ UnionToIntersection<T extends any ? () => T : never> extends () => (infer R)
15
+ ? R
16
+ : never;
17
+
18
+ /**
19
+ Convert a union type into an unordered tuple type of its elements.
20
+
21
+ "Unordered" means the elements of the tuple are not guaranteed to be in the same order as in the union type. The arrangement can appear random and may change at any time.
22
+
23
+ This can be useful when you have objects with a finite set of keys and want a type defining only the allowed keys, but do not want to repeat yourself.
24
+
25
+ @example
26
+ ```
27
+ import type {UnionToTuple} from 'type-fest';
28
+
29
+ type Numbers = 1 | 2 | 3;
30
+ type NumbersTuple = UnionToTuple<Numbers>;
31
+ //=> [1, 2, 3]
32
+ ```
33
+
34
+ @example
35
+ ```
36
+ import type {UnionToTuple} from 'type-fest';
37
+
38
+ const pets = {
39
+ dog: '🐶',
40
+ cat: '🐱',
41
+ snake: '🐍',
42
+ };
43
+
44
+ type Pet = keyof typeof pets;
45
+ //=> 'dog' | 'cat' | 'snake'
46
+
47
+ const petList = Object.keys(pets) as UnionToTuple<Pet>;
48
+ //=> ['dog', 'cat', 'snake']
49
+ ```
50
+
51
+ @category Array
52
+ */
53
+ export type UnionToTuple<T, L = LastOfUnion<T>> =
54
+ IsNever<T> extends false
55
+ ? [...UnionToTuple<Exclude<T, L>>, L]
56
+ : [];
@@ -0,0 +1,25 @@
1
+ /**
2
+ Represents an array with `unknown` value.
3
+
4
+ Use case: You want a type that all arrays can be assigned to, but you don't care about the value.
5
+
6
+ @example
7
+ ```
8
+ import type {UnknownArray} from 'type-fest';
9
+
10
+ type IsArray<T> = T extends UnknownArray ? true : false;
11
+
12
+ type A = IsArray<['foo']>;
13
+ //=> true
14
+
15
+ type B = IsArray<readonly number[]>;
16
+ //=> true
17
+
18
+ type C = IsArray<string>;
19
+ //=> false
20
+ ```
21
+
22
+ @category Type
23
+ @category Array
24
+ */
25
+ export type UnknownArray = readonly unknown[];
@@ -0,0 +1,24 @@
1
+ /**
2
+ Represents a map with `unknown` key and value.
3
+
4
+ Use case: You want a type that all maps can be assigned to, but you don't care about the value.
5
+
6
+ @example
7
+ ```
8
+ import type {UnknownMap} from 'type-fest';
9
+
10
+ type IsMap<T> = T extends UnknownMap ? true : false;
11
+
12
+ type A = IsMap<Map<string, number>>;
13
+ //=> true
14
+
15
+ type B = IsMap<ReadonlyMap<number, string>>;
16
+ //=> true
17
+
18
+ type C = IsMap<string>;
19
+ //=> false
20
+ ```
21
+
22
+ @category Type
23
+ */
24
+ export type UnknownMap = ReadonlyMap<unknown, unknown>;
@@ -0,0 +1,31 @@
1
+ /**
2
+ Represents an object with `unknown` value. You probably want this instead of `{}`.
3
+
4
+ Use case: You have an object whose keys and values are unknown to you.
5
+
6
+ @example
7
+ ```
8
+ import type {UnknownRecord} from 'type-fest';
9
+
10
+ function toJson(object: UnknownRecord) {
11
+ return JSON.stringify(object);
12
+ }
13
+
14
+ toJson({hello: 'world'});
15
+ //=> '{"hello":"world"}'
16
+
17
+ function isObject(value: unknown): value is UnknownRecord {
18
+ return typeof value === 'object' && value !== null;
19
+ }
20
+
21
+ isObject({hello: 'world'});
22
+ //=> true
23
+
24
+ isObject('hello');
25
+ //=> false
26
+ ```
27
+
28
+ @category Type
29
+ @category Object
30
+ */
31
+ export type UnknownRecord = Record<PropertyKey, unknown>;
@@ -0,0 +1,24 @@
1
+ /**
2
+ Represents a set with `unknown` value.
3
+
4
+ Use case: You want a type that all sets can be assigned to, but you don't care about the value.
5
+
6
+ @example
7
+ ```
8
+ import type {UnknownSet} from 'type-fest';
9
+
10
+ type IsSet<T> = T extends UnknownSet ? true : false;
11
+
12
+ type A = IsSet<Set<string>>;
13
+ //=> true
14
+
15
+ type B = IsSet<ReadonlySet<number>>;
16
+ //=> true
17
+
18
+ type C = IsSet<string>;
19
+ //=> false
20
+ ```
21
+
22
+ @category Type
23
+ */
24
+ export type UnknownSet = ReadonlySet<unknown>;
@@ -0,0 +1,42 @@
1
+ /**
2
+ Create a union of the given object's values, and optionally specify which keys to get the values from.
3
+
4
+ Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/31438) if you want to have this type as a built-in in TypeScript.
5
+
6
+ @example
7
+ ```
8
+ // data.json
9
+ {
10
+ 'foo': 1,
11
+ 'bar': 2,
12
+ 'biz': 3
13
+ }
14
+
15
+ // main.ts
16
+ import type {ValueOf} from 'type-fest';
17
+ import data = require('./data.json');
18
+
19
+ export function getData(name: string): ValueOf<typeof data> {
20
+ return data[name];
21
+ }
22
+
23
+ export function onlyBar(name: string): ValueOf<typeof data, 'bar'> {
24
+ return data[name];
25
+ }
26
+
27
+ // file.ts
28
+ import {getData, onlyBar} from './main';
29
+
30
+ getData('foo');
31
+ //=> 1
32
+
33
+ onlyBar('foo');
34
+ //=> TypeError ...
35
+
36
+ onlyBar('bar');
37
+ //=> 2
38
+ ```
39
+
40
+ @category Object
41
+ */
42
+ export type ValueOf<ObjectType, ValueType extends keyof ObjectType = keyof ObjectType> = ObjectType[ValueType];
@@ -0,0 +1,118 @@
1
+ import type {
2
+ ApplyDefaultOptions,
3
+ IsLowerCase,
4
+ IsNumeric,
5
+ IsUpperCase,
6
+ WordSeparators,
7
+ } from './internal';
8
+
9
+ type SkipEmptyWord<Word extends string> = Word extends '' ? [] : [Word];
10
+
11
+ type RemoveLastCharacter<
12
+ Sentence extends string,
13
+ Character extends string,
14
+ > = Sentence extends `${infer LeftSide}${Character}`
15
+ ? SkipEmptyWord<LeftSide>
16
+ : never;
17
+
18
+ /**
19
+ Words options.
20
+
21
+ @see {@link Words}
22
+ */
23
+ export type WordsOptions = {
24
+ /**
25
+ Split on numeric sequence.
26
+
27
+ @default true
28
+
29
+ @example
30
+ ```
31
+ type Example1 = Words<'p2pNetwork', {splitOnNumbers: true}>;
32
+ //=> ["p", "2", "p", "Network"]
33
+
34
+ type Example2 = Words<'p2pNetwork', {splitOnNumbers: false}>;
35
+ //=> ["p2p", "Network"]
36
+ ```
37
+ */
38
+ splitOnNumbers?: boolean;
39
+ };
40
+
41
+ export type DefaultWordsOptions = {
42
+ splitOnNumbers: true;
43
+ };
44
+
45
+ /**
46
+ Split a string (almost) like Lodash's `_.words()` function.
47
+
48
+ - Split on each word that begins with a capital letter.
49
+ - Split on each {@link WordSeparators}.
50
+ - Split on numeric sequence.
51
+
52
+ @example
53
+ ```
54
+ import type {Words} from 'type-fest';
55
+
56
+ type Words0 = Words<'helloWorld'>;
57
+ //=> ['hello', 'World']
58
+
59
+ type Words1 = Words<'helloWORLD'>;
60
+ //=> ['hello', 'WORLD']
61
+
62
+ type Words2 = Words<'hello-world'>;
63
+ //=> ['hello', 'world']
64
+
65
+ type Words3 = Words<'--hello the_world'>;
66
+ //=> ['hello', 'the', 'world']
67
+
68
+ type Words4 = Words<'lifeIs42'>;
69
+ //=> ['life', 'Is', '42']
70
+
71
+ type Words5 = Words<'p2pNetwork', {splitOnNumbers: false}>;
72
+ //=> ['p2p', 'Network']
73
+ ```
74
+
75
+ @category Change case
76
+ @category Template literal
77
+ */
78
+ export type Words<Sentence extends string, Options extends WordsOptions = {}> =
79
+ WordsImplementation<Sentence, ApplyDefaultOptions<WordsOptions, DefaultWordsOptions, Options>>;
80
+
81
+ type WordsImplementation<
82
+ Sentence extends string,
83
+ Options extends Required<WordsOptions>,
84
+ LastCharacter extends string = '',
85
+ CurrentWord extends string = '',
86
+ > = Sentence extends `${infer FirstCharacter}${infer RemainingCharacters}`
87
+ ? FirstCharacter extends WordSeparators
88
+ // Skip word separator
89
+ ? [...SkipEmptyWord<CurrentWord>, ...WordsImplementation<RemainingCharacters, Options>]
90
+ : LastCharacter extends ''
91
+ // Fist char of word
92
+ ? WordsImplementation<RemainingCharacters, Options, FirstCharacter, FirstCharacter>
93
+ // Case change: non-numeric to numeric
94
+ : [false, true] extends [IsNumeric<LastCharacter>, IsNumeric<FirstCharacter>]
95
+ ? Options['splitOnNumbers'] extends true
96
+ // Split on number: push word
97
+ ? [...SkipEmptyWord<CurrentWord>, ...WordsImplementation<RemainingCharacters, Options, FirstCharacter, FirstCharacter>]
98
+ // No split on number: concat word
99
+ : WordsImplementation<RemainingCharacters, Options, FirstCharacter, `${CurrentWord}${FirstCharacter}`>
100
+ // Case change: numeric to non-numeric
101
+ : [true, false] extends [IsNumeric<LastCharacter>, IsNumeric<FirstCharacter>]
102
+ ? Options['splitOnNumbers'] extends true
103
+ // Split on number: push word
104
+ ? [...SkipEmptyWord<CurrentWord>, ...WordsImplementation<RemainingCharacters, Options, FirstCharacter, FirstCharacter>]
105
+ // No split on number: concat word
106
+ : WordsImplementation<RemainingCharacters, Options, FirstCharacter, `${CurrentWord}${FirstCharacter}`>
107
+ // No case change: concat word
108
+ : [true, true] extends [IsNumeric<LastCharacter>, IsNumeric<FirstCharacter>]
109
+ ? WordsImplementation<RemainingCharacters, Options, FirstCharacter, `${CurrentWord}${FirstCharacter}`>
110
+ // Case change: lower to upper, push word
111
+ : [true, true] extends [IsLowerCase<LastCharacter>, IsUpperCase<FirstCharacter>]
112
+ ? [...SkipEmptyWord<CurrentWord>, ...WordsImplementation<RemainingCharacters, Options, FirstCharacter, FirstCharacter>]
113
+ // Case change: upper to lower, brings back the last character, push word
114
+ : [true, true] extends [IsUpperCase<LastCharacter>, IsLowerCase<FirstCharacter>]
115
+ ? [...RemoveLastCharacter<CurrentWord, LastCharacter>, ...WordsImplementation<RemainingCharacters, Options, FirstCharacter, `${LastCharacter}${FirstCharacter}`>]
116
+ // No case change: concat word
117
+ : WordsImplementation<RemainingCharacters, Options, FirstCharacter, `${CurrentWord}${FirstCharacter}`>
118
+ : [...SkipEmptyWord<CurrentWord>];
@@ -0,0 +1,83 @@
1
+ import type {BuiltIns, HasMultipleCallSignatures} from './internal';
2
+
3
+ /**
4
+ Create a deeply mutable version of an `object`/`ReadonlyMap`/`ReadonlySet`/`ReadonlyArray` type. The inverse of `ReadonlyDeep<T>`. Use `Writable<T>` if you only need one level deep.
5
+
6
+ This can be used to [store and mutate options within a class](https://github.com/sindresorhus/pageres/blob/4a5d05fca19a5fbd2f53842cbf3eb7b1b63bddd2/source/index.ts#L72), [edit `readonly` objects within tests](https://stackoverflow.com/questions/50703834), [construct a `readonly` object within a function](https://github.com/Microsoft/TypeScript/issues/24509), or to define a single model where the only thing that changes is whether or not some of the keys are writable.
7
+
8
+ @example
9
+ ```
10
+ import type {WritableDeep} from 'type-fest';
11
+
12
+ type Foo = {
13
+ readonly a: number;
14
+ readonly b: readonly string[]; // To show that mutability is deeply affected.
15
+ readonly c: boolean;
16
+ };
17
+
18
+ const writableDeepFoo: WritableDeep<Foo> = {a: 1, b: ['2'], c: true};
19
+ writableDeepFoo.a = 3;
20
+ writableDeepFoo.b[0] = 'new value';
21
+ writableDeepFoo.b = ['something'];
22
+ ```
23
+
24
+ Note that types containing overloaded functions are not made deeply writable due to a [TypeScript limitation](https://github.com/microsoft/TypeScript/issues/29732).
25
+
26
+ @see Writable
27
+ @category Object
28
+ @category Array
29
+ @category Set
30
+ @category Map
31
+ */
32
+ export type WritableDeep<T> = T extends BuiltIns
33
+ ? T
34
+ : T extends (...arguments_: any[]) => unknown
35
+ ? {} extends WritableObjectDeep<T>
36
+ ? T
37
+ : HasMultipleCallSignatures<T> extends true
38
+ ? T
39
+ : ((...arguments_: Parameters<T>) => ReturnType<T>) & WritableObjectDeep<T>
40
+ : T extends ReadonlyMap<unknown, unknown>
41
+ ? WritableMapDeep<T>
42
+ : T extends ReadonlySet<unknown>
43
+ ? WritableSetDeep<T>
44
+ : T extends readonly unknown[]
45
+ ? WritableArrayDeep<T>
46
+ : T extends object
47
+ ? WritableObjectDeep<T>
48
+ : unknown;
49
+
50
+ /**
51
+ Same as `WritableDeep`, but accepts only `Map`s as inputs. Internal helper for `WritableDeep`.
52
+ */
53
+ type WritableMapDeep<MapType extends ReadonlyMap<unknown, unknown>> =
54
+ MapType extends ReadonlyMap<infer KeyType, infer ValueType>
55
+ ? Map<WritableDeep<KeyType>, WritableDeep<ValueType>>
56
+ : MapType; // Should not heppen
57
+
58
+ /**
59
+ Same as `WritableDeep`, but accepts only `Set`s as inputs. Internal helper for `WritableDeep`.
60
+ */
61
+ type WritableSetDeep<SetType extends ReadonlySet<unknown>> =
62
+ SetType extends ReadonlySet<infer ItemType>
63
+ ? Set<WritableDeep<ItemType>>
64
+ : SetType; // Should not heppen
65
+
66
+ /**
67
+ Same as `WritableDeep`, but accepts only `object`s as inputs. Internal helper for `WritableDeep`.
68
+ */
69
+ type WritableObjectDeep<ObjectType extends object> = {
70
+ -readonly [KeyType in keyof ObjectType]: WritableDeep<ObjectType[KeyType]>
71
+ };
72
+
73
+ /**
74
+ Same as `WritableDeep`, but accepts only `Array`s as inputs. Internal helper for `WritableDeep`.
75
+ */
76
+ type WritableArrayDeep<ArrayType extends readonly unknown[]> =
77
+ ArrayType extends readonly [] ? []
78
+ : ArrayType extends readonly [...infer U, infer V] ? [...WritableArrayDeep<U>, WritableDeep<V>]
79
+ : ArrayType extends readonly [infer U, ...infer V] ? [WritableDeep<U>, ...WritableArrayDeep<V>]
80
+ : ArrayType extends ReadonlyArray<infer U> ? Array<WritableDeep<U>>
81
+ : ArrayType extends Array<infer U> ? Array<WritableDeep<U>>
82
+ : ArrayType;
83
+