wsemi 1.8.69 → 1.8.71

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 (495) hide show
  1. package/README.md +1 -1
  2. package/dist/wsemi.umd.js +4 -4
  3. package/dist/wsemi.umd.js.map +1 -1
  4. package/docs/-_class.mjs.html +2 -2
  5. package/docs/ab2blob.mjs.html +2 -2
  6. package/docs/ab2u8arr.mjs.html +2 -2
  7. package/docs/addExcelWorksheetFromData.mjs.html +2 -2
  8. package/docs/addMonth.mjs.html +2 -2
  9. package/docs/aes2str.mjs.html +12 -9
  10. package/docs/alive.mjs.html +2 -2
  11. package/docs/arr2dt.mjs.html +2 -2
  12. package/docs/arrAccum.mjs.html +2 -2
  13. package/docs/arrAdd.mjs.html +2 -2
  14. package/docs/arrAt.mjs.html +2 -2
  15. package/docs/arrDiff.mjs.html +2 -2
  16. package/docs/arrFilterByKeywords.mjs.html +2 -2
  17. package/docs/arrFilterByNum.mjs.html +2 -2
  18. package/docs/arrFilterByPnum.mjs.html +2 -2
  19. package/docs/arrFilterByPnumAndToLog.mjs.html +2 -2
  20. package/docs/arrFind.mjs.html +2 -2
  21. package/docs/arrGroupByMaxmin.mjs.html +2 -2
  22. package/docs/arrHas.mjs.html +2 -2
  23. package/docs/arrInsert.mjs.html +2 -2
  24. package/docs/arrLookupByMaxmin.mjs.html +2 -2
  25. package/docs/arrMax.mjs.html +2 -2
  26. package/docs/arrMin.mjs.html +2 -2
  27. package/docs/arrMulti.mjs.html +2 -2
  28. package/docs/arrNorm.mjs.html +2 -2
  29. package/docs/arrProduct.mjs.html +2 -2
  30. package/docs/arrPull.mjs.html +2 -2
  31. package/docs/arrPullAt.mjs.html +2 -2
  32. package/docs/arrReduce.mjs.html +2 -2
  33. package/docs/arrReverse.mjs.html +2 -2
  34. package/docs/arrSep.mjs.html +2 -2
  35. package/docs/arrSort.mjs.html +2 -2
  36. package/docs/asind.mjs.html +2 -2
  37. package/docs/atan2d.mjs.html +2 -2
  38. package/docs/atand.mjs.html +2 -2
  39. package/docs/attstr.mjs.html +2 -2
  40. package/docs/b642obj.mjs.html +2 -2
  41. package/docs/b642str.mjs.html +2 -2
  42. package/docs/b642u16arr.mjs.html +2 -2
  43. package/docs/b642u8arr.mjs.html +2 -2
  44. package/docs/binstr.mjs.html +2 -2
  45. package/docs/blob2ab.mjs.html +2 -2
  46. package/docs/blob2b64.mjs.html +2 -2
  47. package/docs/blob2str.mjs.html +2 -2
  48. package/docs/blob2u8arr.mjs.html +2 -2
  49. package/docs/blobs2b64s.mjs.html +2 -2
  50. package/docs/blobs2u8arrs.mjs.html +2 -2
  51. package/docs/bodyLog.mjs.html +2 -2
  52. package/docs/browserView.mjs.html +2 -2
  53. package/docs/browserViewFromBlob.mjs.html +2 -2
  54. package/docs/browserViewFromText.mjs.html +2 -2
  55. package/docs/browserViewFromU8arr.mjs.html +2 -2
  56. package/docs/bs2u8arr.mjs.html +2 -2
  57. package/docs/bufRead.mjs.html +2 -2
  58. package/docs/bufReadDbl.mjs.html +2 -2
  59. package/docs/bufWrite.mjs.html +2 -2
  60. package/docs/bufWriteDbl.mjs.html +2 -2
  61. package/docs/cache.mjs.html +2 -2
  62. package/docs/cacheBd.mjs.html +2 -2
  63. package/docs/cacheSt.mjs.html +2 -2
  64. package/docs/cbol.mjs.html +2 -2
  65. package/docs/cdbl.mjs.html +2 -2
  66. package/docs/ceil.mjs.html +2 -2
  67. package/docs/cfilesize.mjs.html +2 -2
  68. package/docs/cfinancial.mjs.html +2 -2
  69. package/docs/cint.mjs.html +2 -2
  70. package/docs/clearXSS.mjs.html +2 -2
  71. package/docs/clearXSSDyn.mjs.html +2 -2
  72. package/docs/color.mjs.html +2 -2
  73. package/docs/composeToTree.mjs.html +2 -2
  74. package/docs/convertToTree.mjs.html +2 -2
  75. package/docs/copyStrToClipboard.mjs.html +2 -2
  76. package/docs/cosd.mjs.html +2 -2
  77. package/docs/cotd.mjs.html +2 -2
  78. package/docs/createExcelWorkbook.mjs.html +2 -2
  79. package/docs/cscd.mjs.html +2 -2
  80. package/docs/cstr.mjs.html +2 -2
  81. package/docs/day2cht.mjs.html +2 -2
  82. package/docs/debounce.mjs.html +2 -2
  83. package/docs/delay.mjs.html +2 -2
  84. package/docs/dig.mjs.html +2 -2
  85. package/docs/digExp.mjs.html +2 -2
  86. package/docs/domAlert.mjs.html +2 -2
  87. package/docs/domAppend.mjs.html +2 -2
  88. package/docs/domCancelEvent.mjs.html +2 -2
  89. package/docs/domCompareText.mjs.html +2 -2
  90. package/docs/domConvertToPic.mjs.html +2 -2
  91. package/docs/domConvertToPicDyn.mjs.html +2 -2
  92. package/docs/domDetect.mjs.html +2 -2
  93. package/docs/domDrag.mjs.html +2 -2
  94. package/docs/domDragBarAndScroll.mjs.html +2 -2
  95. package/docs/domDragPreview.mjs.html +2 -2
  96. package/docs/domDropFiles.mjs.html +2 -2
  97. package/docs/domElementsFromPoint.mjs.html +2 -2
  98. package/docs/domFadeIn.mjs.html +2 -2
  99. package/docs/domFadeOut.mjs.html +2 -2
  100. package/docs/domFind.mjs.html +2 -2
  101. package/docs/domFinds.mjs.html +2 -2
  102. package/docs/domGetAttr.mjs.html +2 -2
  103. package/docs/domGetBoudRect.mjs.html +2 -2
  104. package/docs/domGetBoudRectRefSelf.mjs.html +2 -2
  105. package/docs/domGetFileAccept.mjs.html +2 -2
  106. package/docs/domGetFiles.mjs.html +2 -2
  107. package/docs/domGetParents.mjs.html +2 -2
  108. package/docs/domGetPointFromEvent.mjs.html +2 -2
  109. package/docs/domGetScrollableParent.mjs.html +2 -2
  110. package/docs/domGetWindowSize.mjs.html +2 -2
  111. package/docs/domIsClientXYIn.mjs.html +2 -2
  112. package/docs/domIsFocused.mjs.html +2 -2
  113. package/docs/domIsStable.mjs.html +2 -2
  114. package/docs/domIsVisible.mjs.html +2 -2
  115. package/docs/domPrepend.mjs.html +2 -2
  116. package/docs/domRemove.mjs.html +2 -2
  117. package/docs/domRenderMarkdownMind.mjs.html +2 -2
  118. package/docs/domRenderMarkdownMindDyn.mjs.html +2 -2
  119. package/docs/domRipple.mjs.html +2 -2
  120. package/docs/domScrollIntoView.mjs.html +2 -2
  121. package/docs/domScrollTo.mjs.html +2 -2
  122. package/docs/domSetAttr.mjs.html +2 -2
  123. package/docs/domShowImages.mjs.html +2 -2
  124. package/docs/domShowImagesDyn.mjs.html +2 -2
  125. package/docs/domShowInputAndGetFiles.mjs.html +2 -2
  126. package/docs/domShowInputAndGetFilesU8Arrs.mjs.html +2 -2
  127. package/docs/domShowInputDatatime.mjs.html +2 -2
  128. package/docs/domTooltip.mjs.html +2 -2
  129. package/docs/domTriggerEvent.mjs.html +2 -2
  130. package/docs/domVirtualCreate.mjs.html +2 -2
  131. package/docs/domVirtualCreateQueue.mjs.html +2 -2
  132. package/docs/downloadExcelFileFromData.mjs.html +2 -2
  133. package/docs/downloadExcelFileFromDataDyn.mjs.html +2 -2
  134. package/docs/downloadFileFromB64.mjs.html +2 -2
  135. package/docs/downloadFileFromBlob.mjs.html +2 -2
  136. package/docs/downloadFileFromText.mjs.html +2 -2
  137. package/docs/downloadFileFromU8Arr.mjs.html +2 -2
  138. package/docs/dtmapping.mjs.html +2 -2
  139. package/docs/dtpick.mjs.html +2 -2
  140. package/docs/estimateTicks.mjs.html +2 -2
  141. package/docs/evem.mjs.html +2 -2
  142. package/docs/examples/ex-blob2b64.html +1 -1
  143. package/docs/examples/ex-clearXSS.html +1 -1
  144. package/docs/examples/ex-clearXSSDyn.html +1 -1
  145. package/docs/examples/ex-colorConverter.html +1 -1
  146. package/docs/examples/ex-domCompareText.html +1 -1
  147. package/docs/examples/ex-domConvertToPic.html +1 -1
  148. package/docs/examples/ex-domDrag.html +1 -1
  149. package/docs/examples/ex-domDropFiles.html +1 -1
  150. package/docs/examples/ex-domIsVisible.html +1 -1
  151. package/docs/examples/ex-domRenderMarkdownMind.html +1 -1
  152. package/docs/examples/ex-domRenderMarkdownMindDyn.html +1 -1
  153. package/docs/examples/ex-domRipple.html +1 -1
  154. package/docs/examples/ex-domScrollIntoView.html +1 -1
  155. package/docs/examples/ex-domScrollTo.html +1 -1
  156. package/docs/examples/ex-domShowImages.html +1 -1
  157. package/docs/examples/ex-domShowImagesDyn.html +1 -1
  158. package/docs/examples/ex-domShowInputAndGetFiles.html +1 -1
  159. package/docs/examples/ex-domTooltip.html +1 -1
  160. package/docs/examples/ex-getFileHash.html +1 -1
  161. package/docs/examples/ex-getUserAgent.html +1 -1
  162. package/docs/examples/ex-getUserAgentDyn.html +1 -1
  163. package/docs/examples/ex-html2str.html +1 -1
  164. package/docs/examples/ex-obj2u8arr-u8arr2obj.html +1 -1
  165. package/docs/examples/ex-openLink.html +1 -1
  166. package/docs/examples/ex-str2aes-aes2str.html +1 -1
  167. package/docs/examples/ex-str2b64-b642str.html +1 -1
  168. package/docs/examples/ex-strFindFuzz.html +1 -1
  169. package/docs/examples/ex-timeTZ2expire-timeTZ2past.html +1 -1
  170. package/docs/examples/ex-xlsx.html +1 -1
  171. package/docs/examples/ex-xlsxDyn.html +1 -1
  172. package/docs/execCli.mjs.html +36 -3
  173. package/docs/execJsCode.mjs.html +2 -2
  174. package/docs/execProcess.mjs.html +2 -2
  175. package/docs/execProcessKillPid.mjs.html +2 -2
  176. package/docs/filepathToTree.mjs.html +2 -2
  177. package/docs/files2data.mjs.html +2 -2
  178. package/docs/flattenToConn.mjs.html +2 -2
  179. package/docs/flattenTree.mjs.html +2 -2
  180. package/docs/floor.mjs.html +2 -2
  181. package/docs/fsBuildReadStreamText.mjs.html +2 -2
  182. package/docs/fsBuildWriteStreamText.mjs.html +2 -2
  183. package/docs/fsCleanFolder.mjs.html +2 -2
  184. package/docs/fsCleanFolderCore.mjs.html +2 -2
  185. package/docs/fsCopyFile.mjs.html +2 -2
  186. package/docs/fsCopyFileCore.mjs.html +2 -2
  187. package/docs/fsCopyFolder.mjs.html +2 -2
  188. package/docs/fsCopyFolderCore.mjs.html +2 -2
  189. package/docs/fsCreateFile.mjs.html +2 -2
  190. package/docs/fsCreateFileCore.mjs.html +2 -2
  191. package/docs/fsCreateFolder.mjs.html +2 -2
  192. package/docs/fsCreateFolderCore.mjs.html +2 -2
  193. package/docs/fsDeleteFile.mjs.html +2 -2
  194. package/docs/fsDeleteFileCore.mjs.html +2 -2
  195. package/docs/fsDeleteFileSafe.mjs.html +2 -2
  196. package/docs/fsDeleteFileSafeCore.mjs.html +2 -2
  197. package/docs/fsDeleteFolder.mjs.html +2 -2
  198. package/docs/fsDeleteFolderCore.mjs.html +2 -2
  199. package/docs/fsDeleteFolderSafe.mjs.html +2 -2
  200. package/docs/fsDeleteFolderSafeCore.mjs.html +2 -2
  201. package/docs/fsDownloadFile.mjs.html +2 -2
  202. package/docs/fsDownloadFileCore.mjs.html +2 -2
  203. package/docs/fsEvem.mjs.html +2 -2
  204. package/docs/fsExists.mjs.html +2 -2
  205. package/docs/fsExistsCore.mjs.html +2 -2
  206. package/docs/fsGetFileBasicHash.mjs.html +2 -2
  207. package/docs/fsGetFileBasicHashCore.mjs.html +2 -2
  208. package/docs/fsGetFileHash.mjs.html +2 -2
  209. package/docs/fsGetFileHashCore.mjs.html +2 -2
  210. package/docs/fsGetFileXxHash.mjs.html +2 -2
  211. package/docs/fsGetFileXxHashCore.mjs.html +2 -2
  212. package/docs/fsGetFilesInFolder.mjs.html +2 -2
  213. package/docs/fsGetFilesInFolderCore.mjs.html +2 -2
  214. package/docs/fsGetFilesWithHashInFolder.mjs.html +2 -2
  215. package/docs/fsGetFilesWithHashInFolderCore.mjs.html +2 -2
  216. package/docs/fsGetFolderBasicHash.mjs.html +2 -2
  217. package/docs/fsGetFolderBasicHashCore.mjs.html +2 -2
  218. package/docs/fsGetFoldersInFolder.mjs.html +2 -2
  219. package/docs/fsGetFoldersInFolderCore.mjs.html +2 -2
  220. package/docs/fsIsFile.mjs.html +2 -2
  221. package/docs/fsIsFileCore.mjs.html +2 -2
  222. package/docs/fsIsFolder.mjs.html +2 -2
  223. package/docs/fsIsFolderCore.mjs.html +2 -2
  224. package/docs/fsMergeFiles.mjs.html +2 -2
  225. package/docs/fsMergeFilesCore.mjs.html +2 -2
  226. package/docs/fsReadJson.mjs.html +2 -2
  227. package/docs/fsReadText.mjs.html +2 -2
  228. package/docs/fsReadTextCore.mjs.html +2 -2
  229. package/docs/fsRenameFile.mjs.html +2 -2
  230. package/docs/fsRenameFileCore.mjs.html +2 -2
  231. package/docs/fsRenameFolder.mjs.html +2 -2
  232. package/docs/fsRenameFolderCore.mjs.html +2 -2
  233. package/docs/fsSrlog.mjs.html +2 -2
  234. package/docs/fsSyncFolder.mjs.html +2 -2
  235. package/docs/fsSyncFolderCore.mjs.html +2 -2
  236. package/docs/fsTask.mjs.html +2 -2
  237. package/docs/fsTaskCp.mjs.html +2 -2
  238. package/docs/fsTreeFolder.mjs.html +2 -2
  239. package/docs/fsTreeFolderCore.mjs.html +2 -2
  240. package/docs/fsTreeFolderWithHash.mjs.html +2 -2
  241. package/docs/fsTreeFolderWithHashCore.mjs.html +2 -2
  242. package/docs/fsWatchFile.mjs.html +2 -2
  243. package/docs/fsWatchFolder.mjs.html +2 -2
  244. package/docs/fsWriteJson.mjs.html +2 -2
  245. package/docs/fsWriteText.mjs.html +2 -2
  246. package/docs/fsWriteTextCore.mjs.html +2 -2
  247. package/docs/genGradientColor.mjs.html +2 -2
  248. package/docs/genID.mjs.html +2 -2
  249. package/docs/genIDSeq.mjs.html +2 -2
  250. package/docs/genPm.mjs.html +2 -2
  251. package/docs/getBufferSize.mjs.html +2 -2
  252. package/docs/getClearPathName.mjs.html +2 -2
  253. package/docs/getCsvStrFromData.mjs.html +2 -2
  254. package/docs/getDataFromExcelFileU8Arr.mjs.html +2 -2
  255. package/docs/getDataFromExcelFileU8ArrDyn.mjs.html +2 -2
  256. package/docs/getEnv.mjs.html +2 -2
  257. package/docs/getErrorMessage.mjs.html +2 -2
  258. package/docs/getExcelU8ArrFromData.mjs.html +2 -2
  259. package/docs/getExcelU8ArrFromWorkbook.mjs.html +2 -2
  260. package/docs/getExcelWorkbookFromData.mjs.html +2 -2
  261. package/docs/getExcelWorkbookFromWorksheet.mjs.html +2 -2
  262. package/docs/getExcelWorksheetFromData.mjs.html +2 -2
  263. package/docs/getFileAccept.mjs.html +2 -2
  264. package/docs/getFileBasicHash.mjs.html +2 -2
  265. package/docs/getFileHash.mjs.html +2 -2
  266. package/docs/getFileName.mjs.html +2 -2
  267. package/docs/getFileNameExt.mjs.html +2 -2
  268. package/docs/getFileTrueName.mjs.html +2 -2
  269. package/docs/getFileType.mjs.html +2 -2
  270. package/docs/getFileXxHash.mjs.html +2 -2
  271. package/docs/getGlobal.mjs.html +2 -2
  272. package/docs/getObjSize.mjs.html +2 -2
  273. package/docs/getPathParent.mjs.html +2 -2
  274. package/docs/getTimeBetween.mjs.html +2 -2
  275. package/docs/getTimeFromUnit.mjs.html +2 -2
  276. package/docs/getTimeHp.mjs.html +2 -2
  277. package/docs/getTimeObject.mjs.html +2 -2
  278. package/docs/getTimeRange.mjs.html +2 -2
  279. package/docs/getUserAgent.mjs.html +2 -2
  280. package/docs/getUserAgentDyn.mjs.html +2 -2
  281. package/docs/getltdtkeys.mjs.html +2 -2
  282. package/docs/global.html +2 -2
  283. package/docs/haskey.mjs.html +2 -2
  284. package/docs/html2str.mjs.html +2 -2
  285. package/docs/htmlDecode.mjs.html +2 -2
  286. package/docs/htmlEncode.mjs.html +2 -2
  287. package/docs/importResources.mjs.html +2 -2
  288. package/docs/index.html +2 -2
  289. package/docs/interp1.mjs.html +2 -2
  290. package/docs/isDate.mjs.html +2 -2
  291. package/docs/isDev.mjs.html +2 -2
  292. package/docs/isEle.mjs.html +2 -2
  293. package/docs/isEleExistByID.mjs.html +2 -2
  294. package/docs/isEmail.mjs.html +2 -2
  295. package/docs/isErr.mjs.html +2 -2
  296. package/docs/isIE.mjs.html +2 -2
  297. package/docs/isNarrow.mjs.html +2 -2
  298. package/docs/isStrHasCapital.mjs.html +2 -2
  299. package/docs/isStrHasLetter.mjs.html +2 -2
  300. package/docs/isStrHasLowerCase.mjs.html +2 -2
  301. package/docs/isStrHasNumber.mjs.html +2 -2
  302. package/docs/isStrHasSpace.mjs.html +2 -2
  303. package/docs/isStrHasSymbol.mjs.html +2 -2
  304. package/docs/isUserIdentify.mjs.html +2 -2
  305. package/docs/isUserName.mjs.html +2 -2
  306. package/docs/isUserPw.mjs.html +2 -2
  307. package/docs/isWindow.mjs.html +2 -2
  308. package/docs/isab.mjs.html +2 -2
  309. package/docs/isarr.mjs.html +2 -2
  310. package/docs/isarr0.mjs.html +2 -2
  311. package/docs/isbigint.mjs.html +2 -2
  312. package/docs/isblob.mjs.html +2 -2
  313. package/docs/isbol.mjs.html +2 -2
  314. package/docs/isday.mjs.html +2 -2
  315. package/docs/isearr.mjs.html +2 -2
  316. package/docs/iseobj.mjs.html +2 -2
  317. package/docs/iser.mjs.html +2 -2
  318. package/docs/isernot.mjs.html +2 -2
  319. package/docs/isestr.mjs.html +2 -2
  320. package/docs/isfile.mjs.html +2 -2
  321. package/docs/isfun.mjs.html +2 -2
  322. package/docs/isint.mjs.html +2 -2
  323. package/docs/ismonth.mjs.html +2 -2
  324. package/docs/isn0int.mjs.html +2 -2
  325. package/docs/isn0num.mjs.html +2 -2
  326. package/docs/isnan.mjs.html +2 -2
  327. package/docs/isnbr.mjs.html +2 -2
  328. package/docs/isnint.mjs.html +2 -2
  329. package/docs/isnnum.mjs.html +2 -2
  330. package/docs/isnull.mjs.html +2 -2
  331. package/docs/isnum.mjs.html +2 -2
  332. package/docs/isobj.mjs.html +2 -2
  333. package/docs/isobj0.mjs.html +2 -2
  334. package/docs/isp0int.mjs.html +2 -2
  335. package/docs/isp0num.mjs.html +2 -2
  336. package/docs/ispint.mjs.html +2 -2
  337. package/docs/ispm.mjs.html +2 -2
  338. package/docs/ispnum.mjs.html +2 -2
  339. package/docs/isstr.mjs.html +2 -2
  340. package/docs/isstr0.mjs.html +2 -2
  341. package/docs/istime.mjs.html +2 -2
  342. package/docs/istimeTZ.mjs.html +2 -2
  343. package/docs/istimems.mjs.html +2 -2
  344. package/docs/istimemsTZ.mjs.html +2 -2
  345. package/docs/isu16arr.mjs.html +2 -2
  346. package/docs/isu8arr.mjs.html +2 -2
  347. package/docs/isundefined.mjs.html +2 -2
  348. package/docs/j2o.mjs.html +2 -2
  349. package/docs/judge.mjs.html +2 -2
  350. package/docs/keysmat2ltdt.mjs.html +2 -2
  351. package/docs/ltdt2vrtsable.mjs.html +2 -2
  352. package/docs/ltdtDiff.mjs.html +2 -2
  353. package/docs/ltdtDiffByKey.mjs.html +2 -2
  354. package/docs/ltdtkeys2mat.mjs.html +2 -2
  355. package/docs/ltdtkeysheads2mat.mjs.html +2 -2
  356. package/docs/ltdtmapping.mjs.html +2 -2
  357. package/docs/ltdtmerge.mjs.html +2 -2
  358. package/docs/ltdtpick.mjs.html +2 -2
  359. package/docs/ltdtpull.mjs.html +2 -2
  360. package/docs/mat2ltdt.mjs.html +2 -2
  361. package/docs/matConcat.mjs.html +2 -2
  362. package/docs/matDiff.mjs.html +2 -2
  363. package/docs/matat.mjs.html +2 -2
  364. package/docs/now2str.mjs.html +2 -2
  365. package/docs/now2strp.mjs.html +2 -2
  366. package/docs/nowDay2str.mjs.html +2 -2
  367. package/docs/nowms2str.mjs.html +2 -2
  368. package/docs/nowms2strp.mjs.html +2 -2
  369. package/docs/o2j.mjs.html +2 -2
  370. package/docs/obj2b64.mjs.html +2 -2
  371. package/docs/obj2pb64.mjs.html +2 -2
  372. package/docs/obj2str.mjs.html +8 -8
  373. package/docs/obj2stru8arr.mjs.html +2 -2
  374. package/docs/obj2u8arr.mjs.html +2 -2
  375. package/docs/objSortBy.mjs.html +2 -2
  376. package/docs/objSortByKeys.mjs.html +2 -2
  377. package/docs/oo.mjs.html +2 -2
  378. package/docs/openLink.mjs.html +2 -2
  379. package/docs/pb642obj.mjs.html +2 -2
  380. package/docs/pmChain.mjs.html +2 -2
  381. package/docs/pmConvertResolve.mjs.html +2 -2
  382. package/docs/pmDebounce.mjs.html +2 -2
  383. package/docs/pmHook.mjs.html +2 -2
  384. package/docs/pmHookReject.mjs.html +2 -2
  385. package/docs/pmIni.mjs.html +2 -2
  386. package/docs/pmInvResolve.mjs.html +2 -2
  387. package/docs/pmKeyMutex.mjs.html +2 -2
  388. package/docs/pmMap.mjs.html +2 -2
  389. package/docs/pmQueue.mjs.html +2 -2
  390. package/docs/pmSeries.mjs.html +2 -2
  391. package/docs/pmThrottle.mjs.html +2 -2
  392. package/docs/preciseNum.mjs.html +2 -2
  393. package/docs/pseudoRandom.mjs.html +2 -2
  394. package/docs/pseudoRandomIntRange.mjs.html +2 -2
  395. package/docs/pseudoRandomIntsNdpRange.mjs.html +2 -2
  396. package/docs/pseudoRandomIntsRange.mjs.html +2 -2
  397. package/docs/pseudoRandomRange.mjs.html +2 -2
  398. package/docs/pseudoRandomsRange.mjs.html +2 -2
  399. package/docs/queue.mjs.html +2 -2
  400. package/docs/random.mjs.html +2 -2
  401. package/docs/randomIntRange.mjs.html +2 -2
  402. package/docs/randomIntsNdpRange.mjs.html +2 -2
  403. package/docs/randomIntsRange.mjs.html +2 -2
  404. package/docs/randomRange.mjs.html +2 -2
  405. package/docs/randomsRange.mjs.html +2 -2
  406. package/docs/rang.mjs.html +2 -2
  407. package/docs/rep.mjs.html +2 -2
  408. package/docs/repObj.mjs.html +2 -2
  409. package/docs/replace.mjs.html +2 -2
  410. package/docs/replaceObj.mjs.html +2 -2
  411. package/docs/replacePlus.mjs.html +2 -2
  412. package/docs/round.mjs.html +2 -2
  413. package/docs/secd.mjs.html +2 -2
  414. package/docs/sep.mjs.html +2 -2
  415. package/docs/sepInt.mjs.html +2 -2
  416. package/docs/setIntervalHp.mjs.html +2 -2
  417. package/docs/setTimeoutHp.mjs.html +2 -2
  418. package/docs/sind.mjs.html +2 -2
  419. package/docs/split.mjs.html +2 -2
  420. package/docs/str2aes.mjs.html +9 -7
  421. package/docs/str2b64.mjs.html +2 -2
  422. package/docs/str2hint.mjs.html +2 -2
  423. package/docs/str2md5.mjs.html +8 -6
  424. package/docs/str2obj.mjs.html +7 -7
  425. package/docs/str2sha.mjs.html +192 -0
  426. package/docs/str2sha512.mjs.html +31 -51
  427. package/docs/str2u8arr.mjs.html +2 -2
  428. package/docs/strCompare.mjs.html +2 -2
  429. package/docs/strDiff.mjs.html +2 -2
  430. package/docs/strDiffToHtml.mjs.html +2 -2
  431. package/docs/strFindFuzz.mjs.html +2 -2
  432. package/docs/strFindSimilar.mjs.html +2 -2
  433. package/docs/strTruncate.mjs.html +2 -2
  434. package/docs/strdelleft.mjs.html +2 -2
  435. package/docs/strdelright.mjs.html +2 -2
  436. package/docs/strleft.mjs.html +2 -2
  437. package/docs/strmid.mjs.html +2 -2
  438. package/docs/strright.mjs.html +2 -2
  439. package/docs/stru8arr2obj.mjs.html +2 -2
  440. package/docs/tand.mjs.html +2 -2
  441. package/docs/time2day.mjs.html +2 -2
  442. package/docs/time2hour.mjs.html +2 -2
  443. package/docs/time2min.mjs.html +2 -2
  444. package/docs/timeTZ2day.mjs.html +2 -2
  445. package/docs/timeTZ2expire.mjs.html +2 -2
  446. package/docs/timeTZ2hour.mjs.html +2 -2
  447. package/docs/timeTZ2min.mjs.html +2 -2
  448. package/docs/timeTZ2past.mjs.html +2 -2
  449. package/docs/timems2day.mjs.html +2 -2
  450. package/docs/timems2hour.mjs.html +2 -2
  451. package/docs/timems2min.mjs.html +2 -2
  452. package/docs/timems2time.mjs.html +2 -2
  453. package/docs/timemsTZ2day.mjs.html +2 -2
  454. package/docs/timemsTZ2expire.mjs.html +2 -2
  455. package/docs/timemsTZ2hour.mjs.html +2 -2
  456. package/docs/timemsTZ2min.mjs.html +2 -2
  457. package/docs/timemsTZ2past.mjs.html +2 -2
  458. package/docs/timemsTZ2time.mjs.html +2 -2
  459. package/docs/treeObj.mjs.html +2 -2
  460. package/docs/treeToFilepath.mjs.html +2 -2
  461. package/docs/trim.mjs.html +2 -2
  462. package/docs/u16arr2b64.mjs.html +2 -2
  463. package/docs/u16arr2u8arr.mjs.html +2 -2
  464. package/docs/u8arr2ab.mjs.html +2 -2
  465. package/docs/u8arr2b64.mjs.html +2 -2
  466. package/docs/u8arr2blob.mjs.html +2 -2
  467. package/docs/u8arr2bs.mjs.html +2 -2
  468. package/docs/u8arr2obj.mjs.html +2 -2
  469. package/docs/u8arr2str.mjs.html +2 -2
  470. package/docs/u8arr2u16arr.mjs.html +2 -2
  471. package/docs/urlParse.mjs.html +2 -2
  472. package/docs/verifyValue.mjs.html +2 -2
  473. package/docs/waitFun.mjs.html +2 -2
  474. package/docs/wsemi.html +367 -28
  475. package/package.json +2 -2
  476. package/src/aes2str.mjs +10 -7
  477. package/src/execCli.mjs +34 -1
  478. package/src/index.mjs +1 -0
  479. package/src/obj2str.mjs +6 -6
  480. package/src/str2aes.mjs +7 -5
  481. package/src/str2md5.mjs +6 -4
  482. package/src/str2obj.mjs +5 -5
  483. package/src/str2sha.mjs +120 -0
  484. package/src/str2sha512.mjs +29 -49
  485. package/test/aes2str.test.mjs +16 -0
  486. package/test/execCli.test.mjs +80 -0
  487. package/test/obj2str.test.mjs +22 -0
  488. package/test/str2aes.test.mjs +17 -0
  489. package/test/str2md5.test.mjs +14 -8
  490. package/test/str2obj.test.mjs +21 -0
  491. package/test/str2sha.test.mjs +176 -0
  492. package/test/str2sha512.test.mjs +8 -8
  493. package/toolfp/dist/wsemip.umd.js +1 -1
  494. package/toolparfor/dist/wpf.umd.js +1 -1
  495. package/toolparfor/dist/wpf_pmSeries.umd.js +1 -1
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "wsemi",
3
- "version": "1.8.69",
3
+ "version": "1.8.71",
4
4
  "main": "dist/wsemi.umd.js",
