wsemi 1.8.11 → 1.8.13

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 (484) hide show
  1. package/README.md +11 -18
  2. package/dist/wsemi.umd.js +5 -5
  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 +2 -2
  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 +3 -3
  62. package/docs/cacheBd.mjs.html +309 -0
  63. package/docs/cbol.mjs.html +2 -2
  64. package/docs/cdbl.mjs.html +2 -2
  65. package/docs/ceil.mjs.html +2 -2
  66. package/docs/cfilesize.mjs.html +2 -2
  67. package/docs/cfinancial.mjs.html +2 -2
  68. package/docs/cint.mjs.html +2 -2
  69. package/docs/clearXSS.mjs.html +2 -2
  70. package/docs/clearXSSDyn.mjs.html +2 -2
  71. package/docs/color.mjs.html +2 -2
  72. package/docs/composeToTree.mjs.html +2 -2
  73. package/docs/convertToTree.mjs.html +2 -2
  74. package/docs/copyStrToClipboard.mjs.html +2 -2
  75. package/docs/cosd.mjs.html +2 -2
  76. package/docs/cotd.mjs.html +2 -2
  77. package/docs/createExcelWorkbook.mjs.html +2 -2
  78. package/docs/cscd.mjs.html +2 -2
  79. package/docs/cstr.mjs.html +2 -2
  80. package/docs/day2cht.mjs.html +2 -2
  81. package/docs/debounce.mjs.html +2 -2
  82. package/docs/delay.mjs.html +2 -2
  83. package/docs/dig.mjs.html +2 -2
  84. package/docs/digExp.mjs.html +2 -2
  85. package/docs/domAlert.mjs.html +2 -2
  86. package/docs/domAppend.mjs.html +2 -2
  87. package/docs/domCancelEvent.mjs.html +2 -2
  88. package/docs/domCompareText.mjs.html +2 -2
  89. package/docs/domCompareTextDyn.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/domIsVisible.mjs.html +2 -2
  114. package/docs/domPrepend.mjs.html +2 -2
  115. package/docs/domRemove.mjs.html +2 -2
  116. package/docs/domRenderMarkdownMind.mjs.html +2 -2
  117. package/docs/domRenderMarkdownMindDyn.mjs.html +2 -2
  118. package/docs/domRipple.mjs.html +2 -2
  119. package/docs/domScrollIntoView.mjs.html +2 -2
  120. package/docs/domScrollTo.mjs.html +2 -2
  121. package/docs/domShowImages.mjs.html +2 -2
  122. package/docs/domShowImagesDyn.mjs.html +2 -2
  123. package/docs/domShowInputAndGetFiles.mjs.html +2 -2
  124. package/docs/domShowInputAndGetFilesU8Arrs.mjs.html +2 -2
  125. package/docs/domShowInputDatatime.mjs.html +2 -2
  126. package/docs/domTooltip.mjs.html +2 -2
  127. package/docs/domTriggerEvent.mjs.html +2 -2
  128. package/docs/domVirtualCreate.mjs.html +2 -2
  129. package/docs/domVirtualCreateQueue.mjs.html +2 -2
  130. package/docs/downloadExcelFileFromData.mjs.html +2 -2
  131. package/docs/downloadExcelFileFromDataDyn.mjs.html +2 -2
  132. package/docs/downloadFileFromB64.mjs.html +2 -2
  133. package/docs/downloadFileFromBlob.mjs.html +2 -2
  134. package/docs/downloadFileFromText.mjs.html +2 -2
  135. package/docs/downloadFileFromU8Arr.mjs.html +2 -2
  136. package/docs/dtmapping.mjs.html +2 -2
  137. package/docs/dtpick.mjs.html +2 -2
  138. package/docs/estimateTicks.mjs.html +2 -2
  139. package/docs/evem.mjs.html +2 -2
  140. package/docs/examples/ex-blob2b64.html +1 -1
  141. package/docs/examples/ex-clearXSS.html +1 -1
  142. package/docs/examples/ex-clearXSSDyn.html +1 -1
  143. package/docs/examples/ex-colorConverter.html +1 -1
  144. package/docs/examples/ex-domCompareText.html +1 -1
  145. package/docs/examples/ex-domCompareTextDyn.html +1 -1
  146. package/docs/examples/ex-domConvertToPic.html +1 -1
  147. package/docs/examples/ex-domConvertToPicDyn.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-execPyodide.html +1 -1
  161. package/docs/examples/ex-execPyodideDyn.html +1 -1
  162. package/docs/examples/ex-getFileHash.html +1 -1
  163. package/docs/examples/ex-getUserAgent.html +1 -1
  164. package/docs/examples/ex-getUserAgentDyn.html +1 -1
  165. package/docs/examples/ex-html2pic.html +1 -1
  166. package/docs/examples/ex-html2picDyn.html +1 -1
  167. package/docs/examples/ex-html2str.html +1 -1
  168. package/docs/examples/ex-html2strDyn.html +1 -1
  169. package/docs/examples/ex-obj2u8arr-u8arr2obj.html +1 -1
  170. package/docs/examples/ex-ocr.html +1 -1
  171. package/docs/examples/ex-ocrDyn.html +1 -1
  172. package/docs/examples/ex-openLink.html +1 -1
  173. package/docs/examples/ex-str2aes-aes2str.html +1 -1
  174. package/docs/examples/ex-str2b64-b642str.html +1 -1
  175. package/docs/examples/ex-strFindFuzz.html +1 -1
  176. package/docs/examples/ex-strFindFuzzDyn.html +1 -1
  177. package/docs/examples/ex-timeTZ2expire-timeTZ2past.html +1 -1
  178. package/docs/examples/ex-xlsx.html +1 -1
  179. package/docs/examples/ex-xlsxDyn.html +1 -1
  180. package/docs/execProcess.mjs.html +2 -2
  181. package/docs/execProcessKillPid.mjs.html +2 -2
  182. package/docs/execPyodide.mjs.html +2 -2
  183. package/docs/execPyodideDyn.mjs.html +2 -2
  184. package/docs/f2c.mjs.html +2 -2
  185. package/docs/filepathToTree.mjs.html +2 -2
  186. package/docs/files2data.mjs.html +2 -2
  187. package/docs/flattenToConn.mjs.html +2 -2
  188. package/docs/flattenTree.mjs.html +2 -2
  189. package/docs/floor.mjs.html +2 -2
  190. package/docs/fsBuildReadStreamText.mjs.html +181 -0
  191. package/docs/fsBuildWriteStreamText.mjs.html +10 -5
  192. package/docs/fsCleanFolder.mjs.html +2 -2
  193. package/docs/fsCleanFolderCore.mjs.html +2 -2
  194. package/docs/fsCopyFile.mjs.html +2 -2
  195. package/docs/fsCopyFileCore.mjs.html +2 -2
  196. package/docs/fsCopyFolder.mjs.html +2 -2
  197. package/docs/fsCopyFolderCore.mjs.html +2 -2
  198. package/docs/fsCreateFile.mjs.html +2 -2
  199. package/docs/fsCreateFileCore.mjs.html +2 -2
  200. package/docs/fsCreateFolder.mjs.html +2 -2
  201. package/docs/fsCreateFolderCore.mjs.html +2 -2
  202. package/docs/fsDeleteFile.mjs.html +2 -2
  203. package/docs/fsDeleteFileCore.mjs.html +2 -2
  204. package/docs/fsDeleteFileSafe.mjs.html +2 -2
  205. package/docs/fsDeleteFileSafeCore.mjs.html +2 -2
  206. package/docs/fsDeleteFolder.mjs.html +2 -2
  207. package/docs/fsDeleteFolderCore.mjs.html +2 -2
  208. package/docs/fsDeleteFolderSafe.mjs.html +2 -2
  209. package/docs/fsDeleteFolderSafeCore.mjs.html +2 -2
  210. package/docs/fsDownloadFile.mjs.html +2 -2
  211. package/docs/fsDownloadFileCore.mjs.html +2 -2
  212. package/docs/fsEvem.mjs.html +2 -2
  213. package/docs/fsGetFileBasicHash.mjs.html +2 -2
  214. package/docs/fsGetFileBasicHashCore.mjs.html +2 -2
  215. package/docs/fsGetFileHash.mjs.html +2 -2
  216. package/docs/fsGetFileHashCore.mjs.html +2 -2
  217. package/docs/fsGetFileXxHash.mjs.html +2 -2
  218. package/docs/fsGetFileXxHashCore.mjs.html +2 -2
  219. package/docs/fsGetFilesInFolder.mjs.html +2 -2
  220. package/docs/fsGetFilesInFolderCore.mjs.html +2 -2
  221. package/docs/fsGetFilesWithHashInFolder.mjs.html +2 -2
  222. package/docs/fsGetFilesWithHashInFolderCore.mjs.html +2 -2
  223. package/docs/fsGetFoldersInFolder.mjs.html +2 -2
  224. package/docs/fsGetFoldersInFolderCore.mjs.html +2 -2
  225. package/docs/fsIsFile.mjs.html +2 -2
  226. package/docs/fsIsFileCore.mjs.html +2 -2
  227. package/docs/fsIsFolder.mjs.html +2 -2
  228. package/docs/fsIsFolderCore.mjs.html +2 -2
  229. package/docs/fsMergeFiles.mjs.html +2 -2
  230. package/docs/fsMergeFilesCore.mjs.html +2 -2
  231. package/docs/fsReadText.mjs.html +2 -2
  232. package/docs/fsReadTextCore.mjs.html +2 -2
  233. package/docs/fsRenameFile.mjs.html +2 -2
  234. package/docs/fsRenameFileCore.mjs.html +2 -2
  235. package/docs/fsRenameFolder.mjs.html +2 -2
  236. package/docs/fsRenameFolderCore.mjs.html +2 -2
  237. package/docs/fsSrlog.mjs.html +2 -2
  238. package/docs/fsTask.mjs.html +2 -2
  239. package/docs/fsTreeFolder.mjs.html +2 -2
  240. package/docs/fsTreeFolderCore.mjs.html +2 -2
  241. package/docs/fsWatchFile.mjs.html +2 -2
  242. package/docs/fsWatchFolder.mjs.html +2 -2
  243. package/docs/fsWriteText.mjs.html +2 -2
  244. package/docs/fsWriteTextCore.mjs.html +2 -2
  245. package/docs/genGradientColor.mjs.html +2 -2
  246. package/docs/genID.mjs.html +2 -2
  247. package/docs/genPm.mjs.html +2 -2
  248. package/docs/getBufferSize.mjs.html +2 -2
  249. package/docs/getClearPathName.mjs.html +2 -2
  250. package/docs/getCsvStrFromData.mjs.html +2 -2
  251. package/docs/getDataFromExcelFileU8Arr.mjs.html +2 -2
  252. package/docs/getDataFromExcelFileU8ArrDyn.mjs.html +2 -2
  253. package/docs/getEnv.mjs.html +2 -2
  254. package/docs/getExcelU8ArrFromData.mjs.html +2 -2
  255. package/docs/getExcelU8ArrFromWorkbook.mjs.html +2 -2
  256. package/docs/getExcelWorkbookFromData.mjs.html +2 -2
  257. package/docs/getExcelWorkbookFromWorksheet.mjs.html +2 -2
  258. package/docs/getExcelWorksheetFromData.mjs.html +2 -2
  259. package/docs/getFileAccept.mjs.html +2 -2
  260. package/docs/getFileBasicHash.mjs.html +2 -2
  261. package/docs/getFileHash.mjs.html +2 -2
  262. package/docs/getFileName.mjs.html +2 -2
  263. package/docs/getFileNameExt.mjs.html +2 -2
  264. package/docs/getFileTrueName.mjs.html +2 -2
  265. package/docs/getFileType.mjs.html +2 -2
  266. package/docs/getFileXxHash.mjs.html +2 -2
  267. package/docs/getGlobal.mjs.html +2 -2
  268. package/docs/getObjSize.mjs.html +2 -2
  269. package/docs/getPathParent.mjs.html +2 -2
  270. package/docs/getTimeBetween.mjs.html +2 -2
  271. package/docs/getTimeFromUnit.mjs.html +2 -2
  272. package/docs/getTimeHp.mjs.html +2 -2
  273. package/docs/getTimeObject.mjs.html +2 -2
  274. package/docs/getTimeRange.mjs.html +2 -2
  275. package/docs/getUserAgent.mjs.html +2 -2
  276. package/docs/getUserAgentDyn.mjs.html +2 -2
  277. package/docs/getltdtkeys.mjs.html +2 -2
  278. package/docs/haskey.mjs.html +2 -2
  279. package/docs/html2pic.mjs.html +2 -2
  280. package/docs/html2picDyn.mjs.html +2 -2
  281. package/docs/html2str.mjs.html +2 -2
  282. package/docs/html2strDyn.mjs.html +2 -2
  283. package/docs/htmlDecode.mjs.html +2 -2
  284. package/docs/htmlEncode.mjs.html +2 -2
  285. package/docs/importResources.mjs.html +2 -2
  286. package/docs/index.html +2 -2
  287. package/docs/interp1.mjs.html +2 -2
  288. package/docs/isDate.mjs.html +2 -2
  289. package/docs/isDev.mjs.html +2 -2
  290. package/docs/isEle.mjs.html +2 -2
  291. package/docs/isEleExistByID.mjs.html +2 -2
  292. package/docs/isEmail.mjs.html +2 -2
  293. package/docs/isErr.mjs.html +2 -2
  294. package/docs/isIE.mjs.html +2 -2
  295. package/docs/isNarrow.mjs.html +2 -2
  296. package/docs/isStrHasCapital.mjs.html +2 -2
  297. package/docs/isStrHasLowerCase.mjs.html +2 -2
  298. package/docs/isStrHasNumber.mjs.html +2 -2
  299. package/docs/isUserIdentify.mjs.html +2 -2
  300. package/docs/isUserName.mjs.html +2 -2
  301. package/docs/isUserPW.mjs.html +2 -2
  302. package/docs/isWindow.mjs.html +2 -2
  303. package/docs/isab.mjs.html +2 -2
  304. package/docs/isarr.mjs.html +2 -2
  305. package/docs/isarr0.mjs.html +2 -2
  306. package/docs/isblob.mjs.html +2 -2
  307. package/docs/isbol.mjs.html +2 -2
  308. package/docs/isday.mjs.html +2 -2
  309. package/docs/isearr.mjs.html +2 -2
  310. package/docs/iseobj.mjs.html +2 -2
  311. package/docs/iser.mjs.html +2 -2
  312. package/docs/isernot.mjs.html +2 -2
  313. package/docs/isestr.mjs.html +2 -2
  314. package/docs/isfile.mjs.html +2 -2
  315. package/docs/isfun.mjs.html +2 -2
  316. package/docs/isint.mjs.html +2 -2
  317. package/docs/ismonth.mjs.html +2 -2
  318. package/docs/isn0int.mjs.html +2 -2
  319. package/docs/isn0num.mjs.html +2 -2
  320. package/docs/isnan.mjs.html +2 -2
  321. package/docs/isnbr.mjs.html +2 -2
  322. package/docs/isnint.mjs.html +2 -2
  323. package/docs/isnnum.mjs.html +2 -2
  324. package/docs/isnull.mjs.html +2 -2
  325. package/docs/isnum.mjs.html +2 -2
  326. package/docs/isobj.mjs.html +2 -2
  327. package/docs/isobj0.mjs.html +2 -2
  328. package/docs/isp0int.mjs.html +2 -2
  329. package/docs/isp0num.mjs.html +2 -2
  330. package/docs/ispint.mjs.html +2 -2
  331. package/docs/ispm.mjs.html +2 -2
  332. package/docs/ispnum.mjs.html +2 -2
  333. package/docs/isstr.mjs.html +2 -2
  334. package/docs/isstr0.mjs.html +2 -2
  335. package/docs/istime.mjs.html +2 -2
  336. package/docs/istimeTZ.mjs.html +2 -2
  337. package/docs/istimems.mjs.html +2 -2
  338. package/docs/istimemsTZ.mjs.html +2 -2
  339. package/docs/isu16arr.mjs.html +2 -2
  340. package/docs/isu8arr.mjs.html +2 -2
  341. package/docs/isundefined.mjs.html +2 -2
  342. package/docs/j2o.mjs.html +2 -2
  343. package/docs/judge.mjs.html +2 -2
  344. package/docs/keysmat2ltdt.mjs.html +2 -2
  345. package/docs/log.mjs.html +2 -2
  346. package/docs/ltdt2vrtsable.mjs.html +2 -2
  347. package/docs/ltdtDiff.mjs.html +2 -2
  348. package/docs/ltdtDiffByKey.mjs.html +2 -2
  349. package/docs/ltdtkeys2mat.mjs.html +2 -2
  350. package/docs/ltdtkeysheads2mat.mjs.html +2 -2
  351. package/docs/ltdtmapping.mjs.html +2 -2
  352. package/docs/ltdtmerge.mjs.html +2 -2
  353. package/docs/ltdtpick.mjs.html +2 -2
  354. package/docs/ltdtpull.mjs.html +2 -2
  355. package/docs/mat2ltdt.mjs.html +2 -2
  356. package/docs/matConcat.mjs.html +2 -2
  357. package/docs/matDiff.mjs.html +2 -2
  358. package/docs/matat.mjs.html +2 -2
  359. package/docs/now2str.mjs.html +2 -2
  360. package/docs/now2strp.mjs.html +2 -2
  361. package/docs/nowDay2str.mjs.html +2 -2
  362. package/docs/nowms2str.mjs.html +2 -2
  363. package/docs/nowms2strp.mjs.html +2 -2
  364. package/docs/o2j.mjs.html +2 -2
  365. package/docs/obj2b64.mjs.html +2 -2
  366. package/docs/obj2pb64.mjs.html +2 -2
  367. package/docs/obj2str.mjs.html +2 -2
  368. package/docs/obj2stru8arr.mjs.html +2 -2
  369. package/docs/obj2u8arr.mjs.html +2 -2
  370. package/docs/objSortBy.mjs.html +2 -2
  371. package/docs/objSortByKeys.mjs.html +2 -2
  372. package/docs/ocr.mjs.html +2 -2
  373. package/docs/ocrDyn.mjs.html +2 -2
  374. package/docs/oo.mjs.html +2 -2
  375. package/docs/openLink.mjs.html +2 -2
  376. package/docs/pb642obj.mjs.html +2 -2
  377. package/docs/pmChain.mjs.html +2 -2
  378. package/docs/pmConvertResolve.mjs.html +2 -2
  379. package/docs/pmDebounce.mjs.html +2 -49
  380. package/docs/pmHook.mjs.html +2 -2
  381. package/docs/pmHookReject.mjs.html +2 -2
  382. package/docs/pmIni.mjs.html +2 -2
  383. package/docs/pmInvResolve.mjs.html +2 -2
  384. package/docs/pmMap.mjs.html +10 -3
  385. package/docs/pmQueue.mjs.html +2 -2
  386. package/docs/pmSeries.mjs.html +2 -2
  387. package/docs/pmThrottle.mjs.html +3 -3
  388. package/docs/preciseNum.mjs.html +2 -2
  389. package/docs/pseudoRandom.mjs.html +2 -2
  390. package/docs/pseudoRandomIntRange.mjs.html +2 -2
  391. package/docs/pseudoRandomIntsNdpRange.mjs.html +2 -2
  392. package/docs/pseudoRandomIntsRange.mjs.html +2 -2
  393. package/docs/pseudoRandomRange.mjs.html +2 -2
  394. package/docs/pseudoRandomsRange.mjs.html +2 -2
  395. package/docs/queue.mjs.html +3 -3
  396. package/docs/random.mjs.html +2 -2
  397. package/docs/randomIntRange.mjs.html +2 -2
  398. package/docs/randomIntsNdpRange.mjs.html +2 -2
  399. package/docs/randomIntsRange.mjs.html +2 -2
  400. package/docs/randomRange.mjs.html +2 -2
  401. package/docs/randomsRange.mjs.html +2 -2
  402. package/docs/rang.mjs.html +2 -2
  403. package/docs/rep.mjs.html +2 -2
  404. package/docs/repObj.mjs.html +2 -2
  405. package/docs/replace.mjs.html +2 -2
  406. package/docs/replaceObj.mjs.html +2 -2
  407. package/docs/replacePlus.mjs.html +2 -2
  408. package/docs/round.mjs.html +2 -2
  409. package/docs/secd.mjs.html +2 -2
  410. package/docs/sep.mjs.html +2 -2
  411. package/docs/sepInt.mjs.html +2 -2
  412. package/docs/setIntervalHp.mjs.html +2 -2
  413. package/docs/setTimeoutHp.mjs.html +2 -2
  414. package/docs/sind.mjs.html +2 -2
  415. package/docs/split.mjs.html +2 -2
  416. package/docs/str2aes.mjs.html +2 -2
  417. package/docs/str2b64.mjs.html +2 -2
  418. package/docs/str2hint.mjs.html +2 -2
  419. package/docs/str2md5.mjs.html +2 -2
  420. package/docs/str2obj.mjs.html +2 -2
  421. package/docs/str2sha512.mjs.html +2 -2
  422. package/docs/str2u8arr.mjs.html +2 -2
  423. package/docs/strCompare.mjs.html +2 -2
  424. package/docs/strDiff.mjs.html +2 -2
  425. package/docs/strFindFuzz.mjs.html +2 -2
  426. package/docs/strFindFuzzDyn.mjs.html +2 -2
  427. package/docs/strFindSimilar.mjs.html +2 -2
  428. package/docs/strdelleft.mjs.html +2 -2
  429. package/docs/strdelright.mjs.html +2 -2
  430. package/docs/strleft.mjs.html +2 -2
  431. package/docs/strmid.mjs.html +2 -2
  432. package/docs/strright.mjs.html +2 -2
  433. package/docs/stru8arr2obj.mjs.html +2 -2
  434. package/docs/tand.mjs.html +2 -2
  435. package/docs/time2day.mjs.html +2 -2
  436. package/docs/time2hour.mjs.html +2 -2
  437. package/docs/time2min.mjs.html +2 -2
  438. package/docs/timeTZ2day.mjs.html +2 -2
  439. package/docs/timeTZ2expire.mjs.html +2 -2
  440. package/docs/timeTZ2hour.mjs.html +2 -2
  441. package/docs/timeTZ2min.mjs.html +2 -2
  442. package/docs/timeTZ2past.mjs.html +2 -2
  443. package/docs/timems2day.mjs.html +2 -2
  444. package/docs/timems2hour.mjs.html +2 -2
  445. package/docs/timems2min.mjs.html +2 -2
  446. package/docs/timems2time.mjs.html +2 -2
  447. package/docs/timemsTZ2day.mjs.html +2 -2
  448. package/docs/timemsTZ2expire.mjs.html +2 -2
  449. package/docs/timemsTZ2hour.mjs.html +2 -2
  450. package/docs/timemsTZ2min.mjs.html +2 -2
  451. package/docs/timemsTZ2past.mjs.html +2 -2
  452. package/docs/timemsTZ2time.mjs.html +2 -2
  453. package/docs/treeObj.mjs.html +2 -2
  454. package/docs/treeToFilepath.mjs.html +2 -2
  455. package/docs/trim.mjs.html +2 -2
  456. package/docs/u16arr2b64.mjs.html +2 -2
  457. package/docs/u16arr2u8arr.mjs.html +2 -2
  458. package/docs/u8arr2ab.mjs.html +2 -2
  459. package/docs/u8arr2b64.mjs.html +2 -2
  460. package/docs/u8arr2blob.mjs.html +2 -2
  461. package/docs/u8arr2bs.mjs.html +2 -2
  462. package/docs/u8arr2obj.mjs.html +2 -2
  463. package/docs/u8arr2str.mjs.html +2 -2
  464. package/docs/u8arr2u16arr.mjs.html +2 -2
  465. package/docs/urlParse.mjs.html +2 -2
  466. package/docs/verifyValue.mjs.html +2 -2
  467. package/docs/waitFun.mjs.html +2 -2
  468. package/docs/wsemi.html +658 -42
  469. package/g.mjs +145 -27
  470. package/package.json +1 -1
  471. package/src/cache.mjs +1 -1
  472. package/src/cacheBd.mjs +237 -0
  473. package/src/fsBuildReadStreamText.mjs +109 -0
  474. package/src/fsBuildWriteStreamText.mjs +8 -3
  475. package/src/index.mjs +2 -0
  476. package/src/pmDebounce.mjs +0 -47
  477. package/src/pmMap.mjs +8 -1
  478. package/src/pmThrottle.mjs +1 -1
  479. package/src/queue.mjs +1 -1
  480. package/test/cacheBd.test.mjs +174 -0
  481. package/test/fsBuildReadStreamText.test.mjs +68 -0
  482. package/toolfp/dist/wsemip.umd.js +2 -2
  483. package/toolparfor/dist/wpf.umd.js +2 -2
  484. package/toolparfor/dist/wpf_pmSeries.umd.js +1 -1
