@bemoje/cli 0.0.4 → 0.0.6

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 (698) hide show
  1. package/.eslintrc.json +5 -0
  2. package/.swcrc +32 -0
  3. package/dist/cjs/_example/bFindIn.js +189 -0
  4. package/dist/cjs/_example/bFindIn.js.map +1 -0
  5. package/dist/cjs/arg/ArgumentBuilder.js +45 -0
  6. package/dist/cjs/arg/ArgumentBuilder.js.map +1 -0
  7. package/dist/cjs/arg/ArgumentParserSelector.js +15 -0
  8. package/dist/cjs/arg/ArgumentParserSelector.js.map +1 -0
  9. package/dist/cjs/arg/ArgumentReader.js +38 -0
  10. package/dist/cjs/arg/ArgumentReader.js.map +1 -0
  11. package/dist/cjs/arg/ArgumentValidatorSelector.js +16 -0
  12. package/dist/cjs/arg/ArgumentValidatorSelector.js.map +1 -0
  13. package/dist/cjs/cmd/CommandBuilder.js +1080 -0
  14. package/dist/cjs/cmd/CommandBuilder.js.map +1 -0
  15. package/dist/cjs/cmd/CommandBuilderMetaData.js +44 -0
  16. package/dist/cjs/cmd/CommandBuilderMetaData.js.map +1 -0
  17. package/dist/cjs/cmd/CommandFeatureSelector.js +112 -0
  18. package/dist/cjs/cmd/CommandFeatureSelector.js.map +1 -0
  19. package/dist/cjs/cmd/DefaultHelpConfig.js +141 -0
  20. package/dist/cjs/cmd/DefaultHelpConfig.js.map +1 -0
  21. package/dist/cjs/cmd/asdas.js +27 -0
  22. package/dist/cjs/cmd/asdas.js.map +1 -0
  23. package/dist/cjs/core/OutputManager.js +99 -0
  24. package/dist/cjs/core/OutputManager.js.map +1 -0
  25. package/dist/cjs/core/ParserSelector.js +36 -0
  26. package/dist/cjs/core/ParserSelector.js.map +1 -0
  27. package/dist/cjs/core/ValidatorSelector.js +36 -0
  28. package/dist/cjs/core/ValidatorSelector.js.map +1 -0
  29. package/dist/cjs/core/splitCombinedArgvShorts.js +15 -0
  30. package/dist/cjs/core/splitCombinedArgvShorts.js.map +1 -0
  31. package/dist/cjs/db/AbstractJsonFileSection.js +190 -0
  32. package/dist/cjs/db/AbstractJsonFileSection.js.map +1 -0
  33. package/dist/cjs/db/AppDataSection.js +48 -0
  34. package/dist/cjs/db/AppDataSection.js.map +1 -0
  35. package/dist/cjs/db/ConfigSection.js +71 -0
  36. package/dist/cjs/db/ConfigSection.js.map +1 -0
  37. package/dist/cjs/db/JsonFile.js +55 -0
  38. package/dist/cjs/db/JsonFile.js.map +1 -0
  39. package/dist/cjs/db/PresetsSection.js +92 -0
  40. package/dist/cjs/db/PresetsSection.js.map +1 -0
  41. package/dist/cjs/index.js +119 -0
  42. package/dist/cjs/index.js.map +1 -0
  43. package/dist/cjs/opt/OptionArgumentParserSelector.js +16 -0
  44. package/dist/cjs/opt/OptionArgumentParserSelector.js.map +1 -0
  45. package/dist/cjs/opt/OptionArgumentValidatorSelector.js +19 -0
  46. package/dist/cjs/opt/OptionArgumentValidatorSelector.js.map +1 -0
  47. package/dist/cjs/opt/OptionBuilder.js +88 -0
  48. package/dist/cjs/opt/OptionBuilder.js.map +1 -0
  49. package/dist/cjs/opt/OptionHelpers.js +57 -0
  50. package/dist/cjs/opt/OptionHelpers.js.map +1 -0
  51. package/dist/cjs/opt/OptionReader.js +66 -0
  52. package/dist/cjs/opt/OptionReader.js.map +1 -0
  53. package/dist/cjs/types/IConfig.js +3 -0
  54. package/dist/cjs/types/IConfig.js.map +1 -0
  55. package/dist/cjs/types/IPreset.js +3 -0
  56. package/dist/cjs/types/IPreset.js.map +1 -0
  57. package/dist/cjs/util/array/arrLast.js +21 -0
  58. package/dist/cjs/util/array/arrLast.js.map +1 -0
  59. package/dist/cjs/util/array/arrSome.js +26 -0
  60. package/dist/cjs/util/array/arrSome.js.map +1 -0
  61. package/dist/cjs/util/array/types/ArrayPredicate.js +3 -0
  62. package/dist/cjs/util/array/types/ArrayPredicate.js.map +1 -0
  63. package/dist/cjs/util/db/JsonDB.js +145 -0
  64. package/dist/cjs/util/db/JsonDB.js.map +1 -0
  65. package/dist/cjs/util/errors/ErrorParser.js +164 -0
  66. package/dist/cjs/util/errors/ErrorParser.js.map +1 -0
  67. package/dist/cjs/util/fs/promptUserEditInTextEditor/IGetUserInputFromEditorOptions.js +3 -0
  68. package/dist/cjs/util/fs/promptUserEditInTextEditor/IGetUserInputFromEditorOptions.js.map +1 -0
  69. package/dist/cjs/util/fs/promptUserEditInTextEditor/promptUserEditInTextEditorSync.js +32 -0
  70. package/dist/cjs/util/fs/promptUserEditInTextEditor/promptUserEditInTextEditorSync.js.map +1 -0
  71. package/dist/cjs/util/fs/promptUserEditInTextEditor/promptUserEditJsonInTextEditorSync.js +25 -0
  72. package/dist/cjs/util/fs/promptUserEditInTextEditor/promptUserEditJsonInTextEditorSync.js.map +1 -0
  73. package/dist/cjs/util/fs/readFile/readFileSafeSync.js +28 -0
  74. package/dist/cjs/util/fs/readFile/readFileSafeSync.js.map +1 -0
  75. package/dist/cjs/util/fs/readFile/readFileSync.js +20 -0
  76. package/dist/cjs/util/fs/readFile/readFileSync.js.map +1 -0
  77. package/dist/cjs/util/fs/readJsonFile/readJsonFileSafeSync.js +24 -0
  78. package/dist/cjs/util/fs/readJsonFile/readJsonFileSafeSync.js.map +1 -0
  79. package/dist/cjs/util/fs/removeFile/removeFile.js +6 -0
  80. package/dist/cjs/util/fs/removeFile/removeFile.js.map +1 -0
  81. package/dist/cjs/util/fs/tempFile/tempFileSync.js +28 -0
  82. package/dist/cjs/util/fs/tempFile/tempFileSync.js.map +1 -0
  83. package/dist/cjs/util/fs/types/IReadJsonFileOptions.js +3 -0
  84. package/dist/cjs/util/fs/types/IReadJsonFileOptions.js.map +1 -0
  85. package/dist/cjs/util/fs/writeFile/writeFileSafeSync.js +6 -0
  86. package/dist/cjs/util/fs/writeFile/writeFileSafeSync.js.map +1 -0
  87. package/dist/cjs/util/fs/writeFile/writeFileSync.js +6 -0
  88. package/dist/cjs/util/fs/writeFile/writeFileSync.js.map +1 -0
  89. package/dist/cjs/util/fs/writeJsonFile/writeJsonFileSafe.js +6 -0
  90. package/dist/cjs/util/fs/writeJsonFile/writeJsonFileSafe.js.map +1 -0
  91. package/dist/cjs/util/function/MethodDisabler.js +94 -0
  92. package/dist/cjs/util/function/MethodDisabler.js.map +1 -0
  93. package/dist/cjs/util/function/funSetName.js +21 -0
  94. package/dist/cjs/util/function/funSetName.js.map +1 -0
  95. package/dist/cjs/util/node/execInherit.js +19 -0
  96. package/dist/cjs/util/node/execInherit.js.map +1 -0
  97. package/dist/cjs/util/node/formatTableForTerminal.js +21 -0
  98. package/dist/cjs/util/node/formatTableForTerminal.js.map +1 -0
  99. package/dist/cjs/util/object/arrAssign.js +6 -0
  100. package/dist/cjs/util/object/arrAssign.js.map +1 -0
  101. package/dist/cjs/util/object/createArrayMerger.js +20 -0
  102. package/dist/cjs/util/object/createArrayMerger.js.map +1 -0
  103. package/dist/cjs/util/object/createObjectMerger.js +20 -0
  104. package/dist/cjs/util/object/createObjectMerger.js.map +1 -0
  105. package/dist/cjs/util/object/objAssign.js +6 -0
  106. package/dist/cjs/util/object/objAssign.js.map +1 -0
  107. package/dist/cjs/util/object/objUpdatePropertyDescriptors.js +28 -0
  108. package/dist/cjs/util/object/objUpdatePropertyDescriptors.js.map +1 -0
  109. package/dist/cjs/util/object/realizeLazyProperty.js +14 -0
  110. package/dist/cjs/util/object/realizeLazyProperty.js.map +1 -0
  111. package/dist/cjs/util/object/setNonEnumerable.js +25 -0
  112. package/dist/cjs/util/object/setNonEnumerable.js.map +1 -0
  113. package/dist/cjs/util/os/defaultOpenInEditorCommand.js +18 -0
  114. package/dist/cjs/util/os/defaultOpenInEditorCommand.js.map +1 -0
  115. package/dist/cjs/util/os/isOSX.js +13 -0
  116. package/dist/cjs/util/os/isOSX.js.map +1 -0
  117. package/dist/cjs/util/os/isVsCodeInstalled.js +19 -0
  118. package/dist/cjs/util/os/isVsCodeInstalled.js.map +1 -0
  119. package/dist/cjs/util/os/isWindows.js +16 -0
  120. package/dist/cjs/util/os/isWindows.js.map +1 -0
  121. package/dist/cjs/util/path/getTempDataPath.js +20 -0
  122. package/dist/cjs/util/path/getTempDataPath.js.map +1 -0
  123. package/dist/cjs/util/regex/regexEscapeString.js +18 -0
  124. package/dist/cjs/util/regex/regexEscapeString.js.map +1 -0
  125. package/dist/cjs/util/string/strEnsureStartsWith.js +19 -0
  126. package/dist/cjs/util/string/strEnsureStartsWith.js.map +1 -0
  127. package/dist/cjs/util/string/strFirstCharToUpperCase.js +16 -0
  128. package/dist/cjs/util/string/strFirstCharToUpperCase.js.map +1 -0
  129. package/dist/cjs/util/string/strIsLowerCase.js +18 -0
  130. package/dist/cjs/util/string/strIsLowerCase.js.map +1 -0
  131. package/dist/cjs/util/string/strIsUpperCase.js +18 -0
  132. package/dist/cjs/util/string/strIsUpperCase.js.map +1 -0
  133. package/dist/cjs/util/string/strSplitCamelCase.js +55 -0
  134. package/dist/cjs/util/string/strSplitCamelCase.js.map +1 -0
  135. package/dist/cjs/util/string-parsers/createBooleanParser.js +21 -0
  136. package/dist/cjs/util/string-parsers/createBooleanParser.js.map +1 -0
  137. package/dist/cjs/util/string-parsers/createTypedListParser.js +22 -0
  138. package/dist/cjs/util/string-parsers/createTypedListParser.js.map +1 -0
  139. package/dist/cjs/util/string-parsers/parseBoolean.js +15 -0
  140. package/dist/cjs/util/string-parsers/parseBoolean.js.map +1 -0
  141. package/dist/cjs/util/string-parsers/parseInteger.js +17 -0
  142. package/dist/cjs/util/string-parsers/parseInteger.js.map +1 -0
  143. package/dist/cjs/util/string-parsers/parseNumber.js +13 -0
  144. package/dist/cjs/util/string-parsers/parseNumber.js.map +1 -0
  145. package/dist/cjs/util/string-parsers/parseString.js +8 -0
  146. package/dist/cjs/util/string-parsers/parseString.js.map +1 -0
  147. package/dist/cjs/util/types/Any.js +3 -0
  148. package/dist/cjs/util/types/Any.js.map +1 -0
  149. package/dist/cjs/util/types/DeepArray.js +3 -0
  150. package/dist/cjs/util/types/DeepArray.js.map +1 -0
  151. package/dist/cjs/util/types/DeepObject.js +3 -0
  152. package/dist/cjs/util/types/DeepObject.js.map +1 -0
  153. package/dist/cjs/util/types/JsonArray.js +3 -0
  154. package/dist/cjs/util/types/JsonArray.js.map +1 -0
  155. package/dist/cjs/util/types/JsonDefinedPrimitive.js +6 -0
  156. package/dist/cjs/util/types/JsonDefinedPrimitive.js.map +1 -0
  157. package/dist/cjs/util/types/JsonObject.js +3 -0
  158. package/dist/cjs/util/types/JsonObject.js.map +1 -0
  159. package/dist/cjs/util/types/JsonRawPrimitive.js +3 -0
  160. package/dist/cjs/util/types/JsonRawPrimitive.js.map +1 -0
  161. package/dist/cjs/util/types/JsonValue.js +3 -0
  162. package/dist/cjs/util/types/JsonValue.js.map +1 -0
  163. package/dist/cjs/util/types/ObjectKey.js +3 -0
  164. package/dist/cjs/util/types/ObjectKey.js.map +1 -0
  165. package/dist/cjs/util/types/TConstructor.js +3 -0
  166. package/dist/cjs/util/types/TConstructor.js.map +1 -0
  167. package/dist/cjs/util/types/TFunction.js +3 -0
  168. package/dist/cjs/util/types/TFunction.js.map +1 -0
  169. package/dist/cjs/util/types/TFunctionNoNew.js +3 -0
  170. package/dist/cjs/util/types/TFunctionNoNew.js.map +1 -0
  171. package/dist/cjs/util/types/TPlainObject.js +3 -0
  172. package/dist/cjs/util/types/TPlainObject.js.map +1 -0
  173. package/dist/cjs/util/types/TPrimitive.js +3 -0
  174. package/dist/cjs/util/types/TPrimitive.js.map +1 -0
  175. package/dist/cjs/util/types/TStringParser.js +3 -0
  176. package/dist/cjs/util/types/TStringParser.js.map +1 -0
  177. package/dist/cjs/util/types/TValidator.js +3 -0
  178. package/dist/cjs/util/types/TValidator.js.map +1 -0
  179. package/dist/cjs/util/validation/createTypedArrayValidator.js +26 -0
  180. package/dist/cjs/util/validation/createTypedArrayValidator.js.map +1 -0
  181. package/dist/cjs/util/validation/ensureThat.js +12 -0
  182. package/dist/cjs/util/validation/ensureThat.js.map +1 -0
  183. package/dist/cjs/util/validation/isArray.js +5 -0
  184. package/dist/cjs/util/validation/isArray.js.map +1 -0
  185. package/dist/cjs/util/validation/isBoolean.js +8 -0
  186. package/dist/cjs/util/validation/isBoolean.js.map +1 -0
  187. package/dist/cjs/util/validation/isFunction.js +17 -0
  188. package/dist/cjs/util/validation/isFunction.js.map +1 -0
  189. package/dist/cjs/util/validation/isNamedFunction.js +11 -0
  190. package/dist/cjs/util/validation/isNamedFunction.js.map +1 -0
  191. package/dist/cjs/util/validation/isNamedFunctionArray.js +9 -0
  192. package/dist/cjs/util/validation/isNamedFunctionArray.js.map +1 -0
  193. package/dist/cjs/util/validation/isObject.js +22 -0
  194. package/dist/cjs/util/validation/isObject.js.map +1 -0
  195. package/dist/cjs/util/validation/isPlainObject.js +19 -0
  196. package/dist/cjs/util/validation/isPlainObject.js.map +1 -0
  197. package/dist/cjs/util/validation/isPrimitive.js +18 -0
  198. package/dist/cjs/util/validation/isPrimitive.js.map +1 -0
  199. package/dist/cjs/util/validation/isString.js +8 -0
  200. package/dist/cjs/util/validation/isString.js.map +1 -0
  201. package/dist/cjs/util/validation/isStringArray.js +12 -0
  202. package/dist/cjs/util/validation/isStringArray.js.map +1 -0
  203. package/dist/cjs/util/validation/isStringWithNoSpacesOrDashes.js +9 -0
  204. package/dist/cjs/util/validation/isStringWithNoSpacesOrDashes.js.map +1 -0
  205. package/dist/cjs/util/validation/numbers/isInteger.js +17 -0
  206. package/dist/cjs/util/validation/numbers/isInteger.js.map +1 -0
  207. package/dist/cjs/util/validation/numbers/isValidNumber.js +22 -0
  208. package/dist/cjs/util/validation/numbers/isValidNumber.js.map +1 -0
  209. package/dist/esm/_example/bFindIn.js +187 -0
  210. package/dist/esm/_example/bFindIn.js.map +1 -0
  211. package/dist/esm/arg/ArgumentBuilder.js +41 -0
  212. package/dist/esm/arg/ArgumentBuilder.js.map +1 -0
  213. package/dist/esm/arg/ArgumentParserSelector.js +11 -0
  214. package/dist/esm/arg/ArgumentParserSelector.js.map +1 -0
  215. package/dist/esm/arg/ArgumentReader.js +34 -0
  216. package/dist/esm/arg/ArgumentReader.js.map +1 -0
  217. package/dist/esm/arg/ArgumentValidatorSelector.js +12 -0
  218. package/dist/esm/arg/ArgumentValidatorSelector.js.map +1 -0
  219. package/dist/esm/cmd/CommandBuilder.js +1073 -0
  220. package/dist/esm/cmd/CommandBuilder.js.map +1 -0
  221. package/dist/esm/cmd/CommandBuilderMetaData.js +40 -0
  222. package/dist/esm/cmd/CommandBuilderMetaData.js.map +1 -0
  223. package/dist/esm/cmd/CommandFeatureSelector.js +108 -0
  224. package/dist/esm/cmd/CommandFeatureSelector.js.map +1 -0
  225. package/dist/esm/cmd/DefaultHelpConfig.js +135 -0
  226. package/dist/esm/cmd/DefaultHelpConfig.js.map +1 -0
  227. package/dist/esm/cmd/asdas.js +25 -0
  228. package/dist/esm/cmd/asdas.js.map +1 -0
  229. package/dist/esm/core/OutputManager.js +92 -0
  230. package/dist/esm/core/OutputManager.js.map +1 -0
  231. package/dist/esm/core/ParserSelector.js +32 -0
  232. package/dist/esm/core/ParserSelector.js.map +1 -0
  233. package/dist/esm/core/ValidatorSelector.js +32 -0
  234. package/dist/esm/core/ValidatorSelector.js.map +1 -0
  235. package/dist/esm/core/splitCombinedArgvShorts.js +11 -0
  236. package/dist/esm/core/splitCombinedArgvShorts.js.map +1 -0
  237. package/dist/esm/db/AbstractJsonFileSection.js +186 -0
  238. package/dist/esm/db/AbstractJsonFileSection.js.map +1 -0
  239. package/dist/esm/db/AppDataSection.js +44 -0
  240. package/dist/esm/db/AppDataSection.js.map +1 -0
  241. package/dist/esm/db/ConfigSection.js +67 -0
  242. package/dist/esm/db/ConfigSection.js.map +1 -0
  243. package/dist/esm/db/JsonFile.js +51 -0
  244. package/dist/esm/db/JsonFile.js.map +1 -0
  245. package/dist/esm/db/PresetsSection.js +88 -0
  246. package/dist/esm/db/PresetsSection.js.map +1 -0
  247. package/dist/esm/index.js +103 -0
  248. package/dist/esm/index.js.map +1 -0
  249. package/dist/esm/opt/OptionArgumentParserSelector.js +12 -0
  250. package/dist/esm/opt/OptionArgumentParserSelector.js.map +1 -0
  251. package/dist/esm/opt/OptionArgumentValidatorSelector.js +15 -0
  252. package/dist/esm/opt/OptionArgumentValidatorSelector.js.map +1 -0
  253. package/dist/esm/opt/OptionBuilder.js +84 -0
  254. package/dist/esm/opt/OptionBuilder.js.map +1 -0
  255. package/dist/esm/opt/OptionHelpers.js +54 -0
  256. package/dist/esm/opt/OptionHelpers.js.map +1 -0
  257. package/dist/esm/opt/OptionReader.js +62 -0
  258. package/dist/esm/opt/OptionReader.js.map +1 -0
  259. package/dist/esm/types/IConfig.js +2 -0
  260. package/dist/esm/types/IConfig.js.map +1 -0
  261. package/dist/esm/types/IPreset.js +2 -0
  262. package/dist/esm/types/IPreset.js.map +1 -0
  263. package/dist/esm/util/array/arrLast.js +17 -0
  264. package/dist/esm/util/array/arrLast.js.map +1 -0
  265. package/dist/esm/util/array/arrSome.js +22 -0
  266. package/dist/esm/util/array/arrSome.js.map +1 -0
  267. package/dist/esm/util/array/types/ArrayPredicate.js +2 -0
  268. package/dist/esm/util/array/types/ArrayPredicate.js.map +1 -0
  269. package/dist/esm/util/db/JsonDB.js +141 -0
  270. package/dist/esm/util/db/JsonDB.js.map +1 -0
  271. package/dist/esm/util/errors/ErrorParser.js +154 -0
  272. package/dist/esm/util/errors/ErrorParser.js.map +1 -0
  273. package/dist/esm/util/fs/promptUserEditInTextEditor/IGetUserInputFromEditorOptions.js +2 -0
  274. package/dist/esm/util/fs/promptUserEditInTextEditor/IGetUserInputFromEditorOptions.js.map +1 -0
  275. package/dist/esm/util/fs/promptUserEditInTextEditor/promptUserEditInTextEditorSync.js +28 -0
  276. package/dist/esm/util/fs/promptUserEditInTextEditor/promptUserEditInTextEditorSync.js.map +1 -0
  277. package/dist/esm/util/fs/promptUserEditInTextEditor/promptUserEditJsonInTextEditorSync.js +21 -0
  278. package/dist/esm/util/fs/promptUserEditInTextEditor/promptUserEditJsonInTextEditorSync.js.map +1 -0
  279. package/dist/esm/util/fs/readFile/readFileSafeSync.js +21 -0
  280. package/dist/esm/util/fs/readFile/readFileSafeSync.js.map +1 -0
  281. package/dist/esm/util/fs/readFile/readFileSync.js +13 -0
  282. package/dist/esm/util/fs/readFile/readFileSync.js.map +1 -0
  283. package/dist/esm/util/fs/readJsonFile/readJsonFileSafeSync.js +17 -0
  284. package/dist/esm/util/fs/readJsonFile/readJsonFileSafeSync.js.map +1 -0
  285. package/dist/esm/util/fs/removeFile/removeFile.js +2 -0
  286. package/dist/esm/util/fs/removeFile/removeFile.js.map +1 -0
  287. package/dist/esm/util/fs/tempFile/tempFileSync.js +21 -0
  288. package/dist/esm/util/fs/tempFile/tempFileSync.js.map +1 -0
  289. package/dist/esm/util/fs/types/IReadJsonFileOptions.js +2 -0
  290. package/dist/esm/util/fs/types/IReadJsonFileOptions.js.map +1 -0
  291. package/dist/esm/util/fs/writeFile/writeFileSafeSync.js +2 -0
  292. package/dist/esm/util/fs/writeFile/writeFileSafeSync.js.map +1 -0
  293. package/dist/esm/util/fs/writeFile/writeFileSync.js +2 -0
  294. package/dist/esm/util/fs/writeFile/writeFileSync.js.map +1 -0
  295. package/dist/esm/util/fs/writeJsonFile/writeJsonFileSafe.js +2 -0
  296. package/dist/esm/util/fs/writeJsonFile/writeJsonFileSafe.js.map +1 -0
  297. package/dist/esm/util/function/MethodDisabler.js +90 -0
  298. package/dist/esm/util/function/MethodDisabler.js.map +1 -0
  299. package/dist/esm/util/function/funSetName.js +17 -0
  300. package/dist/esm/util/function/funSetName.js.map +1 -0
  301. package/dist/esm/util/node/execInherit.js +15 -0
  302. package/dist/esm/util/node/execInherit.js.map +1 -0
  303. package/dist/esm/util/node/formatTableForTerminal.js +14 -0
  304. package/dist/esm/util/node/formatTableForTerminal.js.map +1 -0
  305. package/dist/esm/util/object/arrAssign.js +3 -0
  306. package/dist/esm/util/object/arrAssign.js.map +1 -0
  307. package/dist/esm/util/object/createArrayMerger.js +16 -0
  308. package/dist/esm/util/object/createArrayMerger.js.map +1 -0
  309. package/dist/esm/util/object/createObjectMerger.js +16 -0
  310. package/dist/esm/util/object/createObjectMerger.js.map +1 -0
  311. package/dist/esm/util/object/objAssign.js +3 -0
  312. package/dist/esm/util/object/objAssign.js.map +1 -0
  313. package/dist/esm/util/object/objUpdatePropertyDescriptors.js +24 -0
  314. package/dist/esm/util/object/objUpdatePropertyDescriptors.js.map +1 -0
  315. package/dist/esm/util/object/realizeLazyProperty.js +10 -0
  316. package/dist/esm/util/object/realizeLazyProperty.js.map +1 -0
  317. package/dist/esm/util/object/setNonEnumerable.js +21 -0
  318. package/dist/esm/util/object/setNonEnumerable.js.map +1 -0
  319. package/dist/esm/util/os/defaultOpenInEditorCommand.js +14 -0
  320. package/dist/esm/util/os/defaultOpenInEditorCommand.js.map +1 -0
  321. package/dist/esm/util/os/isOSX.js +9 -0
  322. package/dist/esm/util/os/isOSX.js.map +1 -0
  323. package/dist/esm/util/os/isVsCodeInstalled.js +15 -0
  324. package/dist/esm/util/os/isVsCodeInstalled.js.map +1 -0
  325. package/dist/esm/util/os/isWindows.js +12 -0
  326. package/dist/esm/util/os/isWindows.js.map +1 -0
  327. package/dist/esm/util/path/getTempDataPath.js +13 -0
  328. package/dist/esm/util/path/getTempDataPath.js.map +1 -0
  329. package/dist/esm/util/regex/regexEscapeString.js +14 -0
  330. package/dist/esm/util/regex/regexEscapeString.js.map +1 -0
  331. package/dist/esm/util/string/strEnsureStartsWith.js +15 -0
  332. package/dist/esm/util/string/strEnsureStartsWith.js.map +1 -0
  333. package/dist/esm/util/string/strFirstCharToUpperCase.js +12 -0
  334. package/dist/esm/util/string/strFirstCharToUpperCase.js.map +1 -0
  335. package/dist/esm/util/string/strIsLowerCase.js +14 -0
  336. package/dist/esm/util/string/strIsLowerCase.js.map +1 -0
  337. package/dist/esm/util/string/strIsUpperCase.js +14 -0
  338. package/dist/esm/util/string/strIsUpperCase.js.map +1 -0
  339. package/dist/esm/util/string/strSplitCamelCase.js +51 -0
  340. package/dist/esm/util/string/strSplitCamelCase.js.map +1 -0
  341. package/dist/esm/util/string-parsers/createBooleanParser.js +17 -0
  342. package/dist/esm/util/string-parsers/createBooleanParser.js.map +1 -0
  343. package/dist/esm/util/string-parsers/createTypedListParser.js +18 -0
  344. package/dist/esm/util/string-parsers/createTypedListParser.js.map +1 -0
  345. package/dist/esm/util/string-parsers/parseBoolean.js +12 -0
  346. package/dist/esm/util/string-parsers/parseBoolean.js.map +1 -0
  347. package/dist/esm/util/string-parsers/parseInteger.js +13 -0
  348. package/dist/esm/util/string-parsers/parseInteger.js.map +1 -0
  349. package/dist/esm/util/string-parsers/parseNumber.js +9 -0
  350. package/dist/esm/util/string-parsers/parseNumber.js.map +1 -0
  351. package/dist/esm/util/string-parsers/parseString.js +4 -0
  352. package/dist/esm/util/string-parsers/parseString.js.map +1 -0
  353. package/dist/esm/util/types/Any.js +2 -0
  354. package/dist/esm/util/types/Any.js.map +1 -0
  355. package/dist/esm/util/types/DeepArray.js +2 -0
  356. package/dist/esm/util/types/DeepArray.js.map +1 -0
  357. package/dist/esm/util/types/DeepObject.js +2 -0
  358. package/dist/esm/util/types/DeepObject.js.map +1 -0
  359. package/dist/esm/util/types/JsonArray.js +2 -0
  360. package/dist/esm/util/types/JsonArray.js.map +1 -0
  361. package/dist/esm/util/types/JsonDefinedPrimitive.js +5 -0
  362. package/dist/esm/util/types/JsonDefinedPrimitive.js.map +1 -0
  363. package/dist/esm/util/types/JsonObject.js +2 -0
  364. package/dist/esm/util/types/JsonObject.js.map +1 -0
  365. package/dist/esm/util/types/JsonRawPrimitive.js +2 -0
  366. package/dist/esm/util/types/JsonRawPrimitive.js.map +1 -0
  367. package/dist/esm/util/types/JsonValue.js +2 -0
  368. package/dist/esm/util/types/JsonValue.js.map +1 -0
  369. package/dist/esm/util/types/ObjectKey.js +2 -0
  370. package/dist/esm/util/types/ObjectKey.js.map +1 -0
  371. package/dist/esm/util/types/TConstructor.js +2 -0
  372. package/dist/esm/util/types/TConstructor.js.map +1 -0
  373. package/dist/esm/util/types/TFunction.js +2 -0
  374. package/dist/esm/util/types/TFunction.js.map +1 -0
  375. package/dist/esm/util/types/TFunctionNoNew.js +2 -0
  376. package/dist/esm/util/types/TFunctionNoNew.js.map +1 -0
  377. package/dist/esm/util/types/TPlainObject.js +2 -0
  378. package/dist/esm/util/types/TPlainObject.js.map +1 -0
  379. package/dist/esm/util/types/TPrimitive.js +2 -0
  380. package/dist/esm/util/types/TPrimitive.js.map +1 -0
  381. package/dist/esm/util/types/TStringParser.js +2 -0
  382. package/dist/esm/util/types/TStringParser.js.map +1 -0
  383. package/dist/esm/util/types/TValidator.js +2 -0
  384. package/dist/esm/util/types/TValidator.js.map +1 -0
  385. package/dist/esm/util/validation/createTypedArrayValidator.js +22 -0
  386. package/dist/esm/util/validation/createTypedArrayValidator.js.map +1 -0
  387. package/dist/esm/util/validation/ensureThat.js +8 -0
  388. package/dist/esm/util/validation/ensureThat.js.map +1 -0
  389. package/dist/esm/util/validation/isArray.js +2 -0
  390. package/dist/esm/util/validation/isArray.js.map +1 -0
  391. package/dist/esm/util/validation/isBoolean.js +4 -0
  392. package/dist/esm/util/validation/isBoolean.js.map +1 -0
  393. package/dist/esm/util/validation/isFunction.js +13 -0
  394. package/dist/esm/util/validation/isFunction.js.map +1 -0
  395. package/dist/esm/util/validation/isNamedFunction.js +7 -0
  396. package/dist/esm/util/validation/isNamedFunction.js.map +1 -0
  397. package/dist/esm/util/validation/isNamedFunctionArray.js +5 -0
  398. package/dist/esm/util/validation/isNamedFunctionArray.js.map +1 -0
  399. package/dist/esm/util/validation/isObject.js +18 -0
  400. package/dist/esm/util/validation/isObject.js.map +1 -0
  401. package/dist/esm/util/validation/isPlainObject.js +15 -0
  402. package/dist/esm/util/validation/isPlainObject.js.map +1 -0
  403. package/dist/esm/util/validation/isPrimitive.js +14 -0
  404. package/dist/esm/util/validation/isPrimitive.js.map +1 -0
  405. package/dist/esm/util/validation/isString.js +4 -0
  406. package/dist/esm/util/validation/isString.js.map +1 -0
  407. package/dist/esm/util/validation/isStringArray.js +8 -0
  408. package/dist/esm/util/validation/isStringArray.js.map +1 -0
  409. package/dist/esm/util/validation/isStringWithNoSpacesOrDashes.js +5 -0
  410. package/dist/esm/util/validation/isStringWithNoSpacesOrDashes.js.map +1 -0
  411. package/dist/esm/util/validation/numbers/isInteger.js +14 -0
  412. package/dist/esm/util/validation/numbers/isInteger.js.map +1 -0
  413. package/dist/esm/util/validation/numbers/isValidNumber.js +18 -0
  414. package/dist/esm/util/validation/numbers/isValidNumber.js.map +1 -0
  415. package/dist/types/_example/bFindIn.d.ts +1 -0
  416. package/{src → dist/types}/arg/ArgumentBuilder.d.ts +1 -1
  417. package/{src → dist/types}/arg/ArgumentParserSelector.d.ts +2 -2
  418. package/{src → dist/types}/arg/ArgumentReader.d.ts +3 -3
  419. package/{src → dist/types}/arg/ArgumentValidatorSelector.d.ts +2 -2
  420. package/{src → dist/types}/cmd/CommandBuilder.d.ts +32 -28
  421. package/{src → dist/types}/cmd/CommandBuilderMetaData.d.ts +8 -7
  422. package/{src → dist/types}/cmd/CommandFeatureSelector.d.ts +1 -1
  423. package/dist/types/cmd/DefaultHelpConfig.d.ts +28 -0
  424. package/dist/types/cmd/asdas.d.ts +6 -0
  425. package/{src → dist/types}/core/OutputManager.d.ts +1 -1
  426. package/{src → dist/types}/core/ParserSelector.d.ts +3 -3
  427. package/{src → dist/types}/core/ValidatorSelector.d.ts +2 -2
  428. package/{src → dist/types}/db/AbstractJsonFileSection.d.ts +3 -3
  429. package/{src → dist/types}/db/AppDataSection.d.ts +1 -1
  430. package/{src → dist/types}/db/ConfigSection.d.ts +4 -4
  431. package/{src → dist/types}/db/PresetsSection.d.ts +2 -2
  432. package/{src → dist/types}/index.d.ts +2 -2
  433. package/{src → dist/types}/opt/OptionArgumentParserSelector.d.ts +1 -1
  434. package/{src → dist/types}/opt/OptionArgumentValidatorSelector.d.ts +2 -2
  435. package/{src → dist/types}/opt/OptionBuilder.d.ts +2 -1
  436. package/{src → dist/types}/opt/OptionHelpers.d.ts +2 -2
  437. package/{src → dist/types}/opt/OptionReader.d.ts +7 -7
  438. package/{src → dist/types}/types/IConfig.d.ts +3 -3
  439. package/{src → dist/types}/types/IPreset.d.ts +4 -3
  440. package/{src → dist/types}/util/db/JsonDB.d.ts +2 -2
  441. package/{src → dist/types}/util/fs/promptUserEditInTextEditor/promptUserEditInTextEditorSync.d.ts +1 -1
  442. package/{src → dist/types}/util/fs/promptUserEditInTextEditor/promptUserEditJsonInTextEditorSync.d.ts +1 -1
  443. package/{src → dist/types}/util/fs/readJsonFile/readJsonFileSafeSync.d.ts +1 -1
  444. package/{src → dist/types}/util/fs/tempFile/tempFileSync.d.ts +1 -1
  445. package/{src → dist/types}/util/function/MethodDisabler.d.ts +3 -3
  446. package/{src → dist/types}/util/object/createObjectMerger.d.ts +1 -1
  447. package/{src → dist/types}/util/object/objUpdatePropertyDescriptors.d.ts +1 -1
  448. package/{src → dist/types}/util/object/setNonEnumerable.d.ts +1 -1
  449. package/{src → dist/types}/util/string-parsers/createTypedListParser.d.ts +1 -1
  450. package/{src → dist/types}/util/types/DeepArray.d.ts +2 -2
  451. package/{src → dist/types}/util/types/DeepObject.d.ts +2 -2
  452. package/{src → dist/types}/util/types/JsonArray.d.ts +2 -2
  453. package/{src → dist/types}/util/types/JsonObject.d.ts +2 -2
  454. package/{src → dist/types}/util/types/JsonRawPrimitive.d.ts +1 -1
  455. package/{src → dist/types}/util/types/JsonValue.d.ts +3 -3
  456. package/{src → dist/types}/util/types/TConstructor.d.ts +1 -1
  457. package/dist/types/util/types/TFunction.d.ts +4 -0
  458. package/{src → dist/types}/util/types/TFunctionNoNew.d.ts +1 -1
  459. package/{src → dist/types}/util/types/TPlainObject.d.ts +1 -1
  460. package/dist/types/util/types/TValidator.d.ts +2 -0
  461. package/{src → dist/types}/util/validation/ensureThat.d.ts +2 -2
  462. package/{src → dist/types}/util/validation/isFunction.d.ts +1 -1
  463. package/{src → dist/types}/util/validation/isNamedFunction.d.ts +1 -1
  464. package/{src → dist/types}/util/validation/isPlainObject.d.ts +2 -2
  465. package/{src → dist/types}/util/validation/isPrimitive.d.ts +1 -1
  466. package/jest.config.ts +11 -0
  467. package/notes/tsc.md +1 -0
  468. package/package.json +13 -6
  469. package/project.json +44 -0
  470. package/scripts/currentBemojeUtils.txt +41 -0
  471. package/scripts/rollupUtils.ts +184 -0
  472. package/src/_example/CommandBuilder.example.ts +92 -0
  473. package/src/_example/CommandBuilder.example2.ts +30 -0
  474. package/src/_example/bFindIn.ts +200 -0
  475. package/src/arg/ArgumentBuilder.test.ts +102 -0
  476. package/src/arg/ArgumentBuilder.ts +47 -0
  477. package/src/arg/ArgumentParserSelector.test.ts +53 -0
  478. package/src/arg/ArgumentParserSelector.ts +14 -0
  479. package/src/arg/ArgumentReader.test.ts +60 -0
  480. package/src/arg/ArgumentReader.ts +33 -0
  481. package/src/arg/ArgumentValidatorSelector.test.ts +80 -0
  482. package/src/arg/ArgumentValidatorSelector.ts +14 -0
  483. package/src/cmd/CommandBuilder.test.ts +611 -0
  484. package/src/cmd/CommandBuilder.ts +1164 -0
  485. package/src/cmd/CommandBuilderMetaData.test.ts +54 -0
  486. package/src/cmd/CommandBuilderMetaData.ts +45 -0
  487. package/src/cmd/CommandFeatureSelector.test.ts +185 -0
  488. package/src/cmd/CommandFeatureSelector.ts +113 -0
  489. package/src/cmd/DefaultHelpConfig.test.ts +22 -0
  490. package/src/cmd/DefaultHelpConfig.ts +141 -0
  491. package/src/cmd/asdas.ts +40 -0
  492. package/src/core/OutputManager.test.ts +129 -0
  493. package/src/core/OutputManager.ts +103 -0
  494. package/src/core/ParserSelector.test.ts +7 -0
  495. package/src/core/ParserSelector.ts +38 -0
  496. package/src/core/ValidatorSelector.test.ts +7 -0
  497. package/src/core/ValidatorSelector.ts +38 -0
  498. package/src/core/splitCombinedArgvShorts.test.ts +9 -0
  499. package/src/core/splitCombinedArgvShorts.ts +10 -0
  500. package/src/db/AbstractJsonFileSection.test.ts +274 -0
  501. package/src/db/AbstractJsonFileSection.ts +218 -0
  502. package/src/db/AppDataSection.test.ts +69 -0
  503. package/src/db/AppDataSection.ts +46 -0
  504. package/src/db/ConfigSection.test.ts +95 -0
  505. package/src/db/ConfigSection.ts +74 -0
  506. package/src/db/JsonFile.test.ts +56 -0
  507. package/src/db/JsonFile.ts +52 -0
  508. package/src/db/PresetsSection.test.ts +130 -0
  509. package/src/db/PresetsSection.ts +92 -0
  510. package/src/index.ts +102 -0
  511. package/src/opt/OptionArgumentParserSelector.test.ts +55 -0
  512. package/src/opt/OptionArgumentParserSelector.ts +14 -0
  513. package/src/opt/OptionArgumentValidatorSelector.test.ts +89 -0
  514. package/src/opt/OptionArgumentValidatorSelector.ts +16 -0
  515. package/src/opt/OptionBuilder.test.ts +229 -0
  516. package/src/opt/OptionBuilder.ts +85 -0
  517. package/src/opt/OptionHelpers.test.ts +229 -0
  518. package/src/opt/OptionHelpers.ts +57 -0
  519. package/src/opt/OptionReader.test.ts +106 -0
  520. package/src/opt/OptionReader.ts +61 -0
  521. package/src/types/IConfig.ts +25 -0
  522. package/src/types/IPreset.ts +16 -0
  523. package/src/util/array/arrLast.test.ts +25 -0
  524. package/src/util/array/arrLast.ts +15 -0
  525. package/src/util/array/arrSome.test.ts +78 -0
  526. package/src/util/array/arrSome.ts +23 -0
  527. package/src/util/array/types/ArrayPredicate.ts +10 -0
  528. package/src/util/db/JsonDB.test.ts +214 -0
  529. package/src/util/db/JsonDB.ts +138 -0
  530. package/src/util/errors/ErrorParser.ts +165 -0
  531. package/src/util/fs/promptUserEditInTextEditor/IGetUserInputFromEditorOptions.ts +15 -0
  532. package/src/util/fs/promptUserEditInTextEditor/promptUserEditInTextEditorSync.ts +30 -0
  533. package/src/util/fs/promptUserEditInTextEditor/promptUserEditJsonInTextEditorSync.ts +25 -0
  534. package/src/util/fs/readFile/readFileSafeSync.ts +20 -0
  535. package/src/util/fs/readFile/readFileSync.ts +13 -0
  536. package/src/util/fs/readJsonFile/readJsonFileSafeSync.ts +17 -0
  537. package/src/util/fs/removeFile/removeFile.ts +1 -0
  538. package/src/util/fs/tempFile/tempFileSync.ts +21 -0
  539. package/src/util/fs/types/IReadJsonFileOptions.ts +1 -0
  540. package/src/util/fs/writeFile/writeFileSafeSync.ts +1 -0
  541. package/src/util/fs/writeFile/writeFileSync.ts +1 -0
  542. package/src/util/fs/writeJsonFile/writeJsonFileSafe.ts +1 -0
  543. package/src/util/function/MethodDisabler.test.ts +112 -0
  544. package/src/util/function/MethodDisabler.ts +94 -0
  545. package/src/util/function/funSetName.test.ts +12 -0
  546. package/src/util/function/funSetName.ts +16 -0
  547. package/src/util/node/execInherit.ts +14 -0
  548. package/src/util/node/formatTableForTerminal.ts +12 -0
  549. package/src/util/object/arrAssign.ts +3 -0
  550. package/src/util/object/createArrayMerger.test.ts +11 -0
  551. package/src/util/object/createArrayMerger.ts +15 -0
  552. package/src/util/object/createObjectMerger.test.ts +11 -0
  553. package/src/util/object/createObjectMerger.ts +17 -0
  554. package/src/util/object/objAssign.ts +3 -0
  555. package/src/util/object/objUpdatePropertyDescriptors.test.ts +40 -0
  556. package/src/util/object/objUpdatePropertyDescriptors.ts +29 -0
  557. package/src/util/object/realizeLazyProperty.ts +9 -0
  558. package/src/util/object/setNonEnumerable.test.ts +63 -0
  559. package/src/util/object/setNonEnumerable.ts +22 -0
  560. package/src/util/os/defaultOpenInEditorCommand.ts +14 -0
  561. package/src/util/os/isOSX.ts +9 -0
  562. package/src/util/os/isVsCodeInstalled.test.ts +7 -0
  563. package/src/util/os/isVsCodeInstalled.ts +14 -0
  564. package/src/util/os/isWindows.ts +12 -0
  565. package/src/util/path/getTempDataPath.test.ts +9 -0
  566. package/src/util/path/getTempDataPath.ts +14 -0
  567. package/src/util/regex/regexEscapeString.test.ts +35 -0
  568. package/src/util/regex/regexEscapeString.ts +13 -0
  569. package/src/util/string/strEnsureStartsWith.test.ts +13 -0
  570. package/src/util/string/strEnsureStartsWith.ts +14 -0
  571. package/src/util/string/strFirstCharToUpperCase.test.ts +33 -0
  572. package/src/util/string/strFirstCharToUpperCase.ts +11 -0
  573. package/src/util/string/strIsLowerCase.test.ts +42 -0
  574. package/src/util/string/strIsLowerCase.ts +13 -0
  575. package/src/util/string/strIsUpperCase.test.ts +48 -0
  576. package/src/util/string/strIsUpperCase.ts +13 -0
  577. package/src/util/string/strSplitCamelCase.test.ts +54 -0
  578. package/src/util/string/strSplitCamelCase.ts +51 -0
  579. package/src/util/string-parsers/createBooleanParser.test.ts +58 -0
  580. package/src/util/string-parsers/createBooleanParser.ts +21 -0
  581. package/src/util/string-parsers/createTypedListParser.test.ts +19 -0
  582. package/src/util/string-parsers/createTypedListParser.ts +19 -0
  583. package/src/util/string-parsers/parseBoolean.test.ts +30 -0
  584. package/src/util/string-parsers/parseBoolean.ts +12 -0
  585. package/src/util/string-parsers/parseInteger.test.ts +52 -0
  586. package/src/util/string-parsers/parseInteger.ts +9 -0
  587. package/src/util/string-parsers/parseNumber.test.ts +53 -0
  588. package/src/util/string-parsers/parseNumber.ts +6 -0
  589. package/src/util/string-parsers/parseString.test.ts +7 -0
  590. package/src/util/string-parsers/parseString.ts +3 -0
  591. package/src/util/types/Any.ts +2 -0
  592. package/src/util/types/DeepArray.ts +12 -0
  593. package/src/util/types/DeepObject.ts +16 -0
  594. package/src/util/types/JsonArray.ts +8 -0
  595. package/src/util/types/JsonDefinedPrimitive.ts +5 -0
  596. package/src/util/types/JsonObject.ts +8 -0
  597. package/src/util/types/JsonRawPrimitive.ts +7 -0
  598. package/src/util/types/JsonValue.ts +14 -0
  599. package/src/util/types/ObjectKey.ts +1 -0
  600. package/src/util/types/TConstructor.ts +6 -0
  601. package/src/util/types/TFunction.ts +5 -0
  602. package/src/util/types/TFunctionNoNew.ts +3 -0
  603. package/src/util/types/TPlainObject.ts +4 -0
  604. package/src/util/types/TPrimitive.ts +1 -0
  605. package/src/util/types/TStringParser.ts +1 -0
  606. package/src/util/types/TValidator.ts +3 -0
  607. package/src/util/validation/createTypedArrayValidator.test.ts +34 -0
  608. package/src/util/validation/createTypedArrayValidator.ts +25 -0
  609. package/src/util/validation/ensureThat.test.ts +37 -0
  610. package/src/util/validation/ensureThat.ts +14 -0
  611. package/src/util/validation/isArray.test.ts +7 -0
  612. package/src/util/validation/isArray.ts +1 -0
  613. package/src/util/validation/isBoolean.test.ts +31 -0
  614. package/src/util/validation/isBoolean.ts +3 -0
  615. package/src/util/validation/isFunction.test.ts +54 -0
  616. package/src/util/validation/isFunction.ts +14 -0
  617. package/src/util/validation/isNamedFunction.test.ts +28 -0
  618. package/src/util/validation/isNamedFunction.ts +8 -0
  619. package/src/util/validation/isNamedFunctionArray.test.ts +14 -0
  620. package/src/util/validation/isNamedFunctionArray.ts +5 -0
  621. package/src/util/validation/isObject.test.ts +57 -0
  622. package/src/util/validation/isObject.ts +17 -0
  623. package/src/util/validation/isPlainObject.test.ts +21 -0
  624. package/src/util/validation/isPlainObject.ts +14 -0
  625. package/src/util/validation/isPrimitive.ts +15 -0
  626. package/src/util/validation/isString.test.ts +23 -0
  627. package/src/util/validation/isString.ts +3 -0
  628. package/src/util/validation/isStringArray.test.ts +24 -0
  629. package/src/util/validation/isStringArray.ts +8 -0
  630. package/src/util/validation/isStringWithNoSpacesOrDashes.test.ts +28 -0
  631. package/src/util/validation/isStringWithNoSpacesOrDashes.ts +5 -0
  632. package/src/util/validation/numbers/isInteger.test.ts +25 -0
  633. package/src/util/validation/numbers/isInteger.ts +13 -0
  634. package/src/util/validation/numbers/isValidNumber.test.ts +20 -0
  635. package/src/util/validation/numbers/isValidNumber.ts +17 -0
  636. package/tsconfig.json +32 -0
  637. package/tsconfig.lib.json +18 -0
  638. package/tsconfig.spec.json +10 -0
  639. package/index.cjs.d.ts +0 -1
  640. package/index.cjs.js +0 -3231
  641. package/index.esm.js +0 -3119
  642. package/src/cmd/CLI.d.ts +0 -2
  643. package/src/cmd/DefaultHelpConfig.d.ts +0 -2
  644. package/src/proto/overrideCommanderPrototype.d.ts +0 -8
  645. package/src/util/types/TFunction.d.ts +0 -4
  646. package/src/util/types/TValidator.d.ts +0 -1
  647. /package/{src → dist/types}/core/splitCombinedArgvShorts.d.ts +0 -0
  648. /package/{src → dist/types}/db/JsonFile.d.ts +0 -0
  649. /package/{src → dist/types}/util/array/arrLast.d.ts +0 -0
  650. /package/{src → dist/types}/util/array/arrSome.d.ts +0 -0
  651. /package/{src → dist/types}/util/array/types/ArrayPredicate.d.ts +0 -0
  652. /package/{src → dist/types}/util/errors/ErrorParser.d.ts +0 -0
  653. /package/{src → dist/types}/util/fs/promptUserEditInTextEditor/IGetUserInputFromEditorOptions.d.ts +0 -0
  654. /package/{src → dist/types}/util/fs/readFile/readFileSafeSync.d.ts +0 -0
  655. /package/{src → dist/types}/util/fs/readFile/readFileSync.d.ts +0 -0
  656. /package/{src → dist/types}/util/fs/removeFile/removeFile.d.ts +0 -0
  657. /package/{src → dist/types}/util/fs/types/IReadJsonFileOptions.d.ts +0 -0
  658. /package/{src → dist/types}/util/fs/writeFile/writeFileSafeSync.d.ts +0 -0
  659. /package/{src → dist/types}/util/fs/writeFile/writeFileSync.d.ts +0 -0
  660. /package/{src → dist/types}/util/fs/writeJsonFile/writeJsonFileSafe.d.ts +0 -0
  661. /package/{src → dist/types}/util/function/funSetName.d.ts +0 -0
  662. /package/{src → dist/types}/util/node/execInherit.d.ts +0 -0
  663. /package/{src → dist/types}/util/node/formatTableForTerminal.d.ts +0 -0
  664. /package/{src → dist/types}/util/object/arrAssign.d.ts +0 -0
  665. /package/{src → dist/types}/util/object/createArrayMerger.d.ts +0 -0
  666. /package/{src → dist/types}/util/object/objAssign.d.ts +0 -0
  667. /package/{src → dist/types}/util/object/realizeLazyProperty.d.ts +0 -0
  668. /package/{src → dist/types}/util/os/defaultOpenInEditorCommand.d.ts +0 -0
  669. /package/{src → dist/types}/util/os/isOSX.d.ts +0 -0
  670. /package/{src → dist/types}/util/os/isVsCodeInstalled.d.ts +0 -0
  671. /package/{src → dist/types}/util/os/isWindows.d.ts +0 -0
  672. /package/{src → dist/types}/util/path/getTempDataPath.d.ts +0 -0
  673. /package/{src → dist/types}/util/regex/regexEscapeString.d.ts +0 -0
  674. /package/{src → dist/types}/util/string/strEnsureStartsWith.d.ts +0 -0
  675. /package/{src → dist/types}/util/string/strFirstCharToUpperCase.d.ts +0 -0
  676. /package/{src → dist/types}/util/string/strIsLowerCase.d.ts +0 -0
  677. /package/{src → dist/types}/util/string/strIsUpperCase.d.ts +0 -0
  678. /package/{src → dist/types}/util/string/strSplitCamelCase.d.ts +0 -0
  679. /package/{src → dist/types}/util/string-parsers/createBooleanParser.d.ts +0 -0
  680. /package/{src → dist/types}/util/string-parsers/parseBoolean.d.ts +0 -0
  681. /package/{src → dist/types}/util/string-parsers/parseInteger.d.ts +0 -0
  682. /package/{src → dist/types}/util/string-parsers/parseNumber.d.ts +0 -0
  683. /package/{src → dist/types}/util/string-parsers/parseString.d.ts +0 -0
  684. /package/{src → dist/types}/util/types/Any.d.ts +0 -0
  685. /package/{src → dist/types}/util/types/JsonDefinedPrimitive.d.ts +0 -0
  686. /package/{src → dist/types}/util/types/ObjectKey.d.ts +0 -0
  687. /package/{src → dist/types}/util/types/TPrimitive.d.ts +0 -0
  688. /package/{src → dist/types}/util/types/TStringParser.d.ts +0 -0
  689. /package/{src → dist/types}/util/validation/createTypedArrayValidator.d.ts +0 -0
  690. /package/{src → dist/types}/util/validation/isArray.d.ts +0 -0
  691. /package/{src → dist/types}/util/validation/isBoolean.d.ts +0 -0
  692. /package/{src → dist/types}/util/validation/isNamedFunctionArray.d.ts +0 -0
  693. /package/{src → dist/types}/util/validation/isObject.d.ts +0 -0
  694. /package/{src → dist/types}/util/validation/isString.d.ts +0 -0
  695. /package/{src → dist/types}/util/validation/isStringArray.d.ts +0 -0
  696. /package/{src → dist/types}/util/validation/isStringWithNoSpacesOrDashes.d.ts +0 -0
  697. /package/{src → dist/types}/util/validation/numbers/isInteger.d.ts +0 -0
  698. /package/{src → dist/types}/util/validation/numbers/isValidNumber.d.ts +0 -0