5
5
  "dependencies": {
6
6
  "chokidar": "^5.0.0",
7
7
  "crypto-js": "^4.2.0",
8
- "dayjs": "^1.11.21",
8
+ "dayjs": "^1.11.22",
9
9
  "decimal.js": "^10.6.0",
10
10
  "diff": "^9.0.0",
11
11
  "diff2html": "^3.4.56",
package/src/aes2str.mjs CHANGED
@@ -10,15 +10,16 @@ import isbol from './isbol.mjs'
10
10
 
11
11
 
12
12
  /**
13
- * 一般字串轉AES字串
14
- * 使用AES-128-CBC加密,字串採用PKCS#7填充
13
+ * AES字串轉一般字串
14
+ * 為str2aes之解密函數,使用AES-128-CBC解密,字串採用PKCS#7填充
15
+ * str與base64須與加密時str2aes所用之設定相同,否則解不出原文而回傳空字串
15
16
  *
16
17
  * Unit Test: {@link https://github.com/yuda-lyu/wsemi/blob/master/test/aes2str.test.mjs Github}
17
18
  * @memberOf wsemi
18
- * @param {String} str 輸入一般字串
19
- * @param {String} key 輸入加密key
20
- * @param {Boolean} [base64=false] 輸入是否轉為base64字串,預設為false
21
- * @returns {String} 回傳經AES轉換後字串,採Hex/base64顯示
19
+ * @param {String} str 輸入AES加密字串,非有效字串時回傳空字串
20
+ * @param {String} key 輸入加密key,非有效字串時回傳空字串
21
+ * @param {Boolean} [base64=false] 輸入來源字串是否為base64格式,須與加密時str2aes所用之設定相同,非布林值時回退為false,預設為false
22
+ * @returns {String} 回傳經AES解密後字串,str或key非有效字串時回傳空字串
22
23
  * @example
23
24
  *
24
25
  * let str = '53616c7465645f5f47214797ac01bc03cceb69ebced4948501ab94ca9644a6dfd277456aead4432cb9c9d74c38c42c79'
@@ -36,8 +37,10 @@ function aes2str(str, key, base64 = false) {
36
37
  if (!isestr(key)) {
37
38
  return ''
38
39
  }
40
+
41
+ //check
39
42
  if (!isbol(base64)) {
40
- return ''
43
+ base64 = false
41
44
  }
42
45
 
43
46
  let c = ''
package/src/execCli.mjs CHANGED
@@ -302,6 +302,7 @@ function execCliOnce(command, args = [], opt = {}) {
302
302
  maxBuffer = 10 * 1024 * 1024,
303
303
  onStdout = undefined,
304
304
  onStderr = undefined,
305
+ env: envExtra = undefined,
305
306
  } = opt
306
307
 
307
308
  //validator
@@ -313,13 +314,31 @@ function execCliOnce(command, args = [], opt = {}) {
313
314
  //pm
314
315
  let pm = genPm()
315
316
 
317
+ //envSpawn, 併入process.env(同名以envExtra為準, 含PYTHONIOENCODING)
318
+ //每次attempt於此重新求值並僅作用於該次子進程, 不動本進程process.env, 故並行調用可各自帶不同值
319
+ let envSpawn = { ...process.env, PYTHONIOENCODING: 'utf-8' }
320
+ if (envExtra !== undefined) {
321
+ if (process.platform === 'win32') {
322
+ //Windows環境變數大小寫不敏感但JS物件敏感, 須先移除大小寫不同之同名既有鍵,
323
+ //否則呼叫端傳Path而process.env為PATH時兩鍵並存且Windows取原值, 注入靜默失效
324
+ //此刪除僅限win32: POSIX環境變數大小寫敏感, Path與PATH為兩個獨立變數, 誤刪即退化
325
+ let ks = Object.keys(envExtra).map((k) => k.toLowerCase())
326
+ for (let k of Object.keys(envSpawn)) {
327
+ if (ks.includes(k.toLowerCase())) {
328
+ delete envSpawn[k]
329
+ }
330
+ }
331
+ }
332
+ envSpawn = { ...envSpawn, ...envExtra }
333
+ }
334
+
316
335
  //spawn
317
336
  let winSpawn = buildSpawnArgs(command, args)
318
337
  let proc = spawn(winSpawn.file, winSpawn.args, {
319
338
  cwd,
320
339
  stdio: ['pipe', 'pipe', 'pipe'],
321
340
  windowsHide: true, //執行的主程序若沒有主控台調用執行程序就不會有視窗, 但若通過pm2執行會有, 須設定windowsHide=true
322
- env: { ...process.env, PYTHONIOENCODING: 'utf-8' },
341
+ env: envSpawn,
323
342
  ...winSpawn.opt,
324
343
  })
325
344
 
@@ -515,6 +534,7 @@ function execCliOnce(command, args = [], opt = {}) {
515
534
  * @param {Number} [opt.maxBuffer=10485760] 輸入stdout與stderr各自累積之最大字元數正整數,超過部分將不再累積,預設10485760(10MB)
516
535
  * @param {Function} [opt.onStdout=undefined] 輸入stdout串流回調函數,格式為(chunk)=>{},預設undefined
517
536
  * @param {Function} [opt.onStderr=undefined] 輸入stderr串流回調函數,格式為(chunk)=>{},預設undefined
537
+ * @param {Object} [opt.env=undefined] 輸入本次調用額外注入之環境變數物件,會併入process.env之後(同名以此為準,含PYTHONIOENCODING),僅作用於該次子進程而不影響本進程之process.env,故並行調用可各自帶不同值;值為undefined代表移除該變數(可遮蔽繼承值),值為null會成為字面字串'null'故建議勿傳;Windows下環境變數大小寫不敏感,同名不同大小寫(如Path與PATH)亦視為同名覆蓋,預設undefined代表不覆寫任何變數
518
538
  * @param {Number} [opt.maxRetries=0] 輸入失敗後最大重試次數非負整數,遇ENOENT(命令不存在)或exit code 2(參數錯誤)視為不可重試而立即中止,預設0
519
539
  * @param {Number} [opt.retryDelayMs=5000] 輸入重試間隔毫秒正整數,實際間隔為retryDelayMs乘以重試次數且上限15000ms,預設5000
520
540
  * @returns {Promise} 回傳Promise,resolve回傳結果物件,內含ok(是否成功布林值)、stdout(標準輸出字串)、stderr(標準錯誤字串)、code(離開碼)、error(錯誤訊息字串,成功時為空字串)、durationMs(耗時毫秒)、pid(子進程pid)、attempts(實際嘗試次數)
@@ -545,6 +565,10 @@ function execCliOnce(command, args = [], opt = {}) {
545
565
  * console.log('r5', r5.ok, r5.error)
546
566
  * // => r5 false TIMEOUT after 0.5s
547
567
  *
568
+ * let r6 = await execCli(nodeBin, ['-e', 'process.stdout.write(process.env.API_KEY)'], { env: { API_KEY: 'KEY_A' } })
569
+ * console.log('r6', r6.ok, r6.stdout, process.env.API_KEY)
570
+ * // => r6 true KEY_A undefined (僅作用於該次子進程, 本進程process.env不受影響)
571
+ *
548
572
  * }
549
573
  * test()
550
574
  * .catch((err) => {
@@ -597,6 +621,15 @@ async function execCli(command, args = [], opt = {}) {
597
621
  onceOpt.input = input
598
622
  }
599
623
 
624
+ //env: 逐次注入之環境變數物件, 無效回退預設undefined(未提供 = 不覆寫任何變數)
625
+ let env = get(onceOpt, 'env', null)
626
+ if (!isobj(env)) {
627
+ onceOpt.env = undefined
628
+ }
629
+ else {
630
+ onceOpt.env = env
631
+ }
632
+
600
633
  //validate: 驗證規則字串, 無效回退預設undefined(未提供 = 不驗證)
601
634
  //注意: validate亦可為自訂函數(buildValidator支援), 故先放行function不覆蓋
602
635
  let validate = get(onceOpt, 'validate', null)
package/src/index.mjs CHANGED
@@ -387,6 +387,7 @@ export { default as str2b64 } from './str2b64.mjs'
387
387
  export { default as str2hint } from './str2hint.mjs'
388
388
  export { default as str2md5 } from './str2md5.mjs'
389
389
  export { default as str2obj } from './str2obj.mjs'
390
+ export { default as str2sha } from './str2sha.mjs'
390
391
  export { default as str2sha512 } from './str2sha512.mjs'
391
392
  export { default as str2u8arr } from './str2u8arr.mjs'
392
393
  export { default as strCompare } from './strCompare.mjs'
package/src/obj2str.mjs CHANGED
@@ -9,9 +9,9 @@ import isarr from './isarr.mjs'
9
9
  *
10
10
  * Unit Test: {@link https://github.com/yuda-lyu/wsemi/blob/master/test/obj2str.test.mjs Github}
11
11
  * @memberOf wsemi
12
- * @param {*} data 輸入任意資料
13
- * @param {String|Array} [ext='Uint8Array'] 輸入擴充數據種類字串或陣列,預設'Uint8Array'
14
- * @returns {String} 回傳base64字串
12
+ * @param {*} data 輸入任意資料,為undefined時回傳空字串
13
+ * @param {String|Array} [ext='Uint8Array'] 輸入擴充數據種類字串或陣列,非字串亦非陣列時回退為'Uint8Array',預設'Uint8Array'
14
+ * @returns {String} 回傳轉換後字串,data為undefined或無法轉為JSON時回傳空字串
15
15
  * @example
16
16
  *
17
17
  * let o = {
@@ -34,7 +34,8 @@ function obj2str(data, ext = 'Uint8Array') {
34
34
  return ''
35
35
  }
36
36
 
37
- //ext
37
+ //ext, 無效時回退預設值
38
+ //回退值須為陣列而非字串, 以與isstr分支轉出之型別一致, 否則後續ext.indexOf將由陣列比對變為字串子字串搜尋
38
39
  if (isstr(ext)) {
39
40
  ext = [ext]
40
41
  }
@@ -42,8 +43,7 @@ function obj2str(data, ext = 'Uint8Array') {
42
43
  //none
43
44
  }
44
45
  else {
45
- //ext error
46
- return ''
46
+ ext = ['Uint8Array']
47
47
  }
48
48
 
49
49
  //replacer
package/src/str2aes.mjs CHANGED
@@ -16,10 +16,10 @@ import isbol from './isbol.mjs'
16
16
  *
17
17
  * Unit Test: {@link https://github.com/yuda-lyu/wsemi/blob/master/test/str2aes.test.mjs Github}
18
18
  * @memberOf wsemi
19
- * @param {String} str 輸入一般字串
20
- * @param {String} key 輸入加密key
21
- * @param {Boolean} [base64=false] 輸入是否轉為base64字串,預設為false
22
- * @returns {String} 回傳經AES轉換後字串,採Hex/base64顯示
19
+ * @param {String} str 輸入一般字串,非有效字串時回傳空字串
20
+ * @param {String} key 輸入加密key,非有效字串時回傳空字串
21
+ * @param {Boolean} [base64=false] 輸入是否轉為base64字串,非布林值時回退為false,預設為false
22
+ * @returns {String} 回傳經AES轉換後字串,採Hex/base64顯示,str或key非有效字串時回傳空字串
23
23
  * @example
24
24
  *
25
25
  * let str = 'test中文abcdefghijklmn'
@@ -62,8 +62,10 @@ function str2aes(str, key, base64 = false) {
62
62
  if (!isestr(key)) {
63
63
  return ''
64
64
  }
65
+
66
+ //check
65
67
  if (!isbol(base64)) {
66
- return ''
68
+ base64 = false
67
69
  }
68
70
 
69
71
  let o = AES.encrypt(str, key)
package/src/str2md5.mjs CHANGED
@@ -13,9 +13,9 @@ import isbol from './isbol.mjs'
13
13
  *
14
14
  * Unit Test: {@link https://github.com/yuda-lyu/wsemi/blob/master/test/str2md5.test.mjs Github}
15
15
  * @memberOf wsemi
16
- * @param {String} str 輸入一般字串
17
- * @param {Boolean} [base64=false] 輸入是否轉為base64字串,預設為false
18
- * @returns {String} 回傳經MD5轉換後字串
16
+ * @param {String} str 輸入一般字串,非有效字串時回傳空字串
17
+ * @param {Boolean} [base64=false] 輸入是否轉為base64字串,非布林值時回退為false,預設為false
18
+ * @returns {String} 回傳經MD5轉換後字串,str非有效字串時回傳空字串
19
19
  * @example
20
20
  *
21
21
  * console.log(str2md5('test中文'))
@@ -28,8 +28,10 @@ function str2md5(str, base64 = false) {
28
28
  if (!isestr(str)) {
29
29
  return ''
30
30
  }
31
+
32
+ //check
31
33
  if (!isbol(base64)) {
32
- return ''
34
+ base64 = false
33
35
  }
34
36
 
35
37
  let o = MD5(str)
package/src/str2obj.mjs CHANGED
@@ -9,8 +9,8 @@ import isarr from './isarr.mjs'
9
9
  * Unit Test: {@link https://github.com/yuda-lyu/wsemi/blob/master/test/str2obj.test.mjs Github}
10
10
  * @memberOf wsemi
11
11
  * @param {*} data 輸入任意資料
12
- * @param {String|Array} [ext='Uint8Array'] 輸入擴充數據種類字串或陣列,預設'Uint8Array'
13
- * @returns {String} 回傳base64字串
12
+ * @param {String|Array} [ext='Uint8Array'] 輸入擴充數據種類字串或陣列,非字串亦非陣列時回退為'Uint8Array',預設'Uint8Array'
13
+ * @returns {Object} 回傳轉換後資料,data無法解析為JSON時回傳空物件
14
14
  * @example
15
15
  *
16
16
  * console.log(str2obj('{"a":"abc","b":12.3,"u8a":"[Uint8Array]::QmFz","u16a":{"0":11,"1":79,"2":6}}'))
@@ -32,7 +32,8 @@ import isarr from './isarr.mjs'
32
32
  */
33
33
  function str2obj(data, ext = 'Uint8Array') {
34
34
 
35
- //ext
35
+ //ext, 無效時回退預設值
36
+ //回退值須為陣列而非字串, 以與isstr分支轉出之型別一致, 否則後續ext.indexOf將由陣列比對變為字串子字串搜尋
36
37
  if (isstr(ext)) {
37
38
  ext = [ext]
38
39
  }
@@ -40,8 +41,7 @@ function str2obj(data, ext = 'Uint8Array') {
40
41
  //none
41
42
  }
42
43
  else {
43
- //ext error
44
- return {}
44
+ ext = ['Uint8Array']
45
45
  }
46
46
 
47
47
  //replacer
@@ -0,0 +1,120 @@
1
+ import SHA1 from 'crypto-js/sha1.js'
2
+ import SHA224 from 'crypto-js/sha224.js'
3
+ import SHA256 from 'crypto-js/sha256.js'
4
+ import SHA384 from 'crypto-js/sha384.js'
5
+ import SHA512 from 'crypto-js/sha512.js'
6
+ import encb64 from 'crypto-js/enc-base64.js'
7
+ import enchex from 'crypto-js/enc-hex.js'
8
+ import isbol from './isbol.mjs'
9
+ import isestr from './isestr.mjs'
10
+ import ispint from './ispint.mjs'
11
+ import cint from './cint.mjs'
12
+ import haskey from './haskey.mjs'
13
+
14
+
15
+ //crypto-js沒有支援chunk或stream機制, 無法處理大量資料
16
+
17
+
18
+ //kpSha, 可用之n與其對應之演算法, 即SHA-1與SHA-2系列(SHA-224/SHA-256/SHA-384/SHA-512)
19
+ //n為演算法名稱之數字, 除SHA-1之1為版本號(實際輸出160位元)外, 其餘皆為輸出位元數
20
+ //crypto-js雖另有SHA-3, 但其為獨立演算法族且輸出位元數與SHA-2重疊(如256), 併入將使n產生歧義故不納入
21
+ let kpSha = {
22
+ 1: SHA1,
23
+ 224: SHA224,
24
+ 256: SHA256,
25
+ 384: SHA384,
26
+ 512: SHA512,
27
+ }
28
+
29
+
30
+ /**
31
+ * 一般字串轉SHA字串
32
+ * Secure Hash Algorithm n位
33
+ *
34
+ * n僅可為1、224、256、384、512,分別對應SHA-1、SHA-224、SHA-256、SHA-384、SHA-512
35
+ * 其中SHA-1之1為演算法版本號而非輸出位元數(實際輸出160位元),且已被證實可構造碰撞,僅適用於非資安用途之校驗
36
+ * n為其餘值時視為程式撰寫錯誤而擲出錯誤,非正整數擲出'n is not a positive integer',正整數但不在可用範圍則擲出'invalid n[n]'
37
+ *
38
+ * Unit Test: {@link https://github.com/yuda-lyu/wsemi/blob/master/test/str2sha.test.mjs Github}
39
+ * @memberOf wsemi
40
+ * @param {String} str 輸入一般字串,非有效字串時回傳空字串
41
+ * @param {Number} n 輸入演算法位數,僅可為1、224、256、384、512,其餘一律擲出錯誤
42
+ * @param {Boolean} [base64=false] 輸入是否轉為base64字串,非布林值時回退為false,預設為false
43
+ * @returns {String} 回傳經SHA-n轉換後字串,str非有效字串時回傳空字串
44
+ * @example
45
+ *
46
+ * console.log(str2sha('test中文', 1))
47
+ * // => 'ecabf586cef0d3b11c56549433ad50b81110a836'
48
+ *
49
+ * console.log(str2sha('test中文', 224))
50
+ * // => 'c9b3eebeae6fe7e42cd9680475787a77e234bce0abb8d599d995b2a6'
51
+ *
52
+ * console.log(str2sha('test中文', 256))
53
+ * // => '8af7c7959618cc0900be74a52eee44aca05aeb72525864dc7ae25d31761beb65'
54
+ *
55
+ * console.log(str2sha('test中文', 384))
56
+ * // => '219ece10ffe81c179511d4ffa43a0c75bbee737acdd18ee11839a1def78a4e10c94186ef8483fce85d0589bcbddf632e'
57
+ *
58
+ * console.log(str2sha('test中文', 512))
59
+ * // => 'ab43333a01571e767a2eb15460c270fa123964c121b88c73e274a211d6e2cf98b10d89220e8d04e2fc573354da93400f3255e94d445dc956e177aa4201a4fc30'
60
+ *
61
+ * console.log(str2sha('test中文', 256, true))
62
+ * // => 'ivfHlZYYzAkAvnSlLu5ErKBa63JSWGTceuJdMXYb62U='
63
+ *
64
+ * try {
65
+ * str2sha('test中文', 160) //160為SHA-1之輸出位元數而非其演算法名稱, 不可用
66
+ * }
67
+ * catch (err) {
68
+ * console.log(err.message)
69
+ * // => invalid n[160]
70
+ * }
71
+ *
72
+ * try {
73
+ * str2sha('test中文', 'abc')
74
+ * }
75
+ * catch (err) {
76
+ * console.log(err.message)
77
+ * // => n is not a positive integer
78
+ * }
79
+ *
80
+ */
81
+ function str2sha(str, n, base64 = false) {
82
+
83
+ //check
84
+ if (!isestr(str)) {
85
+ return ''
86
+ }
87
+
88
+ //check n, 須為正整數
89
+ //此檢核須置於haskey之前: haskey內部為key in obj而含原型鏈, 'toString'等鍵會誤判為存在
90
+ if (!ispint(n)) {
91
+ throw new Error(`n is not a positive integer`)
92
+ }
93
+ n = cint(n)
94
+
95
+ //check n, 須為kpSha內可用之n
96
+ if (!haskey(kpSha, n)) {
97
+ throw new Error(`invalid n[${n}]`)
98
+ }
99
+
100
+ //check
101
+ if (!isbol(base64)) {
102
+ base64 = false
103
+ }
104
+
105
+ let fnSha = kpSha[n]
106
+
107
+ let o = fnSha(str)
108
+ let c = ''
109
+ if (base64) {
110
+ c = o.toString(encb64)
111
+ }
112
+ else {
113
+ c = o.toString(enchex)
114
+ }
115
+
116
+ return c
117
+ }
118
+
119
+
120
+ export default str2sha
@@ -1,49 +1,29 @@
1
- import SHA512 from 'crypto-js/sha512.js'
2
- import encb64 from 'crypto-js/enc-base64.js'
3
- import enchex from 'crypto-js/enc-hex.js'
4
- import isestr from './isestr.mjs'
5
- import isbol from './isbol.mjs'
6
-
7
-
8
- //crypto-js沒有支援chunk或stream機制, 無法處理大量資料
9
-
10
-
11
- /**
12
- * 一般字串轉SHA512字串
13
- * Secure Hash Algorithm 512位
14
- *
15
- * Unit Test: {@link https://github.com/yuda-lyu/wsemi/blob/master/test/str2sha512.test.mjs Github}
16
- * @memberOf wsemi
17
- * @param {String} str 輸入一般字串
18
- * @param {Boolean} [base64=false] 輸入是否轉為base64字串,預設為false
19
- * @returns {String} 回傳經SHA512轉換後字串
20
- * @example
21
- *
22
- * console.log(str2sha512('test中文'))
23
- * // => 'ab43333a01571e767a2eb15460c270fa123964c121b88c73e274a211d6e2cf98b10d89220e8d04e2fc573354da93400f3255e94d445dc956e177aa4201a4fc30'
24
- *
25
- */
26
- function str2sha512(str, base64 = false) {
27
-
28
- //check
29
- if (!isestr(str)) {
30
- return ''
31
- }
32
- if (!isbol(base64)) {
33
- return ''
34
- }
35
-
36
- let o = SHA512(str)
37
- let c = ''
38
- if (base64) {
39
- c = o.toString(encb64)
40
- }
41
- else {
42
- c = o.toString(enchex)
43
- }
44
-
45
- return c
46
- }
47
-
48
-
49
- export default str2sha512
1
+ import str2sha from './str2sha.mjs'
2
+
3
+
4
+ //crypto-js沒有支援chunk或stream機制, 無法處理大量資料
5
+
6
+
7
+ /**
8
+ * 一般字串轉SHA512字串
9
+ * Secure Hash Algorithm 512位
10
+ *
11
+ * 內部調用str2sha並固定n為512
12
+ *
13
+ * Unit Test: {@link https://github.com/yuda-lyu/wsemi/blob/master/test/str2sha512.test.mjs Github}
14
+ * @memberOf wsemi
15
+ * @param {String} str 輸入一般字串,非有效字串時回傳空字串
16
+ * @param {Boolean} [base64=false] 輸入是否轉為base64字串,非布林值時回退為false,預設為false
17
+ * @returns {String} 回傳經SHA512轉換後字串,str非有效字串時回傳空字串
18
+ * @example
19
+ *
20
+ * console.log(str2sha512('test中文'))
21
+ * // => 'ab43333a01571e767a2eb15460c270fa123964c121b88c73e274a211d6e2cf98b10d89220e8d04e2fc573354da93400f3255e94d445dc956e177aa4201a4fc30'
22
+ *
23
+ */
24
+ function str2sha512(str, base64 = false) {
25
+ return str2sha(str, 512, base64)
26
+ }
27
+
28
+
29
+ export default str2sha512
@@ -27,6 +27,22 @@ describe(`aes2str`, function() {
27
27
  assert.strict.deepStrictEqual(r, rr)
28
28
  })
29
29
 
30
+ it(`sould fallback base64 to false when base64 is an invalid type`, function() {
31
+ //base64非布林值時回退為false, 即視來源為hex, 結果須等同明確傳false
32
+ for (let v of ['', [], {}, null, 1]) {
33
+ let r = aes2str(o[1], key, v)
34
+ assert.strict.deepStrictEqual(r, str)
35
+ }
36
+ })
37
+
38
+ it(`should return '' when key is an invalid type`, function() {
39
+ assert.strict.deepStrictEqual(aes2str(o[1], ''), '')
40
+ assert.strict.deepStrictEqual(aes2str(o[1], []), '')
41
+ assert.strict.deepStrictEqual(aes2str(o[1], {}), '')
42
+ assert.strict.deepStrictEqual(aes2str(o[1], null), '')
43
+ assert.strict.deepStrictEqual(aes2str(o[1], undefined), '')
44
+ })
45
+
30
46
  it(`should return '' when input 12.34`, function() {
31
47
  let r = aes2str(12.34)
32
48
  let rr = ''
@@ -110,6 +110,86 @@ describe(`execCli`, function() {
110
110
  assert.strict.deepStrictEqual(cerr.includes('errmsg'), true)
111
111
  })
112
112
 
113
+ it(`should not change env behavior when opt.env is not provided`, async function() {
114
+ let r = await execCli(nodeBin, ['-e', 'process.stdout.write(String(process.env.ENVTEST_FOO))'])
115
+ assert.strict.deepStrictEqual(r.ok, true)
116
+ assert.strict.deepStrictEqual(r.stdout, 'undefined')
117
+ })
118
+
119
+ it(`should inject opt.env into child process`, async function() {
120
+ let r = await execCli(nodeBin, ['-e', 'process.stdout.write(process.env.ENVTEST_FOO)'], { env: { ENVTEST_FOO: 'BAR中文' } })
121
+ assert.strict.deepStrictEqual(r.ok, true)
122
+ assert.strict.deepStrictEqual(r.stdout, 'BAR中文')
123
+ })
124
+
125
+ it(`should not pollute parent process.env when opt.env is injected`, async function() {
126
+ await execCli(nodeBin, ['-e', 'process.stdout.write("ok")'], { env: { ENVTEST_FOO: 'BAR' } })
127
+ assert.strict.deepStrictEqual(process.env.ENVTEST_FOO, undefined)
128
+ })
129
+
130
+ it(`should keep inherited env vars when opt.env is injected`, async function() {
131
+ //注入不應清空繼承環境, 否則Windows下子進程連PATH都拿不到
132
+ let r = await execCli(nodeBin, ['-e', 'process.stdout.write(JSON.stringify(Object.keys(process.env).length > 3))'], { env: { ENVTEST_FOO: 'BAR' } })
133
+ assert.strict.deepStrictEqual(r.ok, true)
134
+ assert.strict.deepStrictEqual(r.stdout, 'true')
135
+ })
136
+
137
+ it(`should fallback to no injection when opt.env is not an object`, async function() {
138
+ let r = await execCli(nodeBin, ['-e', 'process.stdout.write("ok")'], { env: 'not-an-object' })
139
+ assert.strict.deepStrictEqual(r.ok, true)
140
+ assert.strict.deepStrictEqual(r.stdout, 'ok')
141
+ })
142
+
143
+ it(`should keep opt.env injection stable across parallel calls with retries`, async function() {
144
+ //3路並行各帶不同值, 以validate強制失敗走重試路徑, 用onStdout側錄每次attempt實得值
145
+ //改process.env之作法於重試階段(await delay之後)必被其他並行路污染, opt.env須全數正確
146
+ let seen = { A: [], B: [], C: [] }
147
+ await Promise.all(['A', 'B', 'C'].map((v) => execCli(
148
+ nodeBin, ['-e', 'process.stdout.write(process.env.ENVTEST_KEY)'],
149
+ {
150
+ env: { ENVTEST_KEY: v },
151
+ validate: () => false, //強制每次attempt失敗以觸發重試
152
+ maxRetries: 1,
153
+ retryDelayMs: 100,
154
+ onStdout: (chunk) => {
155
+ seen[v].push(String(chunk).trim())
156
+ },
157
+ }
158
+ )))
159
+ // console.log('seen', JSON.stringify(seen))
160
+ //每路含重試共2次attempt, 實得值皆須等於該路自己的注入值
161
+ for (let v of ['A', 'B', 'C']) {
162
+ assert.strict.deepStrictEqual(seen[v].length >= 2, true)
163
+ assert.strict.deepStrictEqual(seen[v].every((s) => s === v), true)
164
+ }
165
+ })
166
+
167
+ it(`should treat undefined value in opt.env as removing the variable`, async function() {
168
+ //值為undefined代表移除該變數, 可遮蔽繼承值; 以PYTHONIOENCODING(execCli必注入)驗證
169
+ let sc = 'process.stdout.write(JSON.stringify("PYTHONIOENCODING" in process.env))'
170
+ let r1 = await execCli(nodeBin, ['-e', sc])
171
+ assert.strict.deepStrictEqual(r1.stdout, 'true')
172
+ let r2 = await execCli(nodeBin, ['-e', sc], { env: { PYTHONIOENCODING: undefined } })
173
+ assert.strict.deepStrictEqual(r2.stdout, 'false')
174
+ })
175
+
176
+ it(`should let opt.env override PYTHONIOENCODING`, async function() {
177
+ let r = await execCli(nodeBin, ['-e', 'process.stdout.write(process.env.PYTHONIOENCODING)'], { env: { PYTHONIOENCODING: 'ascii' } })
178
+ assert.strict.deepStrictEqual(r.ok, true)
179
+ assert.strict.deepStrictEqual(r.stdout, 'ascii')
180
+ })
181
+
182
+ if (process.platform === 'win32') {
183
+ it(`should override same-name env var with different case on Windows`, async function() {
184
+ //Windows環境變數大小寫不敏感: 呼叫端傳Path須能覆蓋繼承之PATH, 不可兩鍵並存致注入靜默失效
185
+ let sc = 'const ks=Object.keys(process.env).filter((k)=>k.toLowerCase()==="path");process.stdout.write(JSON.stringify(ks.map((k)=>process.env[k])))'
186
+ let r = await execCli(nodeBin, ['-e', sc], { env: { Path: 'C:\\envtest-injected' } })
187
+ // console.log('case r', JSON.stringify(r.stdout))
188
+ assert.strict.deepStrictEqual(r.ok, true)
189
+ assert.strict.deepStrictEqual(JSON.parse(r.stdout), ['C:\\envtest-injected'])
190
+ })
191
+ }
192
+
113
193
  it(`should pass validate 'nonempty' when stdout has content`, async function() {
114
194
  let r = await execCli(nodeBin, ['-e', 'process.stdout.write("abc")'], { validate: 'nonempty' })
115
195
  assert.strict.deepStrictEqual(r.ok, true)
@@ -1,5 +1,6 @@
1
1
  import assert from 'assert'
2
2
  import obj2str from '../src/obj2str.mjs'
3
+ import str2obj from '../src/str2obj.mjs'
3
4
 
4
5
 
5
6
  describe(`obj2str`, function() {
@@ -25,6 +26,27 @@ describe(`obj2str`, function() {
25
26
  assert.strict.deepStrictEqual(r, rr)
26
27
  })
27
28
 
29
+ it(`should fallback ext to 'Uint8Array' when ext is an invalid type`, function() {
30
+ //ext非字串亦非陣列時回退為預設之'Uint8Array', 結果須等同未給ext
31
+ for (let v of [null, undefined, 12.34, {}, true, NaN]) {
32
+ let r = obj2str(o, v)
33
+ assert.strict.deepStrictEqual(r, co1)
34
+ }
35
+ })
36
+
37
+ it(`should treat string ext the same as single-element array ext`, function() {
38
+ //回退值與isstr分支轉出之型別須一致, 皆為陣列, 故二者結果須相同
39
+ assert.strict.deepStrictEqual(obj2str(o, 'Uint8Array'), obj2str(o, ['Uint8Array']))
40
+ assert.strict.deepStrictEqual(obj2str(o, 'Uint16Array'), obj2str(o, ['Uint16Array']))
41
+ })
42
+
43
+ it(`should round-trip with str2obj under invalid ext`, function() {
44
+ //obj2str與str2obj須成對使用相同ext, 兩端對無效ext之回退一致才能正確往返
45
+ let c = obj2str(o, null)
46
+ let r = str2obj(c, null)
47
+ assert.strict.deepStrictEqual(r.u8a, o.u8a)
48
+ })
49
+
28
50
  it(`should return '[1,"3","abc"]' when input [1, '3', 'abc']`, function() {
29
51
  let r = obj2str([1, '3', 'abc'])
30
52
  let rr = '[1,"3","abc"]'
@@ -18,6 +18,23 @@ describe(`str2aes`, function() {
18
18
  assert.strict.deepStrictEqual(r.length, rr)
19
19
  })
20
20
 
21
+ it(`sould fallback base64 to false when base64 is an invalid type`, function() {
22
+ //base64非布林值時回退為false, 即輸出hex(96字元), 而非base64(64字元)
23
+ //AES每次加密含隨機salt故密文不固定, 以長度辨別輸出格式
24
+ for (let v of ['', [], {}, null, 1]) {
25
+ let r = str2aes(str, key, v)
26
+ assert.strict.deepStrictEqual(r.length, 96)
27
+ }
28
+ })
29
+
30
+ it(`should return '' when key is an invalid type`, function() {
31
+ assert.strict.deepStrictEqual(str2aes(str, ''), '')
32
+ assert.strict.deepStrictEqual(str2aes(str, []), '')
33
+ assert.strict.deepStrictEqual(str2aes(str, {}), '')
34
+ assert.strict.deepStrictEqual(str2aes(str, null), '')
35
+ assert.strict.deepStrictEqual(str2aes(str, undefined), '')
36
+ })
37
+
21
38
  it(`should return '' when input 12.34`, function() {
22
39
  let r = str2aes(12.34)
23
40
  let rr = ''