package/g.mjs CHANGED
@@ -6,47 +6,165 @@ import fsCreateFolder from './src/fsCreateFolder.mjs'
6
6
  import fsDeleteFolder from './src/fsDeleteFolder.mjs'
7
7
  import fsSrlog from './src/fsSrlog.mjs'
8
8
  import dig from './src/dig.mjs'
9
- import fsDownloadFile from './src/fsDownloadFile.mjs'
9
+ import genPm from './src/genPm.mjs'
10
+ import delay from './src/delay.mjs'
11
+ import cacheBd from './src/cacheBd.mjs'
10
12
 
11
- let test = async () => {
13
+
14
+ let test1 = async () => {
12
15
  let ms = []
13
16
 
14
- let fdt = './_test_fsDownloadFile'
15
- fsCreateFolder(fdt) //創建任務資料夾
17
+ let fun = async(p1, p2) => {
18
+ await delay(300)
19
+ return `${p1}:${p2}`
20
+ }
21
+
22
+ let bc = cacheBd(fun)
23
+ let execFun = bc.get
24
+ let execFunCache = bc.getByCache
16
25
 
17
- let urlIn = `https://raw.githubusercontent.com/yuda-lyu/w-demores/refs/heads/master/res/img/avatar/100.svg`
18
- let fpOut = `${fdt}/100.svg`
19
- await fsDownloadFile(urlIn, fpOut)
26
+ let pm1 = execFunCache(123, 'abc') //pm1執行取得快取, 因無快取將持續等待
27
+ pm1
20
28
  .then((res) => {
21
- console.log('res', res)
22
- ms.push({ fp: res })
29
+ // console.log('res', res)
30
+ ms.push({ result: `pm1-${res}` })
23
31
  })
24
- .catch((err) => {
25
- console.log('err', err)
32
+
33
+ let pm2 = execFun(4.56, 'def') //pm2執行原本函數與使用輸入, 會最先回傳, 且更新快取給等待或之後取得快取使用
34
+ pm2
35
+ .then((res) => {
36
+ // console.log('res', res)
37
+ ms.push({ result: `pm2-${res}` })
26
38
  })
27
39
 
28
- let c = fs.readFileSync(fpOut, 'utf8')
29
- console.log('c', c)
30
- ms.push({ content: c })
40
+ let pm3 = execFunCache(78.9, 'xyz') //pm3執行取得快取, 因已有快取將直接取得快取
41
+ pm3
42
+ .then((res) => {
43
+ // console.log('res', res)
44
+ ms.push({ result: `pm3-${res}` })
45
+ })
46
+
47
+ await Promise.all([pm1, pm2, pm3])
48
+ // console.log('rs', rs)
49
+
50
+ console.log('ms', ms)
51
+ return ms
52
+ }
53
+ await test1()
54
+ // ms [
55
+ // { result: 'pm2-4.56:def' },
56
+ // { result: 'pm1-4.56:def' },
57
+ // { result: 'pm3-4.56:def' }
58
+ // ]
59
+
60
+
61
+ let test2 = async () => {
62
+ let ms = []
63
+
64
+ let fun = async(p1, p2) => {
65
+ await delay(300)
66
+ return `${p1}:${p2}`
67
+ }
68
+
69
+ let bc = cacheBd(fun)
70
+ let execFun = bc.get
71
+ let execFunCache = bc.getByCache
72
+
73
+ setTimeout(() => {
74
+ console.log('pm1 exec..')
75
+ let pm1 = execFunCache(123, 'abc') //pm1執行取得快取, 因無快取將持續等待
76
+ pm1
77
+ .then((res) => {
78
+ console.log('pm1 then', res)
79
+ ms.push({ result: `pm1-${res}` })
80
+ })
81
+ }, 1)
82
+
83
+ setTimeout(() => {
84
+ console.log('pm2 exec..')
85
+ let pm2 = execFun(4.56, 'def') //1000ms後, pm2執行原本函數與使用輸入, 會最先回傳, 且更新快取給等待或之後取得快取使用
86
+ pm2
87
+ .then((res) => {
88
+ console.log('pm2 then', res)
89
+ ms.push({ result: `pm2-${res}` })
90
+ })
91
+ }, 1000)
92
+
93
+ setTimeout(() => {
94
+ console.log('pm3 exec..')
95
+ let pm3 = execFunCache(78.9, 'xyz') //pm3執行取得快取, 因已有快取將直接取得快取
96
+ pm3
97
+ .then((res) => {
98
+ console.log('pm3 then', res)
99
+ ms.push({ result: `pm3-${res}` })
100
+ })
101
+ }, 3000)
102
+
103
+ await delay(5000)
104
+
105
+ console.log('ms', ms)
106
+ return ms
107
+ }
108
+ await test2()
109
+ // ms [
110
+ // { result: 'pm2-4.56:def' },
111
+ // { result: 'pm1-4.56:def' },
112
+ // { result: 'pm3-4.56:def' }
113
+ // ]
114
+
115
+
116
+ let test3 = async () => {
117
+ let ms = []
118
+
119
+ let fun = async(p1, p2) => {
120
+ await delay(300)
121
+ return `${p1}:${p2}`
122
+ }
123
+
124
+ let bc = cacheBd(fun)
125
+ let execFun = bc.get
126
+ let execFunCache = bc.getByCache
127
+
128
+ setTimeout(() => {
129
+ console.log('pm1 exec..')
130
+ let pm1 = execFunCache(123, 'abc') //pm1執行取得快取, 因無快取將持續等待, 3000ms將執行get與自己的輸入, 並最先回傳
131
+ pm1
132
+ .then((res) => {
133
+ console.log('pm1 then', res)
134
+ ms.push({ result: `pm1-${res}` })
135
+ })
136
+ }, 1)
137
+
138
+ setTimeout(() => {
139
+ console.log('pm2 exec..')
140
+ let pm2 = execFun(4.56, 'def') //3500ms後, pm2執行原本函數與使用輸入, 計算完畢則會覆蓋快取, 此快取將再給等待或之後取得快取使用
141
+ pm2
142
+ .then((res) => {
143
+ console.log('pm2 then', res)
144
+ ms.push({ result: `pm2-${res}` })
145
+ })
146
+ }, 3500)
147
+
148
+ setTimeout(() => {
149
+ console.log('pm3 exec..')
150
+ let pm3 = execFunCache(78.9, 'xyz') //pm3執行取得快取, 因已有快取將直接取得快取
151
+ pm3
152
+ .then((res) => {
153
+ console.log('pm3 then', res)
154
+ ms.push({ result: `pm3-${res}` })
155
+ })
156
+ }, 4500)
31
157
 
32
- // fsDeleteFolder(fdt) //最終階段清除任務資料夾
158
+ await delay(6500)
33
159
 
34
160
  console.log('ms', ms)
35
161
  return ms
36
162
  }
37
- await test()
38
- .catch((err) => {
39
- console.log(err)
40
- })
163
+ await test3()
41
164
  // ms [
42
- // { fp: './_test_fsDownloadFile/100.svg' },
43
- // {
44
- // content: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 231 231"><path d="M33.83,33.83a115.5,115.5,0,1,1,0,163.34,115.49,115.49,0,0,1,0-163.34Z" style="fill:#bcf700;"/><path d="m115.5 51.75a63.75 63.75 0 0 0-10.5 126.63v14.09a115.5 115.5 0 0 0-53.729 19.027 115.5 115.5 0 0 0 128.46 0 115.5 115.5 0 0 0-53.729-19.029v-14.084a63.75 63.75 0 0 0 53.25-62.881 63.75 63.75 0 0 0-63.65-63.75 63.75 63.75 0 0 0-0.09961 0z" style="fill:#b96438;"/><path d="m141.75 195a114.79 114.79 0 0 1 38 16.5 115.53 115.53 0 0 1-128.46 0 114.79 114.79 0 0 1 38-16.5l15.71 15.75h21z" style="fill:#304267;"/><path d="m115.45 211.34-10.55 10.54a2.51 2.51 0 0 1-3.5599 0 2 2 0 0 1-0.26999-0.30994l-18.48-25.4 5.8901-5.8899a2.52 2.52 0 0 1 3.5199-0.0791l23.49 21.14z" style="fill:#aab0b1;"/><path d="m115.45 211.34
45
- // 10.55 10.54a2.51 2.51 0 0 0 3.5599 0 2 2 0 0 0 0.26999-0.30994l18.48-25.4-5.8901-5.8899a2.52 2.52 0 0 0-3.4699-0.089l-23.49 21.14z" style="fill:#aab0b1;"/><path d="m158.41 199.58-10.11-3.2401v29.93q5.1601-1.5299 10.11-3.51zm-75.82 26.66v-29.9l-10.1 3.2401v23.14c3.2901 1.3199 6.67 2.4999 10.1 3.5199z" style="fill:#aab0b1;"/><path d="m157.79 67.5a61.31 61.31 0 0 1-42.79 17.43h-55.7c18.16-37.74 68.27-46.85 98.49-17.43z" style="fill:#531148;"/><path d="m122.93 7.0078c-10.503-0.15729-21.09 1.6448-29.545 5.4316-17.141 7.8999-32.169 23.297-43.973 38.779-5.1703 6.8631-8.7779 13.46-8.1855 18.395 0.93114 12.312 10.372 26.483 11.068 36.9 15.663-72.081 105.99-70.452 124.91-7.0525l4e-3 0.0156c5.616-10.926 8.0682-20.188 8.352-27.653 0.43654-15.607-7.8088-21.149-21.735-28.249 1.7934-3.7704 1.7273-7.5023
46
- // 2.0625-10.154-0.79964-7.8568-3.6796-13.51-10.43-17.758-5.9434-3.7404-13.06-6.0867-18.463-7.2266-4.5319-0.87895-9.2901-1.3562-14.064-1.4277z" style="fill:#531148;"/><path d="m42.426 75.338c0.52158 18.689 10.557 74.338-18.115 101.25 12.38 10.603 28.352 19.061 46.025 24.594 11.032-4.6874 22.88-7.4147 34.817-8.5046l0.0633-14.477c-22.49-4.3813-40.766-18.898-48.862-39.967-8.096-21.07-4.7931-44.72 9.2478-62.393zm124.67 2.7207c7.8997 10.886 11.743 24.64 11.787 37.441-0.36632 30.178-22.389 57.576-53.12 62.708l0.0238 14.471c12.282 1.1216 24.518 3.9888 35.825 8.9128 15.488-5.1448 30.007-13.325 42.396-25.043-13.136-22.051-23.282-63.045-18.694-101.55z" style="fill:#531148;"/><path d="m143.61 46.383c-11.639 0.12482-20.998 1.8906-20.998 1.8906l-9 3.5059c0.63003-0.0191 1.2603-0.0289 1.8906-0.0293h0.0996c35.169 0.055 60.959 27.235 63.283 63.383 7.4e-4 31.157-22.742 57.213-53.106 63.079l-0.0216 14.498c11.567 1.0563 23.154 3.6067 33.887 8.0463 35.952-15.315 55.082-52.303 36.709-68.279-5.018-7.9035-10.44-15.409-9.5544-23.03 5.0545-50.452 0.39626-63.561-43.189-63.064zm-69.966 21.09c-15.286 3.244-17.096 3.73-31.734 6.6953 3.0304 13.081 3.0583 22.274 1.2085 30.012-3.8004 11.361-8.9712 19.787-12.286 28.764-6.8823 22.459-2.9157 31.982 12.093 46.165 8.6595 8.0693 19.861 16.209 30.939 20.647 2.669-1.0316 5.3729-1.9628 8.106-2.792 7.4979-2.275 15.388-3.6535 23.206-4.3673l0.0433-14.393c-23.933-4.5937-44.283-21.98-50.77-45.817-6.3319-23.265 0.51104-48.752 19.195-64.914z" style="fill:none;"/><path d="m172.7 90.75h-6.54c-0.14-0.1-0.26-0.22-0.4-0.3-4.48-2.76-22.75-2.11-33.71 1.2-1 0.3-1.91 0.61-2.75 0.94-1.8937 0.79244-3.8739 1.3597-5.9 1.69-5.5051 0.79002-10.403 0.79002-15.908 0-2.0261-0.33034-4.0063-0.89756-5.9-1.69-0.84-0.33-1.76-0.64-2.75-0.94-11-3.31-29.23-4-33.71-1.2-0.13832 0.08869-0.2688 0.18906-0.39 0.3h-6.55c-1.1046 0-2 0.89543-2 2v4.66c-0.0013 0.98185 0.49088 1.8986 1.31 2.44l1.9 1.27c0.59238 0.38889 0.93475
47
- // 1.0622 0.9 1.77-0.14175 5.4854 0.88072 10.939 3 16 3.58 8.38 16 10.9 24.93 10.9 2.6976 0.0771 5.3921-0.2361 8-0.93 4.35-1.43 8.24-7.36 10.45-12.42 1.7607-3.8506 2.7493-8.009 2.91-12.24 7.3e-4 -0.7138 0.38183-1.3731 1-1.73 3.2281-1.951 6.5798-1.951 9.8079 0 0.61817 0.3569 0.99927 1.0162 1 1.73 0.16067 4.231 1.1493 8.3894 2.91 12.24 2.21 5.06 6.1 11 10.45 12.42 2.6079 0.6939 5.3024 1.0071 8 0.93 8.92 0 21.35-2.52 24.93-10.9 2.1193-5.0614 3.1418-10.515 3-16-0.0348-0.70778 0.30762-1.3811 0.9-1.77l1.9-1.27c0.81913-0.54136 1.3113-1.4582 1.31-2.44v-4.6c0.0336-1.1048-0.83521-2.0274-1.94-2.06z" style="fill:#000;stroke-linecap:round;stroke-linejoin:round;stroke-width:2.5;stroke:none;"/><polygon points="121.61 160.74 109.39 160.74 115.5 171.31" style="fill:#666;"/><path d="m132.64 144.06a34.42 34.42
48
- // 0 0 1-34.24 0" style="fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:5.9998px;stroke:#000;"/></svg>'
49
- // }
165
+ // { result: 'pm1-123:abc' },
166
+ // { result: 'pm2-4.56:def' },
167
+ // { result: 'pm3-4.56:def' }
50
168
  // ]
51
169
 
52
170
  //node g.mjs
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wsemi",
3
- "version": "1.8.11",
3
+ "version": "1.8.13",
4
4
  "main": "dist/wsemi.umd.js",
5
5
  "dependencies": {
6
6
  "chokidar": "^4.0.3",
package/src/cache.mjs CHANGED
@@ -10,7 +10,7 @@ import cint from './cint.mjs'
10
10
 
11
11
 
12
12
  /**
13
- * 非同步函數快取
13
+ * 非同步函數快取,通過指定key代表函數與其輸入進行執行並快取,快取可設定失效時間,超過失效時間則重新執行與再更新快取
14
14
  *
15
15
  * Unit Test: {@link https://github.com/yuda-lyu/wsemi/blob/master/test/cache.test.mjs Github}
16
16
  * @memberOf wsemi
@@ -0,0 +1,237 @@
1
+ import get from 'lodash-es/get.js'
2
+ import ispint from './ispint.mjs'
3
+ import cint from './cint.mjs'
4
+ import delay from './delay.mjs'
5
+
6
+
7
+ /**
8
+ * 封裝非同步函數與再提供使用快取版
9
+ *
10
+ * Unit Test: {@link https://github.com/yuda-lyu/wsemi/blob/master/test/cacheBd.test.mjs Github}
11
+ * @memberOf wsemi
12
+ * @param {Function} fun 輸入非同步函數
13
+ * @param {Object} [opt={}] 輸入設定物件,預設{}
14
+ * @param {Integer} [nMax=200] 輸入使用快取版之總嘗試次數整數,超過則報錯,預設200
15
+ * @param {Integer} [nTrigger=3] 輸入嘗試指定次數整數,若嘗試指定次數之後皆無快取則須自動執行get用以取得快取,預設3
16
+ * @returns {Object} 回傳事件物件,可呼叫事件get、getByCache,get為封裝後封裝原本非同步函數,getByCache為提供取用快取版之非同步函數,若有快取則優先使用,若超過指定次數則自動執行get使能取得快取
17
+ * @example
18
+ *
19
+ * let test1 = async () => {
20
+ * let ms = []
21
+ *
22
+ * let fun = async(p1, p2) => {
23
+ * await delay(300)
24
+ * return `${p1}:${p2}`
25
+ * }
26
+ *
27
+ * let bc = cacheBd(fun)
28
+ * let execFun = bc.get
29
+ * let execFunCache = bc.getByCache
30
+ *
31
+ * let pm1 = execFunCache(123, 'abc') //pm1執行取得快取, 因無快取將持續等待
32
+ * pm1
33
+ * .then((res) => {
34
+ * // console.log('res', res)
35
+ * ms.push({ result: `pm1-${res}` })
36
+ * })
37
+ *
38
+ * let pm2 = execFun(4.56, 'def') //pm2執行原本函數與使用輸入, 會最先回傳, 且更新快取給等待或之後取得快取使用
39
+ * pm2
40
+ * .then((res) => {
41
+ * // console.log('res', res)
42
+ * ms.push({ result: `pm2-${res}` })
43
+ * })
44
+ *
45
+ * let pm3 = execFunCache(78.9, 'xyz') //pm3執行取得快取, 因已有快取將直接取得快取
46
+ * pm3
47
+ * .then((res) => {
48
+ * // console.log('res', res)
49
+ * ms.push({ result: `pm3-${res}` })
50
+ * })
51
+ *
52
+ * await Promise.all([pm1, pm2, pm3])
53
+ * // console.log('rs', rs)
54
+ *
55
+ * console.log('ms', ms)
56
+ * return ms
57
+ * }
58
+ * await test1()
59
+ * // ms [
60
+ * // { result: 'pm2-4.56:def' },
61
+ * // { result: 'pm1-4.56:def' },
62
+ * // { result: 'pm3-4.56:def' }
63
+ * // ]
64
+ *
65
+ * let test2 = async () => {
66
+ * let ms = []
67
+ *
68
+ * let fun = async(p1, p2) => {
69
+ * await delay(300)
70
+ * return `${p1}:${p2}`
71
+ * }
72
+ *
73
+ * let bc = cacheBd(fun)
74
+ * let execFun = bc.get
75
+ * let execFunCache = bc.getByCache
76
+ *
77
+ * setTimeout(() => {
78
+ * console.log('pm1 exec..')
79
+ * let pm1 = execFunCache(123, 'abc') //pm1執行取得快取, 因無快取將持續等待
80
+ * pm1
81
+ * .then((res) => {
82
+ * console.log('pm1 then', res)
83
+ * ms.push({ result: `pm1-${res}` })
84
+ * })
85
+ * }, 1)
86
+ *
87
+ * setTimeout(() => {
88
+ * console.log('pm2 exec..')
89
+ * let pm2 = execFun(4.56, 'def') //1000ms後, pm2執行原本函數與使用輸入, 會最先回傳, 且更新快取給等待或之後取得快取使用
90
+ * pm2
91
+ * .then((res) => {
92
+ * console.log('pm2 then', res)
93
+ * ms.push({ result: `pm2-${res}` })
94
+ * })
95
+ * }, 1000)
96
+ *
97
+ * setTimeout(() => {
98
+ * console.log('pm3 exec..')
99
+ * let pm3 = execFunCache(78.9, 'xyz') //pm3執行取得快取, 因已有快取將直接取得快取
100
+ * pm3
101
+ * .then((res) => {
102
+ * console.log('pm3 then', res)
103
+ * ms.push({ result: `pm3-${res}` })
104
+ * })
105
+ * }, 3000)
106
+ *
107
+ * await delay(5000)
108
+ *
109
+ * console.log('ms', ms)
110
+ * return ms
111
+ * }
112
+ * await test2()
113
+ * // ms [
114
+ * // { result: 'pm2-4.56:def' },
115
+ * // { result: 'pm1-4.56:def' },
116
+ * // { result: 'pm3-4.56:def' }
117
+ * // ]
118
+ *
119
+ * let test3 = async () => {
120
+ * let ms = []
121
+ *
122
+ * let fun = async(p1, p2) => {
123
+ * await delay(300)
124
+ * return `${p1}:${p2}`
125
+ * }
126
+ *
127
+ * let bc = cacheBd(fun)
128
+ * let execFun = bc.get
129
+ * let execFunCache = bc.getByCache
130
+ *
131
+ * setTimeout(() => {
132
+ * console.log('pm1 exec..')
133
+ * let pm1 = execFunCache(123, 'abc') //pm1執行取得快取, 因無快取將持續等待, 3000ms將執行get與自己的輸入, 並最先回傳
134
+ * pm1
135
+ * .then((res) => {
136
+ * console.log('pm1 then', res)
137
+ * ms.push({ result: `pm1-${res}` })
138
+ * })
139
+ * }, 1)
140
+ *
141
+ * setTimeout(() => {
142
+ * console.log('pm2 exec..')
143
+ * let pm2 = execFun(4.56, 'def') //3500ms後, pm2執行原本函數與使用輸入, 計算完畢則會覆蓋快取, 此快取將再給等待或之後取得快取使用
144
+ * pm2
145
+ * .then((res) => {
146
+ * console.log('pm2 then', res)
147
+ * ms.push({ result: `pm2-${res}` })
148
+ * })
149
+ * }, 3500)
150
+ *
151
+ * setTimeout(() => {
152
+ * console.log('pm3 exec..')
153
+ * let pm3 = execFunCache(78.9, 'xyz') //pm3執行取得快取, 因已有快取將直接取得快取
154
+ * pm3
155
+ * .then((res) => {
156
+ * console.log('pm3 then', res)
157
+ * ms.push({ result: `pm3-${res}` })
158
+ * })
159
+ * }, 4500)
160
+ *
161
+ * await delay(6500)
162
+ *
163
+ * console.log('ms', ms)
164
+ * return ms
165
+ * }
166
+ * await test3()
167
+ * // ms [
168
+ * // { result: 'pm1-123:abc' },
169
+ * // { result: 'pm2-4.56:def' },
170
+ * // { result: 'pm3-4.56:def' }
171
+ * // ]
172
+ *
173
+ */
174
+ function cacheBd(fun, opt = {}) {
175
+
176
+ //nMax
177
+ let nMax = get(opt, 'nMax')
178
+ if (!ispint(nMax)) {
179
+ nMax = 200
180
+ }
181
+ nMax = cint(nMax)
182
+
183
+ //nTrigger
184
+ let nTrigger = get(opt, 'nTrigger')
185
+ if (!ispint(nTrigger)) {
186
+ nTrigger = 3
187
+ }
188
+ nTrigger = cint(nTrigger)
189
+
190
+ //快取
191
+ let cc = null
192
+
193
+ //函數執行狀態
194
+ let lock = false
195
+
196
+ //_get, 封裝原本非同步函數
197
+ let _get = async(...inputs) => {
198
+ lock = true
199
+ cc = await fun(...inputs) //若發生錯誤則向外報錯
200
+ lock = false
201
+ return cc
202
+ }
203
+
204
+ //_getByCache, 提供取用快取版之非同步函數, 若有快取則優先使用, 若超過指定次數則執行get使能取得快取
205
+ let _getByCache = async(...inputs) => {
206
+ for (let i = 1; i <= nMax; i++) {
207
+
208
+ //exec
209
+ if (i > nTrigger && !lock) {
210
+ // console.log('執行get使能取得快取...')
211
+ await _get(...inputs)
212
+ .catch(() => {}) //取得快取時不向外報錯
213
+ }
214
+
215
+ //check
216
+ if (cc !== null) {
217
+ break
218
+ }
219
+
220
+ //delay
221
+ await delay(1000) //偵測週期1000ms
222
+
223
+ }
224
+ if (cc === null) {
225
+ throw new Error(`exceeded nMax[${nMax}]`)
226
+ }
227
+ return cc
228
+ }
229
+
230
+ return {
231
+ get: _get,
232
+ getByCache: _getByCache,
233
+ }
234
+ }
235
+
236
+
237
+ export default cacheBd
@@ -0,0 +1,109 @@
1
+ import fs from 'fs'
2
+ import readline from 'readline'
3
+ import fsIsFile from './fsIsFile.mjs'
4
+ import evem from './evem.mjs'
5
+
6
+
7
+ /**
8
+ * 使用stream從檔案讀utf8文字
9
+ *
10
+ * Unit Test: {@link https://github.com/yuda-lyu/wsemi/blob/master/test/fsBuildReadStreamText.test.mjs Github}
11
+ * @memberOf wsemi
12
+ * @param {String} fp 輸入讀取檔案路徑字串
13
+ * @returns {EventEmitter} 回傳EventEmitter,可監聽create、line、close事件,line事件接收讀入各列字串
14
+ * @example
15
+ * need test in nodejs.
16
+ *
17
+ * let test = async () => {
18
+ *
19
+ * let ms = []
20
+ *
21
+ * let fdt = './_test_fsBuildReadStreamText'
22
+ * fsCreateFolder(fdt) //創建臨時任務資料夾
23
+ *
24
+ * let fn = 't1.txt'
25
+ * let fp = `${fdt}/${fn}`
26
+ *
27
+ * fs.writeFileSync(fp, `abc
28
+ * 測試中文
29
+ * def123xyz
30
+ * `, 'utf8')
31
+ *
32
+ * let ev = fsBuildReadStreamText(fp)
33
+ * ms.push({ 'create': '' })
34
+ *
35
+ * ev.on('line', (line) => {
36
+ * console.log('line', line)
37
+ * ms.push({ line })
38
+ * })
39
+ *
40
+ * let pm = genPm()
41
+ * ev.on('close', () => {
42
+ * console.log('close')
43
+ * pm.resolve()
44
+ * ms.push({ 'close': '' })
45
+ * })
46
+ * await pm
47
+ *
48
+ * fsDeleteFolder(fdt) //刪除臨時任務資料夾
49
+ *
50
+ * console.log('ms', ms)
51
+ * return ms
52
+ * }
53
+ * await test()
54
+ * // ms [
55
+ * // { create: '' },
56
+ * // { line: 'abc' },
57
+ * // { line: '測試中文' },
58
+ * // { line: 'def123xyz' },
59
+ * // { close: '' }
60
+ * // ]
61
+ *
62
+ */
63
+ function fsBuildReadStreamText(fp) {
64
+
65
+ //check
66
+ if (!fsIsFile(fp)) {
67
+ throw new Error(`fp is not a file`)
68
+ }
69
+
70
+ //ev
71
+ let ev = evem()
72
+
73
+ //stream
74
+ let stream = fs.createReadStream(fp, { encoding: 'utf8' })
75
+ ev.emit('create')
76
+
77
+ //rl
78
+ let rl = readline.createInterface({
79
+ input: stream,
80
+ crlfDelay: Infinity, //支援\r\n或\n
81
+ })
82
+
83
+ //rl line
84
+ rl.on('line', (line) => {
85
+ // console.log(`line`,line)
86
+ ev.emit('line', line)
87
+ })
88
+
89
+ // //rl close
90
+ // rl.on('close', () => {
91
+ // // console.log('close')
92
+ // })
93
+
94
+ //stream close
95
+ stream.on('close', () => {
96
+ //stream close事件才代表檔案可刪除
97
+ ev.emit('close')
98
+ })
99
+
100
+ // //stream end
101
+ // stream.on('end', () => {
102
+ // //stream end事件只是讀寫結束, 不代表檔案可刪除
103
+ // })
104
+
105
+ return ev
106
+ }
107
+
108
+
109
+ export default fsBuildReadStreamText
@@ -3,12 +3,11 @@ import genPm from './genPm.mjs'
3
3
 
4
4
 
5
5
  /**
6
- * 使用stream寫入utf-8文字至檔案
6
+ * 使用stream寫入utf8文字至檔案
7
7
  *
8
8
  * Unit Test: {@link https://github.com/yuda-lyu/wsemi/blob/master/test/fsBuildWriteStreamText.test.mjs Github}
9
9
  * @memberOf wsemi
10
- * @param {String} fp 輸入檔案名稱
11
- * @param {String} c 輸入utf-8文字數據
10
+ * @returns {Object} 回傳函數物件,提供creat、write、end函數,create代表創建stream,可輸入fp為檔案路徑字串,write代表寫入字串,輸入c為字串(預設為行),end代表結束stream,無輸入
12
11
  * @example
13
12
  * need test in nodejs.
14
13
  *
@@ -86,7 +85,13 @@ function fsBuildWriteStreamText() {
86
85
 
87
86
  //end
88
87
  let end = () => {
88
+ let pmm = genPm()
89
+ stream.on('close', () => {
90
+ //close事件才代表檔案可刪除
91
+ pmm.resolve()
92
+ })
89
93
  stream.end() //發出flush與close
94
+ return pmm
90
95
  }
91
96
 
92
97
  //r
package/src/index.mjs CHANGED
@@ -55,6 +55,7 @@ export { default as bufReadDbl } from './bufReadDbl.mjs'
55
55
  export { default as bufWrite } from './bufWrite.mjs'
56
56
  export { default as bufWriteDbl } from './bufWriteDbl.mjs'
57
57
  export { default as cache } from './cache.mjs'
58
+ export { default as cacheBd } from './cacheBd.mjs'
58
59
  export { default as cbol } from './cbol.mjs'
59
60
  export { default as cdbl } from './cdbl.mjs'
60
61
  export { default as ceil } from './ceil.mjs'
@@ -142,6 +143,7 @@ export { default as files2data } from './files2data.mjs'
142
143
  export { default as flattenToConn } from './flattenToConn.mjs'
143
144
  export { default as flattenTree } from './flattenTree.mjs'
144
145
  export { default as floor } from './floor.mjs'
146
+ export { default as fsBuildReadStreamText } from './fsBuildReadStreamText.mjs'
145
147
  export { default as fsBuildWriteStreamText } from './fsBuildWriteStreamText.mjs'
146
148
  export { default as fsCleanFolder } from './fsCleanFolder.mjs'
147
149
  export { default as fsCleanFolderCore } from './fsCleanFolderCore.mjs'
@@ -114,47 +114,6 @@ import cint from './cint.mjs'
114
114
  */
115
115
  function pmDebounce(ms = 300) {
116
116
 
117
- // function ClsDebounceEasy(ms) { //簡易法, 因執行階段中無法儲存推入任務會被視為強制取消, 不合需求
118
-
119
- // //timer
120
- // let t = null
121
-
122
- // //pm
123
- // let pm = Promise.resolve()
124
-
125
- // //run
126
- // let run = (func, ...input) => {
127
-
128
- // //clearTimeout
129
- // clearTimeout(t)
130
-
131
- // // console.log('call fun')
132
- // return new Promise((resolve, reject) => {
133
- // // console.log('call in Promise', ...input, ms)
134
-
135
- // //setTimeout
136
- // t = setTimeout(async () => {
137
- // // console.log('exec fun start', ...input, ms)
138
-
139
- // try {
140
- // let res = func(...input)
141
- // if (ispm(res)) {
142
- // res = await pm
143
- // }
144
- // resolve(res)
145
- // }
146
- // catch (err) {
147
- // reject(err)
148
- // }
149
- // // console.log('exec fun end')
150
-
151
- // }, ms)
152
- // })
153
- // }
154
-
155
- // return run
156
- // }
157
-
158
117
  function ClsDebounce(ms) {
159
118
  let q = [] //queue
160
119
  let t = null //timer
@@ -167,12 +126,6 @@ function pmDebounce(ms = 300) {
167
126
  }
168
127
  ms = cint(ms)
169
128
 
170
- // //_tNow
171
- // let _tNow = Date.now()
172
- // let getIt = () => {
173
- // return Date.now() - _tNow
174
- // }
175
-
176
129
  function detect() {
177
130
 
178
131
  //check