@@ -0,0 +1,165 @@
1
+ import colors from 'ansi-colors'
2
+ import path from 'path'
3
+ import type { Any } from '../types/Any'
4
+ import { isPlainObject } from '../validation/isPlainObject'
5
+ import { isPrimitive } from '../validation/isPrimitive'
6
+ import { regexEscapeString } from '../regex/regexEscapeString'
7
+
8
+ export class ErrorParser {
9
+ readonly error: Error
10
+
11
+ constructor(error: unknown) {
12
+ this.error = error instanceof Error ? error : new Error(String(error))
13
+ }
14
+
15
+ get name() {
16
+ return this.error.name
17
+ }
18
+
19
+ get message() {
20
+ return this.error.message
21
+ }
22
+
23
+ get stack(): string {
24
+ return this.error.stack || ''
25
+ }
26
+
27
+ summary() {
28
+ return this.name + ': ' + this.message
29
+ }
30
+
31
+ parseStackFrames() {
32
+ return errParseStack(this.stack)
33
+ }
34
+
35
+ prettyStack(parsedStackFrames?: [string, string][]) {
36
+ return errPrettyStack(this.error, parsedStackFrames)
37
+ }
38
+
39
+ toObject() {
40
+ return errToObject(this.error)
41
+ }
42
+
43
+ toJSON() {
44
+ return this.toObject()
45
+ }
46
+ }
47
+
48
+ export function errPrettyStack(error: Error, parsedStackFrames?: [string, string][]) {
49
+ const frames = parsedStackFrames ?? errParseStack(error.stack || '')
50
+
51
+ // width of the first column = the longest frame.cell string
52
+ const offset = 2 + frames.reduce((acc: number, frame) => Math.max(acc, frame[0].length), 0)
53
+
54
+ // type and message
55
+ const result = [
56
+ colors.bold(colors.red(error.name)) +
57
+ ': ' +
58
+ ' '.repeat(Math.max(0, offset - error.name.length)) +
59
+ colors.red(error.message),
60
+ ]
61
+
62
+ // stack trace
63
+ result.push(colors.yellow('stack') + ':')
64
+ result.push(
65
+ frames
66
+ .map((frame: [string, string]) => {
67
+ const [call, file] = frame
68
+ let s = ' '
69
+ let fp: string
70
+ if (file.startsWith('node:')) {
71
+ s += colors.gray(call)
72
+ fp = colors.gray(file)
73
+ } else if (file.includes('node_modules')) {
74
+ s += call
75
+ const base = path.basename(file.split(':')[0])
76
+ fp = file.replace(base, colors.yellow(base))
77
+ } else {
78
+ s += call
79
+ const base = path.basename(file.split(':')[0])
80
+ fp = file.replace(base, colors.red(base))
81
+ }
82
+ s += ' '.repeat(offset - call.length)
83
+ s += fp
84
+ return s
85
+ })
86
+ .join('\n')
87
+ )
88
+
89
+ // other properties
90
+ const ignore = ['name', 'message', 'frames', 'stack']
91
+ const keys = Object.getOwnPropertyNames(error).filter((key) => !ignore.includes(key))
92
+ for (const k of keys) {
93
+ if (typeof k === 'symbol') continue
94
+ const key = k as keyof typeof error
95
+ let s = colors.yellow(key.toString()) + ': '
96
+ if (isPlainObject(error[key])) {
97
+ const json = JSON.stringify(error[key], null, 2)
98
+ if (json.length < 350) {
99
+ s += JSON.stringify(error[key], null, 2)
100
+ .split('\n')
101
+ .map((line: string) => {
102
+ const arr = line.split('": ')
103
+ arr[0] = colors.gray(arr[0].replace('"', ''))
104
+ return arr.join(': ')
105
+ })
106
+ .join('\n')
107
+ } else {
108
+ s += JSON.stringify(error[key])
109
+ }
110
+ } else if (isPrimitive(error[key])) {
111
+ s += String(error[key])
112
+ } else if (error[key] != null && typeof error[key] === 'object') {
113
+ s += (error[key] as Any).toString()
114
+ } else {
115
+ s += JSON.stringify(error[key])
116
+ }
117
+ result.push(s.trim())
118
+ }
119
+ return '\n' + result.join('\n') + '\n'
120
+ }
121
+
122
+ export function errParseStack(stack: string): [string, string][] {
123
+ if (!stack) return []
124
+ const nodeRe = /^\s*at (?:((?:\[object object\])?[^\\/]+(?: \[as \S+\])?) )?\(?(.*?):(\d+)(?::(\d+))?\)?\s*$/i
125
+ const recwd = new RegExp('^' + regexEscapeString(process.cwd() + path.sep), 'i')
126
+ const frames: [string, string][] = []
127
+ for (const line of stack.split('\n')) {
128
+ const parts = nodeRe.exec(line)
129
+ if (!parts) continue
130
+ frames.push([
131
+ parts[1] || '<unknown>',
132
+ `${(parts[2] || '').replace(recwd, '').replace(/\\\\?/g, '/')}:${+parts[3]}:${parts[4] ? +parts[4] : null}`,
133
+ ])
134
+ }
135
+ return frames
136
+ }
137
+
138
+ export function errToObject(error: Error) {
139
+ const own = Object.getOwnPropertyNames(error).filter((key) => typeof key === 'string')
140
+ const keys = new Set(['name', 'message', 'frames', ...own])
141
+ keys.delete('stack')
142
+ const entries = Array.from(keys)
143
+ .filter((key) => error[key as keyof Error] !== undefined)
144
+ .map((key) => [key, error[key as keyof Error]])
145
+ return Object.fromEntries(entries)
146
+ }
147
+
148
+ // try {
149
+ // throw new TypeError('wow ok oops')
150
+ // } catch (error) {
151
+ // const err = new ErrorParser(error)
152
+ // console.log('----------------------')
153
+ // console.log({
154
+ // name: err.name,
155
+ // message: err.message,
156
+ // summary: err.summary,
157
+ // })
158
+ // console.log('----------------------')
159
+ // console.log(err.stack)
160
+ // console.log('----------------------')
161
+ // console.log(err.prettyStack())
162
+ // console.log('----------------------')
163
+ // console.log(err.toObject())
164
+ // console.log('----------------------')
165
+ // }
@@ -0,0 +1,15 @@
1
+ export interface IGetUserInputFromEditorOptions {
2
+ /**
3
+ * The content to put in the temp file so that the user can edit it. Defaults to an empty file.
4
+ */
5
+ content?: string
6
+ /**
7
+ * Launch command to start your editor. Defaults to VSCode: 'code -w' (if installed).
8
+ * Otherwise this logic: isWindows() ? 'notepad' : isOSX() ? 'open vi' : 'xdg-open'
9
+ */
10
+ editor?: string
11
+ /**
12
+ * The file extension to use for the temporary file. Defaults to '.txt'.
13
+ */
14
+ extension?: string
15
+ }
@@ -0,0 +1,30 @@
1
+ import { defaultOpenInEditorCommand } from '../../os/defaultOpenInEditorCommand'
2
+ import { execSync } from 'child_process'
3
+ import type { IGetUserInputFromEditorOptions } from './IGetUserInputFromEditorOptions'
4
+ import { readFileSync } from '../readFile/readFileSync'
5
+ import { strEnsureStartsWith } from '../../string/strEnsureStartsWith'
6
+ import { tempFileSync } from '../tempFile/tempFileSync'
7
+ import { writeFileSync } from '../writeFile/writeFileSync'
8
+
9
+ /**
10
+ * Prompts the user to edit a string in the user's text editor.
11
+ *
12
+ * @example ```ts
13
+ * promptUserEditInTextEditor({ editor: 'notepad' })
14
+ * ```
15
+ */
16
+ export function promptUserEditInTextEditorSync(options?: IGetUserInputFromEditorOptions): string {
17
+ const { editor, content, extension } = applyDefaults(options)
18
+ return tempFileSync(extension, (tempfile) => {
19
+ writeFileSync(tempfile, content)
20
+ execSync(`${editor} ${tempfile}`, { stdio: 'inherit' })
21
+ return readFileSync(tempfile)
22
+ })
23
+ }
24
+
25
+ function applyDefaults(options: IGetUserInputFromEditorOptions = {}) {
26
+ const content = options.content ?? ''
27
+ const extension = strEnsureStartsWith(options.extension ?? '.txt', '.')
28
+ const editor = options.editor ?? defaultOpenInEditorCommand()
29
+ return { content, extension, editor }
30
+ }
@@ -0,0 +1,25 @@
1
+ import type { JsonValue } from '../../types/JsonValue'
2
+ import { promptUserEditInTextEditorSync } from './promptUserEditInTextEditorSync'
3
+
4
+ /**
5
+ * Edit a JSON-stringify-compatible value in the user's editor and return the (JSON.parse'd) result.
6
+ *
7
+ * @param value - The value to edit (NOT a json string). Defaults to an empty object.
8
+ * @param editor - Launch command to start your editor. Defaults to VSCode: 'code -w' (if installed).
9
+ * - Otherwise this logic: isWindows() ? 'notepad' : isOSX() ? 'open vi' : 'xdg-open'
10
+ *
11
+ * @example ```ts
12
+ * promptUserEditJsonInTextEditorSync([1, 2])
13
+ * ```
14
+ */
15
+ export function promptUserEditJsonInTextEditorSync<T extends JsonValue = JsonValue, R extends T = T>(
16
+ value: T = {} as T,
17
+ editor?: string
18
+ ): R {
19
+ const json = promptUserEditInTextEditorSync({
20
+ editor,
21
+ content: JSON.stringify(value, null, 2),
22
+ extension: '.json',
23
+ })
24
+ return JSON.parse(json) as R
25
+ }
@@ -0,0 +1,20 @@
1
+ import fs from 'fs-extra'
2
+
3
+ /**
4
+ * Reads a file and returns the file's contents.
5
+ *
6
+ * Identical to fs.readFileSync, except that:
7
+ * - it uses utf8 encoding by default
8
+ * - if operation fails, returns undefined instead of throwing
9
+ *
10
+ * @param filepath - The path to the file.
11
+ * @param encoding - The encoding to use when reading the file.
12
+ * @returns The file's contents or undefined if the file does not exist.
13
+ */
14
+ export function readFileSafeSync(filepath: string, encoding: BufferEncoding = 'utf8'): string | undefined {
15
+ try {
16
+ return fs.readFileSync(filepath, encoding)
17
+ } catch (error) {
18
+ return undefined
19
+ }
20
+ }
@@ -0,0 +1,13 @@
1
+ import fs from 'fs-extra'
2
+
3
+ /**
4
+ * Reads a file and returns the file's contents.
5
+ * Identical to fs.readFileSync, except that it uses utf8 encoding by default.
6
+ *
7
+ * @param filepath - The path to the file.
8
+ * @param encoding - The encoding to use when reading the file.
9
+ * @returns The file's contents.
10
+ */
11
+ export function readFileSync(filepath: string, encoding: BufferEncoding = 'utf8'): string {
12
+ return fs.readFileSync(filepath, encoding)
13
+ }
@@ -0,0 +1,17 @@
1
+ import fs from 'fs-extra'
2
+ import type { IReadJsonFileOptions } from '../types/IReadJsonFileOptions'
3
+
4
+ /**
5
+ * Reads a JSON file and then parses it into an object.
6
+ * If an error occurs, it returns undefined.
7
+ *
8
+ * @param filepath - The path to the JSON file.
9
+ * @param options - Options for reading the JSON file.
10
+ */
11
+ export function readJsonFileSafeSync<T>(filepath: string, options?: IReadJsonFileOptions): T | undefined {
12
+ try {
13
+ return fs.readJsonSync(filepath, options) as T
14
+ } catch (error) {
15
+ return undefined
16
+ }
17
+ }
@@ -0,0 +1 @@
1
+ export { remove as removeFile } from 'fs-extra'
@@ -0,0 +1,21 @@
1
+ import fs from 'fs-extra'
2
+ import type { Any } from '../../types/Any'
3
+ import { getTempDataPath } from '../../path/getTempDataPath'
4
+ import { strEnsureStartsWith } from '../../string/strEnsureStartsWith'
5
+
6
+ /**
7
+ * Syncrhonously creates a temporary file and deletes it after the callback has finished.
8
+ * @param fileExtension - The file extension to use for the temporary file.
9
+ * @param callback - The callback to execute with the temporary file path. The callback can return a promise and the temporary file will not be deleted until the promise has resolved or rejected.
10
+ */
11
+ export function tempFileSync(fileExtension: string, callback: (fpath: string) => Any) {
12
+ const fpath = getTempDataPath('temp', Date.now() + strEnsureStartsWith(fileExtension, '.'))
13
+ fs.ensureFileSync(fpath)
14
+ try {
15
+ const retval = callback(fpath)
16
+ fs.remove(fpath)
17
+ return retval
18
+ } catch (error) {
19
+ fs.remove(fpath)
20
+ }
21
+ }
@@ -0,0 +1 @@
1
+ export type { JFReadOptions as IReadJsonFileOptions } from 'jsonfile'
@@ -0,0 +1 @@
1
+ export { outputFileSync as writeFileSafeSync } from 'fs-extra'
@@ -0,0 +1 @@
1
+ export { writeFileSync } from 'fs-extra'
@@ -0,0 +1 @@
1
+ export { outputJson as writeJsonFileSafe } from 'fs-extra'
@@ -0,0 +1,112 @@
1
+ import assert from 'assert'
2
+ import { Any } from '../types/Any'
3
+ import { MethodDisabler } from './MethodDisabler'
4
+ import { ObjectKey } from '../types/ObjectKey'
5
+
6
+ describe(MethodDisabler.name, () => {
7
+ it('TSDOC @example', () => {
8
+ expect(() => {
9
+ const md = new MethodDisabler(process.stdout, 'write')
10
+
11
+ md.disable()
12
+ assert(!md.isEnabled)
13
+ console.log('This will not print')
14
+
15
+ md.enable()
16
+ assert(md.isEnabled)
17
+ // console.log('This will print')
18
+
19
+ assert(md.original === process.stdout.write)
20
+ }).not.toThrow()
21
+ })
22
+
23
+ describe('constructor', () => {
24
+ it('instanceof ' + MethodDisabler.name, () => {
25
+ expect(new MethodDisabler(Array.prototype, 'sort')).toBeInstanceOf(MethodDisabler)
26
+ })
27
+
28
+ it('throws if not function', () => {
29
+ expect(() => new MethodDisabler(Array.prototype, 'length')).toThrow()
30
+ })
31
+
32
+ it('original', () => {
33
+ expect(new MethodDisabler(Array.prototype, 'sort').original).toBe(Array.prototype['sort'])
34
+ })
35
+
36
+ it('memoize', () => {
37
+ const ins = new MethodDisabler(Map.prototype, 'set')
38
+ expect(ins).toBe(new MethodDisabler(Map.prototype, 'set'))
39
+ expect(ins).not.toBe(new MethodDisabler(Map.prototype, 'get'))
40
+ expect(ins).not.toBe(new MethodDisabler(WeakMap.prototype, 'set'))
41
+ })
42
+ })
43
+
44
+ type Obj = Record<ObjectKey, Any>
45
+ type BfOpts = { obj: Obj; key: string }
46
+ type Opts = { ins: MethodDisabler; obj: Obj; key: string; spy?: jest.SpyInstance }
47
+
48
+ const createMock = (opts: BfOpts) => {
49
+ const { obj, key } = opts
50
+ jest.clearAllMocks()
51
+ const spy = jest.spyOn(obj, key)
52
+ spy.mockImplementation(() => false)
53
+ return spy
54
+ }
55
+
56
+ const createInstance = (opts: BfOpts) => {
57
+ const { obj, key } = opts
58
+ jest.clearAllMocks()
59
+ return new MethodDisabler(obj, key)
60
+ }
61
+
62
+ const testIsEnabled = (opts: Opts) => () => {
63
+ const { ins, obj, key, spy } = opts
64
+ expect(ins.isEnabled).toBe(true)
65
+ obj[key]('')
66
+ if (spy) expect(spy).toHaveBeenCalledTimes(1)
67
+ }
68
+
69
+ const testDisable = (opts: Opts) => () => {
70
+ const { ins, obj, key, spy } = opts
71
+ ins.disable()
72
+ expect(obj[key]).not.toBe(ins.original)
73
+ expect(ins.isEnabled).toBe(false)
74
+ obj[key]('')
75
+ if (spy) expect(spy).not.toHaveBeenCalled()
76
+ }
77
+
78
+ const testEnable = (opts: Opts) => () => {
79
+ const { ins, obj, key, spy } = opts
80
+ ins.disable()
81
+ ins.enable()
82
+ expect(obj[key]).toBe(ins.original)
83
+ if (spy) createMock({ obj, key })
84
+ testIsEnabled(opts)
85
+ }
86
+
87
+ const runTest = (opts: Opts) => {
88
+ const bopts = { obj: opts.obj, key: opts.key }
89
+ beforeEach(() => {
90
+ opts.ins = createInstance(bopts)
91
+ if (opts.spy) opts.spy = createMock(bopts)
92
+ })
93
+ it('isEnabled', testIsEnabled(opts))
94
+ it('disable', testDisable(opts))
95
+ it('enable', testEnable(opts))
96
+ }
97
+
98
+ describe('console.log (hasOwn)', () => {
99
+ const bopts = { obj: console, key: 'log' }
100
+ runTest({ ...bopts, ins: createInstance(bopts), spy: createMock(bopts) })
101
+ })
102
+
103
+ describe('process.stdout.write', () => {
104
+ const bopts = { obj: process.stdout, key: 'write' }
105
+ runTest({ ...bopts, ins: createInstance(bopts), spy: createMock(bopts) })
106
+ })
107
+
108
+ describe('[].push ', () => {
109
+ const bopts = { obj: [], key: 'join' }
110
+ runTest({ ...bopts, ins: createInstance(bopts) })
111
+ })
112
+ })
@@ -0,0 +1,94 @@
1
+ import type { Any } from '../types/Any'
2
+ import { ensureThat } from '../validation/ensureThat'
3
+ import { isFunction } from '../validation/isFunction'
4
+ import type { ObjectKey } from '../types/ObjectKey'
5
+ import type { TFunctionNoNew } from '../types/TFunctionNoNew'
6
+
7
+ /**
8
+ * A class that creates an object with methods for disabling/enabling a given method on a given object.
9
+ *
10
+ * @example
11
+ * const md = new MethodDisabler(process.stdout, 'write')
12
+ *
13
+ * md.disable()
14
+ * assert(!md.isEnabled)
15
+ * console.log('This will not print')
16
+ *
17
+ * md.enable()
18
+ * assert(md.isEnabled)
19
+ * console.log('This will print')
20
+ *
21
+ * assert(md.original === process.stdout.write)
22
+ */
23
+ export class MethodDisabler {
24
+ static #defaultDescriptor(value: Any): PropertyDescriptor {
25
+ return { value, writable: true, enumerable: true, configurable: true }
26
+ }
27
+ static #noop: TFunctionNoNew = (...args: any[]) => void 0
28
+ static #memoized = new WeakMap<Record<ObjectKey, Any>, Map<ObjectKey, MethodDisabler>>()
29
+
30
+ readonly #obj: Record<ObjectKey, Any>
31
+ readonly #key: string
32
+ readonly #original: TFunctionNoNew
33
+ readonly #hasOwn: boolean
34
+ readonly #originalDescriptor: PropertyDescriptor
35
+ readonly #noopDescriptor: PropertyDescriptor
36
+ #isEnabled = true
37
+
38
+ /**
39
+ * @param obj - The object on which the method is defined.
40
+ * @param key - The property name of the method.
41
+ */
42
+ constructor(obj: Record<ObjectKey, Any>, key: string) {
43
+ ensureThat(obj[key], isFunction)
44
+ this.#obj = obj
45
+ this.#key = key
46
+ this.#original = obj[key]
47
+ this.#hasOwn = Object.hasOwn(obj, key)
48
+ this.#originalDescriptor = this.#hasOwn
49
+ ? (Object.getOwnPropertyDescriptor(obj, key) as PropertyDescriptor)
50
+ : MethodDisabler.#defaultDescriptor(this.#original)
51
+ this.#noopDescriptor = Object.assign({}, this.#originalDescriptor, { value: MethodDisabler.#noop })
52
+ // return stored if memoized
53
+ if (MethodDisabler.#memoized.get(obj)?.has(key)) {
54
+ return MethodDisabler.#memoized.get(obj)?.get(key) as this
55
+ }
56
+ //memoize
57
+ if (!MethodDisabler.#memoized.has(obj)) MethodDisabler.#memoized.set(obj, new Map())
58
+ const methods = MethodDisabler.#memoized.get(obj) as Map<ObjectKey, MethodDisabler>
59
+ methods.set(key, this)
60
+ }
61
+
62
+ /**
63
+ * Disable the method.
64
+ */
65
+ disable() {
66
+ if (!this.isEnabled) return
67
+ Object.defineProperty(this.#obj, this.#key, this.#noopDescriptor)
68
+ this.#isEnabled = false
69
+ }
70
+
71
+ /**
72
+ * Enable the method.
73
+ */
74
+ enable() {
75
+ if (this.isEnabled) return
76
+ if (this.#hasOwn) Object.defineProperty(this.#obj, this.#key, this.#originalDescriptor)
77
+ else delete this.#obj[this.#key]
78
+ this.#isEnabled = true
79
+ }
80
+
81
+ /**
82
+ * The original method before it was disabled.
83
+ */
84
+ get original() {
85
+ return this.#original
86
+ }
87
+
88
+ /**
89
+ * Whether the method is currently enabled.
90
+ */
91
+ get isEnabled() {
92
+ return this.#isEnabled
93
+ }
94
+ }
@@ -0,0 +1,12 @@
1
+ import { funSetName } from './funSetName'
2
+
3
+ describe('funSetName', () => {
4
+ it('should set the name of a function', () => {
5
+ expect(
6
+ funSetName('myFunc', function () {
7
+ //
8
+ }).name,
9
+ ).toBe('myFunc')
10
+ expect(funSetName('myFunc', () => 1).name).toBe('myFunc')
11
+ })
12
+ })
@@ -0,0 +1,16 @@
1
+ /**
2
+ * This function sets the name of a function and returns the function with the new name.
3
+ * @template T - The type of the function.
4
+ * @param name The new name to be set for the function.
5
+ * @param fun The function whose name is to be set.
6
+ * @returns The function with the new name.
7
+ * @example ```ts
8
+ * const myFun = () => 'Hello World';
9
+ * funSetName('newFun', myFun).name;;
10
+ * //=> 'newFun'
11
+ * ```
12
+ */
13
+ export function funSetName<T>(name: string, fun: T): T {
14
+ Object.defineProperty(fun, 'name', { value: name, configurable: true, writable: true, enumerable: false })
15
+ return fun
16
+ }
@@ -0,0 +1,14 @@
1
+ import { execSync } from 'child_process'
2
+
3
+ export function execInherit(command: string): Promise<string> {
4
+ return new Promise((resolve, reject) => {
5
+ try {
6
+ const buffer = execSync(command, { stdio: 'inherit' })
7
+ const string = buffer && buffer.toString ? buffer.toString().trim() : ''
8
+ resolve(string)
9
+ } catch (error) {
10
+ const oError = error instanceof Error ? error : new Error(String(error))
11
+ reject(oError)
12
+ }
13
+ })
14
+ }
@@ -0,0 +1,12 @@
1
+ import colors from 'ansi-colors'
2
+ import Table from 'cli-table'
3
+
4
+ export function formatTableForTerminal(rows: string[][], headers?: string[]) {
5
+ if (!rows.length || !rows[0].length) return ''
6
+ const table = new Table()
7
+ if (headers && headers.length) {
8
+ table.push(headers.map((s) => colors.bold(colors.yellow(s))))
9
+ }
10
+ for (const row of rows) table.push(row)
11
+ return table.toString()
12
+ }
@@ -0,0 +1,3 @@
1
+ import { createArrayMerger } from './createArrayMerger'
2
+
3
+ export const arrAssign = createArrayMerger((value) => value != null)
@@ -0,0 +1,11 @@
1
+ import { createArrayMerger } from './createArrayMerger'
2
+
3
+ describe(createArrayMerger.name, () => {
4
+ it('should merge arrays based on the predicate function', () => {
5
+ const merge = createArrayMerger<number>((value) => value != null)
6
+ const target = [1, 3, 5, 7]
7
+ const source1 = [2, 4, 6]
8
+ const result = merge(target, source1)
9
+ expect(result).toEqual([2, 4, 6, 7])
10
+ })
11
+ })
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Creates a function that merges arrays based on a predicate function.
3
+ */
4
+ export function createArrayMerger<T>(predicate: (value: T, index: number, arr: T[]) => boolean) {
5
+ return function arrMerge<E extends T>(target: E[], ...sources: E[][]) {
6
+ for (const src of sources) {
7
+ for (let i = 0; i < src.length; i++) {
8
+ if (predicate(src[i], i, src)) {
9
+ target[i] = src[i]
10
+ }
11
+ }
12
+ }
13
+ return target
14
+ }
15
+ }
@@ -0,0 +1,11 @@
1
+ import { createObjectMerger } from './createObjectMerger'
2
+
3
+ describe(createObjectMerger.name, () => {
4
+ it('should merge objects based on the predicate function', () => {
5
+ const merge = createObjectMerger((value) => value != null)
6
+ const target = { a: 1, b: 2, c: 3 }
7
+ const source1 = { a: 5, b: null, c: undefined, d: 5 }
8
+ const result = merge(target, source1)
9
+ expect(result).toEqual({ a: 5, b: 2, c: 3, d: 5 })
10
+ })
11
+ })
@@ -0,0 +1,17 @@
1
+ import type { Any } from '../types/Any'
2
+
3
+ /**
4
+ * Creates a function that merges objects based on a predicate function.
5
+ */
6
+ export function createObjectMerger(predicate: (value: Any, key: string, obj: Record<string, Any>) => boolean) {
7
+ return function objMerge(target: Record<string, Any>, ...sources: Record<string, Any>[]) {
8
+ for (const src of sources) {
9
+ for (const [key, value] of Object.entries(src)) {
10
+ if (predicate(value, key, src)) {
11
+ target[key] = value
12
+ }
13
+ }
14
+ }
15
+ return target
16
+ }
17
+ }
@@ -0,0 +1,3 @@
1
+ import { createObjectMerger } from './createObjectMerger'
2
+
3
+ export const objAssign = createObjectMerger((value) => value != null)