wsemi 1.9.21 → 1.9.23

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 (524) hide show
  1. package/README.md +1 -1
  2. package/dist/wsemi.umd.js +6 -6
  3. package/dist/wsemi.umd.js.map +1 -1
  4. package/docs/-_class.mjs.html +1 -1
  5. package/docs/-_const.mjs.html +1 -1
  6. package/docs/-_detector.mjs.html +1 -1
  7. package/docs/-_errToStr.mjs.html +1 -1
  8. package/docs/-_execThrownMsg.mjs.html +1 -1
  9. package/docs/-_isRealError.mjs.html +1 -1
  10. package/docs/-_optNum.mjs.html +1 -1
  11. package/docs/-_pmMarkHandled.mjs.html +1 -1
  12. package/docs/-_pmReadItems.mjs.html +1 -1
  13. package/docs/-_pmSettleByState.mjs.html +1 -1
  14. package/docs/-_realErrorToStr.mjs.html +1 -1
  15. package/docs/-_toResultError.mjs.html +1 -1
  16. package/docs/ab2blob.mjs.html +1 -1
  17. package/docs/ab2u8arr.mjs.html +1 -1
  18. package/docs/addExcelWorksheetFromData.mjs.html +1 -1
  19. package/docs/addMonth.mjs.html +1 -1
  20. package/docs/aes2str.mjs.html +1 -1
  21. package/docs/alive.mjs.html +1 -1
  22. package/docs/arr2dt.mjs.html +1 -1
  23. package/docs/arrAccum.mjs.html +1 -1
  24. package/docs/arrAdd.mjs.html +1 -1
  25. package/docs/arrAt.mjs.html +1 -1
  26. package/docs/arrDiff.mjs.html +1 -1
  27. package/docs/arrFilterByKeywords.mjs.html +1 -1
  28. package/docs/arrFilterByNum.mjs.html +1 -1
  29. package/docs/arrFilterByPnum.mjs.html +1 -1
  30. package/docs/arrFilterByPnumAndToLog.mjs.html +1 -1
  31. package/docs/arrFind.mjs.html +1 -1
  32. package/docs/arrGroupByMaxmin.mjs.html +1 -1
  33. package/docs/arrHas.mjs.html +1 -1
  34. package/docs/arrInsert.mjs.html +1 -1
  35. package/docs/arrLookupByMaxmin.mjs.html +1 -1
  36. package/docs/arrMax.mjs.html +1 -1
  37. package/docs/arrMin.mjs.html +1 -1
  38. package/docs/arrMulti.mjs.html +1 -1
  39. package/docs/arrNorm.mjs.html +1 -1
  40. package/docs/arrProduct.mjs.html +1 -1
  41. package/docs/arrPull.mjs.html +1 -1
  42. package/docs/arrPullAt.mjs.html +1 -1
  43. package/docs/arrReduce.mjs.html +1 -1
  44. package/docs/arrReverse.mjs.html +1 -1
  45. package/docs/arrSep.mjs.html +1 -1
  46. package/docs/arrSort.mjs.html +1 -1
  47. package/docs/asind.mjs.html +1 -1
  48. package/docs/atan2d.mjs.html +1 -1
  49. package/docs/atand.mjs.html +1 -1
  50. package/docs/attstr.mjs.html +1 -1
  51. package/docs/b642obj.mjs.html +1 -1
  52. package/docs/b642str.mjs.html +1 -1
  53. package/docs/b642u16arr.mjs.html +1 -1
  54. package/docs/b642u8arr.mjs.html +1 -1
  55. package/docs/binstr.mjs.html +1 -1
  56. package/docs/blob2ab.mjs.html +1 -1
  57. package/docs/blob2b64.mjs.html +1 -1
  58. package/docs/blob2str.mjs.html +1 -1
  59. package/docs/blob2u8arr.mjs.html +1 -1
  60. package/docs/blobs2b64s.mjs.html +1 -1
  61. package/docs/blobs2u8arrs.mjs.html +1 -1
  62. package/docs/bodyLog.mjs.html +1 -1
  63. package/docs/browserView.mjs.html +1 -1
  64. package/docs/browserViewFromBlob.mjs.html +1 -1
  65. package/docs/browserViewFromText.mjs.html +1 -1
  66. package/docs/browserViewFromU8arr.mjs.html +1 -1
  67. package/docs/bs2u8arr.mjs.html +1 -1
  68. package/docs/bufRead.mjs.html +1 -1
  69. package/docs/bufReadDbl.mjs.html +1 -1
  70. package/docs/bufWrite.mjs.html +1 -1
  71. package/docs/bufWriteDbl.mjs.html +1 -1
  72. package/docs/cache.mjs.html +1 -1
  73. package/docs/cacheBd.mjs.html +1 -1
  74. package/docs/cacheSt.mjs.html +1 -1
  75. package/docs/cbol.mjs.html +1 -1
  76. package/docs/cdbl.mjs.html +1 -1
  77. package/docs/ceil.mjs.html +1 -1
  78. package/docs/cfilesize.mjs.html +1 -1
  79. package/docs/cfinancial.mjs.html +1 -1
  80. package/docs/cint.mjs.html +1 -1
  81. package/docs/clearXSS.mjs.html +263 -25
  82. package/docs/clearXSSDyn.mjs.html +1 -1
  83. package/docs/color.mjs.html +1 -1
  84. package/docs/composeToTree.mjs.html +1 -1
  85. package/docs/convertToTree.mjs.html +1 -1
  86. package/docs/copyStrToClipboard.mjs.html +1 -1
  87. package/docs/cosd.mjs.html +1 -1
  88. package/docs/cotd.mjs.html +1 -1
  89. package/docs/createExcelWorkbook.mjs.html +1 -1
  90. package/docs/cscd.mjs.html +1 -1
  91. package/docs/cstr.mjs.html +1 -1
  92. package/docs/cvOrmFind.mjs.html +1 -1
  93. package/docs/day2cht.mjs.html +1 -1
  94. package/docs/debounce.mjs.html +1 -1
  95. package/docs/delay.mjs.html +1 -1
  96. package/docs/detectXSS.mjs.html +1 -1
  97. package/docs/detectXSSDyn.mjs.html +1 -1
  98. package/docs/dig.mjs.html +1 -1
  99. package/docs/digExp.mjs.html +1 -1
  100. package/docs/domAlert.mjs.html +1 -1
  101. package/docs/domAppend.mjs.html +1 -1
  102. package/docs/domCancelEvent.mjs.html +1 -1
  103. package/docs/domCompareText.mjs.html +1 -1
  104. package/docs/domConvertToPic.mjs.html +1 -1
  105. package/docs/domConvertToPicDyn.mjs.html +1 -1
  106. package/docs/domDetect.mjs.html +1 -1
  107. package/docs/domDrag.mjs.html +1 -1
  108. package/docs/domDragBarAndScroll.mjs.html +1 -1
  109. package/docs/domDragPointer.mjs.html +1 -1
  110. package/docs/domDragPreview.mjs.html +1 -1
  111. package/docs/domDropFiles.mjs.html +1 -1
  112. package/docs/domElementsFromPoint.mjs.html +1 -1
  113. package/docs/domFadeIn.mjs.html +1 -1
  114. package/docs/domFadeOut.mjs.html +1 -1
  115. package/docs/domFind.mjs.html +1 -1
  116. package/docs/domFinds.mjs.html +1 -1
  117. package/docs/domGetAttr.mjs.html +1 -1
  118. package/docs/domGetBoudRect.mjs.html +1 -1
  119. package/docs/domGetBoudRectRefSelf.mjs.html +1 -1
  120. package/docs/domGetFileAccept.mjs.html +1 -1
  121. package/docs/domGetFiles.mjs.html +1 -1
  122. package/docs/domGetParents.mjs.html +1 -1
  123. package/docs/domGetPointFromEvent.mjs.html +1 -1
  124. package/docs/domGetScrollableParent.mjs.html +1 -1
  125. package/docs/domGetWindowSize.mjs.html +1 -1
  126. package/docs/domIsClientXYIn.mjs.html +1 -1
  127. package/docs/domIsFocused.mjs.html +1 -1
  128. package/docs/domIsRendered.mjs.html +1 -1
  129. package/docs/domIsStable.mjs.html +1 -1
  130. package/docs/domIsVisible.mjs.html +1 -1
  131. package/docs/domPrepend.mjs.html +1 -1
  132. package/docs/domRemove.mjs.html +1 -1
  133. package/docs/domRenderMarkdownMind.mjs.html +1 -1
  134. package/docs/domRenderMarkdownMindDyn.mjs.html +1 -1
  135. package/docs/domRipple.mjs.html +1 -1
  136. package/docs/domScrollIntoView.mjs.html +1 -1
  137. package/docs/domScrollTo.mjs.html +1 -1
  138. package/docs/domSetAttr.mjs.html +1 -1
  139. package/docs/domShowImages.mjs.html +1 -1
  140. package/docs/domShowImagesDyn.mjs.html +1 -1
  141. package/docs/domShowInputAndGetFiles.mjs.html +1 -1
  142. package/docs/domShowInputAndGetFilesU8Arrs.mjs.html +1 -1
  143. package/docs/domShowInputDatatime.mjs.html +1 -1
  144. package/docs/domTooltip.mjs.html +1 -1
  145. package/docs/domTriggerEvent.mjs.html +1 -1
  146. package/docs/domVirtualCreate.mjs.html +1 -1
  147. package/docs/domVirtualCreateQueue.mjs.html +1 -1
  148. package/docs/downloadExcelFileFromData.mjs.html +1 -1
  149. package/docs/downloadExcelFileFromDataDyn.mjs.html +1 -1
  150. package/docs/downloadFileFromB64.mjs.html +1 -1
  151. package/docs/downloadFileFromBlob.mjs.html +1 -1
  152. package/docs/downloadFileFromText.mjs.html +1 -1
  153. package/docs/downloadFileFromU8Arr.mjs.html +1 -1
  154. package/docs/dtmapping.mjs.html +1 -1
  155. package/docs/dtpick.mjs.html +1 -1
  156. package/docs/estimateTicks.mjs.html +1 -1
  157. package/docs/evEmit.mjs.html +1 -1
  158. package/docs/evEmitDelay.mjs.html +1 -1
  159. package/docs/evem.mjs.html +1 -1
  160. package/docs/examples/ex-blob2b64.html +1 -1
  161. package/docs/examples/ex-clearXSS.html +1 -1
  162. package/docs/examples/ex-clearXSSDyn.html +1 -1
  163. package/docs/examples/ex-colorConverter.html +1 -1
  164. package/docs/examples/ex-detectXSS.html +1 -1
  165. package/docs/examples/ex-detectXSSDyn.html +1 -1
  166. package/docs/examples/ex-domCompareText.html +1 -1
  167. package/docs/examples/ex-domConvertToPic.html +1 -1
  168. package/docs/examples/ex-domDrag.html +1 -1
  169. package/docs/examples/ex-domDropFiles.html +1 -1
  170. package/docs/examples/ex-domIsVisible.html +1 -1
  171. package/docs/examples/ex-domRenderMarkdownMind.html +1 -1
  172. package/docs/examples/ex-domRenderMarkdownMindDyn.html +1 -1
  173. package/docs/examples/ex-domRipple.html +1 -1
  174. package/docs/examples/ex-domScrollIntoView.html +1 -1
  175. package/docs/examples/ex-domScrollTo.html +1 -1
  176. package/docs/examples/ex-domShowImages.html +1 -1
  177. package/docs/examples/ex-domShowImagesDyn.html +1 -1
  178. package/docs/examples/ex-domShowInputAndGetFiles.html +1 -1
  179. package/docs/examples/ex-domTooltip.html +1 -1
  180. package/docs/examples/ex-getFileHash.html +1 -1
  181. package/docs/examples/ex-getUserAgent.html +1 -1
  182. package/docs/examples/ex-getUserAgentDyn.html +1 -1
  183. package/docs/examples/ex-html2str.html +1 -1
  184. package/docs/examples/ex-obj2u8arr-u8arr2obj.html +1 -1
  185. package/docs/examples/ex-openLink.html +1 -1
  186. package/docs/examples/ex-str2aes-aes2str.html +1 -1
  187. package/docs/examples/ex-str2b64-b642str.html +1 -1
  188. package/docs/examples/ex-strFindFuzz.html +1 -1
  189. package/docs/examples/ex-timeTZ2expire-timeTZ2past.html +1 -1
  190. package/docs/examples/ex-xlsx.html +1 -1
  191. package/docs/execCli.mjs.html +1 -1
  192. package/docs/execCliCore.mjs.html +1 -1
  193. package/docs/execCliJsonRpc.mjs.html +1 -1
  194. package/docs/execCliSession.mjs.html +1 -1
  195. package/docs/execJsCode.mjs.html +1 -1
  196. package/docs/execProcess.mjs.html +1 -1
  197. package/docs/execProcessKillPid.mjs.html +1 -1
  198. package/docs/filepathToTree.mjs.html +1 -1
  199. package/docs/files2data.mjs.html +1 -1
  200. package/docs/flattenToConn.mjs.html +12 -8
  201. package/docs/flattenTree.mjs.html +9 -9
  202. package/docs/floor.mjs.html +1 -1
  203. package/docs/fsBuildReadStreamText.mjs.html +1 -1
  204. package/docs/fsBuildWriteStreamText.mjs.html +1 -1
  205. package/docs/fsCleanFolder.mjs.html +1 -1
  206. package/docs/fsCleanFolderCore.mjs.html +1 -1
  207. package/docs/fsCopyFile.mjs.html +1 -1
  208. package/docs/fsCopyFileCore.mjs.html +1 -1
  209. package/docs/fsCopyFolder.mjs.html +1 -1
  210. package/docs/fsCopyFolderCore.mjs.html +1 -1
  211. package/docs/fsCreateFile.mjs.html +1 -1
  212. package/docs/fsCreateFileCore.mjs.html +1 -1
  213. package/docs/fsCreateFolder.mjs.html +1 -1
  214. package/docs/fsCreateFolderCore.mjs.html +1 -1
  215. package/docs/fsDeleteFile.mjs.html +1 -1
  216. package/docs/fsDeleteFileCore.mjs.html +1 -1
  217. package/docs/fsDeleteFileSafe.mjs.html +1 -1
  218. package/docs/fsDeleteFileSafeCore.mjs.html +1 -1
  219. package/docs/fsDeleteFolder.mjs.html +1 -1
  220. package/docs/fsDeleteFolderCore.mjs.html +1 -1
  221. package/docs/fsDeleteFolderSafe.mjs.html +1 -1
  222. package/docs/fsDeleteFolderSafeCore.mjs.html +1 -1
  223. package/docs/fsDownloadFile.mjs.html +1 -1
  224. package/docs/fsDownloadFileCore.mjs.html +1 -1
  225. package/docs/fsEvem.mjs.html +1 -1
  226. package/docs/fsExists.mjs.html +1 -1
  227. package/docs/fsExistsCore.mjs.html +1 -1
  228. package/docs/fsGetFileBasicHash.mjs.html +1 -1
  229. package/docs/fsGetFileBasicHashCore.mjs.html +1 -1
  230. package/docs/fsGetFileHash.mjs.html +1 -1
  231. package/docs/fsGetFileHashCore.mjs.html +1 -1
  232. package/docs/fsGetFileXxHash.mjs.html +1 -1
  233. package/docs/fsGetFileXxHashCore.mjs.html +1 -1
  234. package/docs/fsGetFilesInFolder.mjs.html +1 -1
  235. package/docs/fsGetFilesInFolderCore.mjs.html +1 -1
  236. package/docs/fsGetFilesWithHashInFolder.mjs.html +1 -1
  237. package/docs/fsGetFilesWithHashInFolderCore.mjs.html +1 -1
  238. package/docs/fsGetFolderBasicHash.mjs.html +1 -1
  239. package/docs/fsGetFolderBasicHashCore.mjs.html +1 -1
  240. package/docs/fsGetFoldersInFolder.mjs.html +1 -1
  241. package/docs/fsGetFoldersInFolderCore.mjs.html +1 -1
  242. package/docs/fsIsFile.mjs.html +1 -1
  243. package/docs/fsIsFileCore.mjs.html +1 -1
  244. package/docs/fsIsFolder.mjs.html +1 -1
  245. package/docs/fsIsFolderCore.mjs.html +1 -1
  246. package/docs/fsMergeFiles.mjs.html +1 -1
  247. package/docs/fsMergeFilesCore.mjs.html +1 -1
  248. package/docs/fsReadJson.mjs.html +1 -1
  249. package/docs/fsReadText.mjs.html +1 -1
  250. package/docs/fsReadTextCore.mjs.html +1 -1
  251. package/docs/fsRenameFile.mjs.html +1 -1
  252. package/docs/fsRenameFileCore.mjs.html +1 -1
  253. package/docs/fsRenameFolder.mjs.html +1 -1
  254. package/docs/fsRenameFolderCore.mjs.html +1 -1
  255. package/docs/fsSrlog.mjs.html +1 -1
  256. package/docs/fsSyncFolder.mjs.html +1 -1
  257. package/docs/fsSyncFolderCore.mjs.html +1 -1
  258. package/docs/fsTask.mjs.html +14 -13
  259. package/docs/fsTaskCp.mjs.html +1 -1
  260. package/docs/fsTreeFolder.mjs.html +1 -1
  261. package/docs/fsTreeFolderCore.mjs.html +1 -1
  262. package/docs/fsTreeFolderWithHash.mjs.html +1 -1
  263. package/docs/fsTreeFolderWithHashCore.mjs.html +1 -1
  264. package/docs/fsWatchFile.mjs.html +1 -1
  265. package/docs/fsWatchFolder.mjs.html +1 -1
  266. package/docs/fsWriteJson.mjs.html +1 -1
  267. package/docs/fsWriteText.mjs.html +1 -1
  268. package/docs/fsWriteTextCore.mjs.html +1 -1
  269. package/docs/genGradientColor.mjs.html +1 -1
  270. package/docs/genID.mjs.html +1 -1
  271. package/docs/genIDSeq.mjs.html +1 -1
  272. package/docs/genPm.mjs.html +1 -1
  273. package/docs/getBufferSize.mjs.html +1 -1
  274. package/docs/getClearPathName.mjs.html +1 -1
  275. package/docs/getCsvStrFromData.mjs.html +1 -1
  276. package/docs/getDataFromExcelFileU8Arr.mjs.html +1 -1
  277. package/docs/getDataFromExcelFileU8ArrDyn.mjs.html +1 -1
  278. package/docs/getEnv.mjs.html +1 -1
  279. package/docs/getErrorMessage.mjs.html +1 -1
  280. package/docs/getExcelU8ArrFromData.mjs.html +1 -1
  281. package/docs/getExcelU8ArrFromWorkbook.mjs.html +1 -1
  282. package/docs/getExcelWorkbookFromData.mjs.html +1 -1
  283. package/docs/getExcelWorkbookFromWorksheet.mjs.html +1 -1
  284. package/docs/getExcelWorksheetFromData.mjs.html +1 -1
  285. package/docs/getFileAccept.mjs.html +3 -4
  286. package/docs/getFileBasicHash.mjs.html +1 -1
  287. package/docs/getFileHash.mjs.html +1 -1
  288. package/docs/getFileName.mjs.html +1 -1
  289. package/docs/getFileNameExt.mjs.html +1 -1
  290. package/docs/getFileTrueName.mjs.html +1 -1
  291. package/docs/getFileType.mjs.html +150 -5
  292. package/docs/getFileXxHash.mjs.html +1 -1
  293. package/docs/getGlobal.mjs.html +1 -1
  294. package/docs/getObjSize.mjs.html +1 -1
  295. package/docs/getPathParent.mjs.html +1 -1
  296. package/docs/getTimeBetween.mjs.html +1 -1
  297. package/docs/getTimeFromUnit.mjs.html +1 -1
  298. package/docs/getTimeHp.mjs.html +1 -1
  299. package/docs/getTimeObject.mjs.html +1 -1
  300. package/docs/getTimeRange.mjs.html +1 -1
  301. package/docs/getUserAgent.mjs.html +1 -1
  302. package/docs/getUserAgentDyn.mjs.html +1 -1
  303. package/docs/getltdtkeys.mjs.html +7 -6
  304. package/docs/global.html +1 -1
  305. package/docs/haskey.mjs.html +1 -1
  306. package/docs/html2str.mjs.html +1 -1
  307. package/docs/htmlDecode.mjs.html +1 -1
  308. package/docs/htmlEncode.mjs.html +1 -1
  309. package/docs/importResources.mjs.html +1 -1
  310. package/docs/index.html +1 -1
  311. package/docs/interp1.mjs.html +1 -1
  312. package/docs/isDate.mjs.html +1 -1
  313. package/docs/isDev.mjs.html +1 -1
  314. package/docs/isEle.mjs.html +1 -1
  315. package/docs/isEleExistByID.mjs.html +1 -1
  316. package/docs/isEmail.mjs.html +1 -1
  317. package/docs/isErr.mjs.html +1 -1
  318. package/docs/isIE.mjs.html +1 -1
  319. package/docs/isNarrow.mjs.html +1 -1
  320. package/docs/isStrHasCapital.mjs.html +1 -1
  321. package/docs/isStrHasLetter.mjs.html +1 -1
  322. package/docs/isStrHasLowerCase.mjs.html +1 -1
  323. package/docs/isStrHasNumber.mjs.html +1 -1
  324. package/docs/isStrHasSpace.mjs.html +1 -1
  325. package/docs/isStrHasSymbol.mjs.html +1 -1
  326. package/docs/isUserIdentify.mjs.html +1 -1
  327. package/docs/isUserName.mjs.html +1 -1
  328. package/docs/isUserPw.mjs.html +1 -1
  329. package/docs/isWindow.mjs.html +1 -1
  330. package/docs/isab.mjs.html +1 -1
  331. package/docs/isarr.mjs.html +1 -1
  332. package/docs/isarr0.mjs.html +1 -1
  333. package/docs/isarr1.mjs.html +1 -1
  334. package/docs/isbigint.mjs.html +1 -1
  335. package/docs/isblob.mjs.html +1 -1
  336. package/docs/isbol.mjs.html +1 -1
  337. package/docs/isday.mjs.html +1 -1
  338. package/docs/isearr.mjs.html +1 -1
  339. package/docs/iseobj.mjs.html +1 -1
  340. package/docs/iser.mjs.html +1 -1
  341. package/docs/isernot.mjs.html +1 -1
  342. package/docs/isestr.mjs.html +1 -1
  343. package/docs/isfile.mjs.html +1 -1
  344. package/docs/isfun.mjs.html +1 -1
  345. package/docs/isint.mjs.html +1 -1
  346. package/docs/ismonth.mjs.html +1 -1
  347. package/docs/isn0int.mjs.html +1 -1
  348. package/docs/isn0num.mjs.html +1 -1
  349. package/docs/isnan.mjs.html +1 -1
  350. package/docs/isnbr.mjs.html +1 -1
  351. package/docs/isnint.mjs.html +1 -1
  352. package/docs/isnnum.mjs.html +1 -1
  353. package/docs/isnull.mjs.html +1 -1
  354. package/docs/isnum.mjs.html +1 -1
  355. package/docs/isobj.mjs.html +1 -1
  356. package/docs/isobj0.mjs.html +1 -1
  357. package/docs/isp0int.mjs.html +1 -1
  358. package/docs/isp0num.mjs.html +1 -1
  359. package/docs/ispint.mjs.html +1 -1
  360. package/docs/ispm.mjs.html +1 -1
  361. package/docs/ispnum.mjs.html +1 -1
  362. package/docs/isstr.mjs.html +1 -1
  363. package/docs/isstr0.mjs.html +1 -1
  364. package/docs/istime.mjs.html +1 -1
  365. package/docs/istimeTZ.mjs.html +1 -1
  366. package/docs/istimems.mjs.html +1 -1
  367. package/docs/istimemsTZ.mjs.html +1 -1
  368. package/docs/isu16arr.mjs.html +1 -1
  369. package/docs/isu8arr.mjs.html +1 -1
  370. package/docs/isundefined.mjs.html +1 -1
  371. package/docs/j2o.mjs.html +1 -1
  372. package/docs/judge.mjs.html +1 -1
  373. package/docs/keysmat2ltdt.mjs.html +1 -1
  374. package/docs/ltdt2vrtsable.mjs.html +1 -1
  375. package/docs/ltdtDiff.mjs.html +1 -1
  376. package/docs/ltdtDiffByKey.mjs.html +1 -1
  377. package/docs/ltdtkeys2mat.mjs.html +1 -1
  378. package/docs/ltdtkeysheads2mat.mjs.html +1 -1
  379. package/docs/ltdtmapping.mjs.html +1 -1
  380. package/docs/ltdtmerge.mjs.html +1 -1
  381. package/docs/ltdtpick.mjs.html +1 -1
  382. package/docs/ltdtpull.mjs.html +1 -1
  383. package/docs/mat2ltdt.mjs.html +1 -1
  384. package/docs/matConcat.mjs.html +1 -1
  385. package/docs/matDiff.mjs.html +1 -1
  386. package/docs/matat.mjs.html +1 -1
  387. package/docs/now2str.mjs.html +1 -1
  388. package/docs/now2strp.mjs.html +1 -1
  389. package/docs/nowDay2str.mjs.html +1 -1
  390. package/docs/nowms2str.mjs.html +1 -1
  391. package/docs/nowms2strp.mjs.html +1 -1
  392. package/docs/o2j.mjs.html +1 -1
  393. package/docs/obj2b64.mjs.html +1 -1
  394. package/docs/obj2pb64.mjs.html +1 -1
  395. package/docs/obj2str.mjs.html +1 -1
  396. package/docs/obj2stru8arr.mjs.html +1 -1
  397. package/docs/obj2u8arr.mjs.html +1 -1
  398. package/docs/objSortBy.mjs.html +1 -1
  399. package/docs/objSortByKeys.mjs.html +1 -1
  400. package/docs/oo.mjs.html +1 -1
  401. package/docs/openLink.mjs.html +1 -1
  402. package/docs/pb642obj.mjs.html +1 -1
  403. package/docs/pmChain.mjs.html +1 -1
  404. package/docs/pmConvertResolve.mjs.html +1 -1
  405. package/docs/pmDebounce.mjs.html +1 -1
  406. package/docs/pmHook.mjs.html +1 -1
  407. package/docs/pmHookReject.mjs.html +1 -1
  408. package/docs/pmIni.mjs.html +1 -1
  409. package/docs/pmInvResolve.mjs.html +1 -1
  410. package/docs/pmKeyMutex.mjs.html +1 -1
  411. package/docs/pmMap.mjs.html +1 -1
  412. package/docs/pmQueue.mjs.html +1 -1
  413. package/docs/pmSeries.mjs.html +1 -1
  414. package/docs/pmThrottle.mjs.html +1 -1
  415. package/docs/pmTimeout.mjs.html +1 -1
  416. package/docs/preciseNum.mjs.html +1 -1
  417. package/docs/pseudoRandom.mjs.html +1 -1
  418. package/docs/pseudoRandomIntRange.mjs.html +1 -1
  419. package/docs/pseudoRandomIntsNdpRange.mjs.html +1 -1
  420. package/docs/pseudoRandomIntsRange.mjs.html +1 -1
  421. package/docs/pseudoRandomRange.mjs.html +1 -1
  422. package/docs/pseudoRandomsRange.mjs.html +1 -1
  423. package/docs/queue.mjs.html +1 -1
  424. package/docs/random.mjs.html +1 -1
  425. package/docs/randomIntRange.mjs.html +1 -1
  426. package/docs/randomIntsNdpRange.mjs.html +1 -1
  427. package/docs/randomIntsRange.mjs.html +1 -1
  428. package/docs/randomRange.mjs.html +1 -1
  429. package/docs/randomsRange.mjs.html +1 -1
  430. package/docs/rang.mjs.html +1 -1
  431. package/docs/rep.mjs.html +1 -1
  432. package/docs/repObj.mjs.html +1 -1
  433. package/docs/replace.mjs.html +1 -1
  434. package/docs/replaceObj.mjs.html +1 -1
  435. package/docs/replacePlus.mjs.html +1 -1
  436. package/docs/round.mjs.html +1 -1
  437. package/docs/secd.mjs.html +1 -1
  438. package/docs/sep.mjs.html +1 -1
  439. package/docs/sepInt.mjs.html +1 -1
  440. package/docs/setIntervalHp.mjs.html +1 -1
  441. package/docs/setTimeoutHp.mjs.html +1 -1
  442. package/docs/sind.mjs.html +1 -1
  443. package/docs/split.mjs.html +1 -1
  444. package/docs/str2aes.mjs.html +1 -1
  445. package/docs/str2b64.mjs.html +1 -1
  446. package/docs/str2hint.mjs.html +1 -1
  447. package/docs/str2md5.mjs.html +1 -1
  448. package/docs/str2obj.mjs.html +1 -1
  449. package/docs/str2sha.mjs.html +1 -1
  450. package/docs/str2sha512.mjs.html +1 -1
  451. package/docs/str2u8arr.mjs.html +1 -1
  452. package/docs/strCompare.mjs.html +1 -1
  453. package/docs/strCompareForVersion.mjs.html +1 -1
  454. package/docs/strDiff.mjs.html +1 -1
  455. package/docs/strDiffToHtml.mjs.html +1 -1
  456. package/docs/strFindFuzz.mjs.html +1 -1
  457. package/docs/strFindSimilar.mjs.html +1 -1
  458. package/docs/strTruncate.mjs.html +1 -1
  459. package/docs/strdelleft.mjs.html +1 -1
  460. package/docs/strdelright.mjs.html +1 -1
  461. package/docs/strleft.mjs.html +1 -1
  462. package/docs/strmid.mjs.html +1 -1
  463. package/docs/strright.mjs.html +1 -1
  464. package/docs/stru8arr2obj.mjs.html +1 -1
  465. package/docs/tand.mjs.html +1 -1
  466. package/docs/time2day.mjs.html +1 -1
  467. package/docs/time2hour.mjs.html +1 -1
  468. package/docs/time2min.mjs.html +1 -1
  469. package/docs/timeTZ2day.mjs.html +1 -1
  470. package/docs/timeTZ2expire.mjs.html +1 -1
  471. package/docs/timeTZ2hour.mjs.html +1 -1
  472. package/docs/timeTZ2min.mjs.html +1 -1
  473. package/docs/timeTZ2past.mjs.html +1 -1
  474. package/docs/timems2day.mjs.html +1 -1
  475. package/docs/timems2hour.mjs.html +1 -1
  476. package/docs/timems2min.mjs.html +1 -1
  477. package/docs/timems2time.mjs.html +1 -1
  478. package/docs/timemsTZ2day.mjs.html +1 -1
  479. package/docs/timemsTZ2expire.mjs.html +1 -1
  480. package/docs/timemsTZ2hour.mjs.html +1 -1
  481. package/docs/timemsTZ2min.mjs.html +1 -1
  482. package/docs/timemsTZ2past.mjs.html +1 -1
  483. package/docs/timemsTZ2time.mjs.html +1 -1
  484. package/docs/treeObj.mjs.html +7 -7
  485. package/docs/treeToFilepath.mjs.html +1 -1
  486. package/docs/trim.mjs.html +1 -1
  487. package/docs/u16arr2b64.mjs.html +1 -1
  488. package/docs/u16arr2u8arr.mjs.html +1 -1
  489. package/docs/u8arr2ab.mjs.html +1 -1
  490. package/docs/u8arr2b64.mjs.html +1 -1
  491. package/docs/u8arr2blob.mjs.html +1 -1
  492. package/docs/u8arr2bs.mjs.html +1 -1
  493. package/docs/u8arr2obj.mjs.html +17 -3
  494. package/docs/u8arr2str.mjs.html +1 -1
  495. package/docs/u8arr2u16arr.mjs.html +1 -1
  496. package/docs/urlParse.mjs.html +1 -1
  497. package/docs/verifyValue.mjs.html +1 -1
  498. package/docs/waitFun.mjs.html +1 -1
  499. package/docs/wsemi.html +49 -20
  500. package/package.json +1 -1
  501. package/src/clearXSS.mjs +262 -24
  502. package/src/flattenToConn.mjs +11 -7
  503. package/src/flattenTree.mjs +8 -8
  504. package/src/fsTask.mjs +13 -12
  505. package/src/getFileAccept.mjs +2 -3
  506. package/src/getFileType.mjs +149 -4
  507. package/src/getltdtkeys.mjs +6 -5
  508. package/src/treeObj.mjs +6 -6
  509. package/src/u8arr2obj.mjs +16 -2
  510. package/test/clearXSS.test.mjs +1276 -1
  511. package/test/domGetFileAccept.test.mjs +79 -11
  512. package/test/flattenToConn.test.mjs +83 -0
  513. package/test/flattenTree.test.mjs +49 -0
  514. package/test/fsTask.test.mjs +144 -0
  515. package/test/getFileAccept.test.mjs +83 -0
  516. package/test/getFileType.test.mjs +200 -29
  517. package/test/getltdtkeys.test.mjs +71 -0
  518. package/test/tools/clearXssWalkRunner.mjs +202 -0
  519. package/test/tools/getFileTypeBase.mjs +189 -0
  520. package/test/treeObj.test.mjs +119 -0
  521. package/test/u8arr2obj.test.mjs +107 -2
  522. package/toolfp/dist/wsemip.umd.js +1 -1
  523. package/toolparfor/dist/wpf.umd.js +1 -1
  524. package/toolparfor/dist/wpf_pmSeries.umd.js +1 -1
@@ -1,29 +1,200 @@
1
- import assert from 'assert'
2
- import getFileType from '../src/getFileType.mjs'
3
-
4
-
5
- describe(`getFileType`, function() {
6
-
7
- let o1 = {
8
- name: 'html',
9
- group: 'docums',
10
- acp: 'text/html',
11
- exec: 'browser',
12
- }
13
- it(`should return ${JSON.stringify(o1)} when 'html'`, function() {
14
- let r = getFileType('html')
15
- assert.strict.deepStrictEqual(r, o1)
16
- })
17
-
18
- let o2 = {
19
- name: 'zip',
20
- group: 'compress',
21
- acp: 'application/zip',
22
- exec: 'compressor'
23
- }
24
- it(`should return ${JSON.stringify(o2)} when 'zip'`, function() {
25
- let r = getFileType('zip')
26
- assert.strict.deepStrictEqual(r, o2)
27
- })
28
-
29
- })
1
+ import assert from 'assert'
2
+ import getFileType from '../src/getFileType.mjs'
3
+ import base, { applyChanges } from './tools/getFileTypeBase.mjs'
4
+
5
+
6
+ //既有項目期望值: 修前基準表 + 規則 5 唯一允許之差異(heic 之 acp)
7
+ let existing = applyChanges(base)
8
+
9
+
10
+ describe(`getFileType`, function() {
11
+
12
+ let o1 = {
13
+ name: 'html',
14
+ group: 'docums',
15
+ acp: 'text/html',
16
+ exec: 'browser',
17
+ }
18
+ it(`should return ${JSON.stringify(o1)} when 'html'`, function() {
19
+ let r = getFileType('html')
20
+ assert.strict.deepStrictEqual(r, o1)
21
+ })
22
+
23
+ let o2 = {
24
+ name: 'zip',
25
+ group: 'compress',
26
+ acp: 'application/zip',
27
+ exec: 'compressor'
28
+ }
29
+ it(`should return ${JSON.stringify(o2)} when 'zip'`, function() {
30
+ let r = getFileType('zip')
31
+ assert.strict.deepStrictEqual(r, o2)
32
+ })
33
+
34
+ })
35
+
36
+
37
+ //R-FILETYPE-01: 新增項目(附於表尾)之預期列, acp 依 IANA 登錄(gpx 無登錄取通行值), group/exec 比照同類既有項目
38
+ let newRows = [
39
+ { name: 'jpeg', group: 'image', acp: 'image/jpeg', exec: 'imageviwer' },
40
+ { name: 'jpe', group: 'image', acp: 'image/jpeg', exec: 'imageviwer' },
41
+ { name: 'jfif', group: 'image', acp: 'image/jpeg', exec: 'imageviwer' },
42
+ { name: 'tiff', group: 'image', acp: 'image/tiff', exec: 'imageviwer' },
43
+ { name: 'svg', group: 'image', acp: 'image/svg+xml', exec: 'imageviwer' },
44
+ { name: 'heif', group: 'image', acp: 'image/heif', exec: 'imageviwer' },
45
+ { name: 'md', group: 'data', acp: 'text/markdown', exec: 'textviwer' },
46
+ { name: 'markdown', group: 'data', acp: 'text/markdown', exec: 'textviwer' },
47
+ { name: 'yaml', group: 'data', acp: 'application/yaml', exec: 'textviwer' },
48
+ { name: 'yml', group: 'data', acp: 'application/yaml', exec: 'textviwer' },
49
+ { name: 'log', group: 'data', acp: 'text/plain', exec: 'textviwer' },
50
+ { name: 'ini', group: 'data', acp: 'text/plain', exec: 'textviwer' },
51
+ { name: 'tsv', group: 'data', acp: 'text/tab-separated-values', exec: 'excel' },
52
+ { name: 'kml', group: 'data', acp: 'application/vnd.google-earth.kml+xml', exec: 'textviwer' },
53
+ { name: 'kmz', group: '', acp: 'application/vnd.google-earth.kmz', exec: '' },
54
+ { name: 'gpx', group: 'data', acp: 'application/gpx+xml', exec: 'textviwer', msg: 'gpx無IANA登錄,application/gpx+xml為通行用法' },
55
+ { name: 'dxf', group: 'image', acp: 'image/vnd.dxf', exec: 'imageviwer' },
56
+ { name: 'las', group: '', acp: 'application/vnd.las', exec: '', msg: 'las亦為井測資料(Log ASCII Standard)副檔名,此處依光達點雲(LASer)' },
57
+ { name: 'laz', group: '', acp: 'application/vnd.laszip', exec: '' },
58
+ { name: 'obj', group: '', acp: 'model/obj', exec: '', msg: 'obj亦為編譯目的檔副檔名,此處依3D模型(Wavefront OBJ)' },
59
+ { name: 'gltf', group: '', acp: 'model/gltf+json', exec: '' },
60
+ ]
61
+
62
+
63
+ describe(`getFileType 既有項目回傳不變(R-FILETYPE-01)`, function() {
64
+
65
+ it(`修前基準表為 174 列`, function() {
66
+ assert.strict.deepStrictEqual(base.length, 174)
67
+ })
68
+
69
+ it(`全表前 ${base.length} 列與修前逐列相同(順序與內容), 唯一相異列為 heic`, function() {
70
+ let rs = getFileType().slice(0, base.length)
71
+ assert.strict.deepStrictEqual(rs, existing)
72
+ let diff = base.filter((r, i) => JSON.stringify(r) !== JSON.stringify(rs[i])).map((r) => r.name)
73
+ assert.strict.deepStrictEqual(diff, ['heic'])
74
+ })
75
+
76
+ it(`修前每個鍵以原名查詢, 仍回該列(heic 之 acp 除外)`, function() {
77
+ for (let row of existing) {
78
+ assert.strict.deepStrictEqual(getFileType(row.name), row, row.name)
79
+ }
80
+ })
81
+
82
+ it(`heic 之 acp 為 image/heic(IANA 與 File.type 實際回報), heif 為 image/heif`, function() {
83
+ assert.strict.deepStrictEqual(getFileType('heic'), { name: 'heic', group: 'image', acp: 'image/heic', exec: 'imageviwer' })
84
+ assert.strict.deepStrictEqual(getFileType('HEIC').acp, 'image/heic')
85
+ assert.strict.deepStrictEqual(getFileType('heif'), { name: 'heif', group: 'image', acp: 'image/heif', exec: 'imageviwer' })
86
+ assert.strict.deepStrictEqual(getFileType('Heif').acp, 'image/heif')
87
+ })
88
+
89
+ it(`修前未收錄且不在新增項目內者仍回 null`, function() {
90
+ for (let k of ['nonexist', 'jpgg', 'jp', 'xlsm', 'wmv', '.jpg', ' jpg', 'jpg ', 'j p g', '__proto__', 'constructor', 'toString', 'hasOwnProperty']) {
91
+ assert.strict.deepStrictEqual(getFileType(k), null, k)
92
+ }
93
+ })
94
+
95
+ it(`無參數與空字串回全表(同一份)`, function() {
96
+ let rs = getFileType()
97
+ assert.strict.deepStrictEqual(Array.isArray(rs), true)
98
+ assert.strict.deepStrictEqual(rs.length, base.length + newRows.length)
99
+ assert.strict.strictEqual(getFileType(''), rs)
100
+ })
101
+
102
+ })
103
+
104
+
105
+ describe(`getFileType 新增項目(R-FILETYPE-01)`, function() {
106
+
107
+ for (let row of newRows) {
108
+ it(`should return ${row.acp} when '${row.name}'`, function() {
109
+ let r = getFileType(row.name)
110
+ assert.strict.deepStrictEqual(r, row)
111
+ })
112
+ }
113
+
114
+ it(`表尾恰為預期之 ${newRows.length} 項且順序相同(附於既有項目之後; 順序決定 getFileAccept 分組與 accept 字串之成員順序)`, function() {
115
+ let rs = getFileType()
116
+ assert.strict.deepStrictEqual(rs.slice(base.length), newRows)
117
+ })
118
+
119
+ it(`group 與 exec 只使用修前表已有之值`, function() {
120
+ let groups = new Set(base.map((v) => v.group))
121
+ let execs = new Set(base.map((v) => v.exec))
122
+ for (let row of getFileType()) {
123
+ assert.strict.deepStrictEqual(groups.has(row.group), true, `${row.name} group=${row.group}`)
124
+ assert.strict.deepStrictEqual(execs.has(row.exec), true, `${row.name} exec=${row.exec}`)
125
+ }
126
+ })
127
+
128
+ it(`group 為 image 者 acp 皆以 image/ 開頭`, function() {
129
+ for (let row of getFileType()) {
130
+ if (row.group === 'image') {
131
+ assert.strict.deepStrictEqual(row.acp.startsWith('image/'), true, row.name)
132
+ }
133
+ }
134
+ })
135
+
136
+ it(`鍵一律小寫(唯一例外 Z), 且小寫後無重複`, function() {
137
+ let names = getFileType().map((v) => v.name)
138
+ assert.strict.deepStrictEqual(names.filter((n) => n !== n.toLowerCase()), ['Z'])
139
+ assert.strict.deepStrictEqual(new Set(names.map((n) => n.toLowerCase())).size, names.length)
140
+ })
141
+
142
+ it(`鍵不得為 __proto__(getFileAccept 以 r[k] = [] 建分組, 會設定原型而非自有鍵)`, function() {
143
+ let names = getFileType().map((v) => v.name)
144
+ assert.strict.deepStrictEqual(names.filter((n) => n === '__proto__'), [])
145
+ })
146
+
147
+ })
148
+
149
+
150
+ describe(`getFileType 不分大小寫(R-FILETYPE-01)`, function() {
151
+
152
+ let oZ = {
153
+ name: 'Z',
154
+ group: 'compress',
155
+ acp: 'application/x-compress',
156
+ exec: 'compressor'
157
+ }
158
+ it(`should return ${JSON.stringify(oZ)} when 'z' and 'Z'`, function() {
159
+ assert.strict.deepStrictEqual(getFileType('z'), oZ)
160
+ assert.strict.deepStrictEqual(getFileType('Z'), oZ)
161
+ })
162
+
163
+ it(`全表: 每個鍵之全大寫, 全小寫, 首字母大寫變體皆回同一列`, function() {
164
+ for (let row of getFileType()) {
165
+ let n = row.name
166
+ let cap = n.charAt(0).toUpperCase() + n.slice(1).toLowerCase()
167
+ for (let v of [n.toUpperCase(), n.toLowerCase(), cap]) {
168
+ assert.strict.strictEqual(getFileType(v), row, `${n} <- ${v}`)
169
+ }
170
+ }
171
+ })
172
+
173
+ it(`混合大小寫`, function() {
174
+ assert.strict.deepStrictEqual(getFileType('JPG').acp, 'image/jpeg')
175
+ assert.strict.deepStrictEqual(getFileType('jPeG').acp, 'image/jpeg')
176
+ assert.strict.deepStrictEqual(getFileType('SVG').acp, 'image/svg+xml')
177
+ assert.strict.deepStrictEqual(getFileType('Mp3').acp, 'audio/mpeg')
178
+ assert.strict.deepStrictEqual(getFileType('PdF').acp, 'application/pdf')
179
+ assert.strict.deepStrictEqual(getFileType('HTML').acp, 'text/html')
180
+ assert.strict.deepStrictEqual(getFileType('Docx').exec, 'word')
181
+ })
182
+
183
+ it(`包裝字串物件(new String)同原始字串`, function() {
184
+ assert.strict.strictEqual(getFileType(new String('html')), getFileType('html')) // eslint-disable-line no-new-wrappers
185
+ assert.strict.strictEqual(getFileType(new String('JPG')), getFileType('jpg')) // eslint-disable-line no-new-wrappers
186
+ assert.strict.deepStrictEqual(getFileType(new String('nonexist')), null) // eslint-disable-line no-new-wrappers
187
+ })
188
+
189
+ it(`回傳列之 name 保持表內原樣`, function() {
190
+ assert.strict.deepStrictEqual(getFileType('SVG').name, 'svg')
191
+ assert.strict.deepStrictEqual(getFileType('z').name, 'Z')
192
+ })
193
+
194
+ it(`大小寫變體不影響未命中判定`, function() {
195
+ for (let k of ['NONEXIST', 'JPGG', '.JPG', ' JPG', 'JPG ', 'Constructor', '__PROTO__']) {
196
+ assert.strict.deepStrictEqual(getFileType(k), null, k)
197
+ }
198
+ })
199
+
200
+ })
@@ -2,6 +2,77 @@ import assert from 'assert'
2
2
  import getltdtkeys from '../src/getltdtkeys.mjs'
3
3
 
4
4
 
5
+ describe(`getltdtkeys 列物件只依自有鍵(R-OBJ-ITER-01 候選11)`, function() {
6
+
7
+ it(`should return the own keys of a row that fakes Arguments with a non-writable Symbol.toStringTag`, function() {
8
+ //lodash keys 對不可寫偽稱 Arguments 之物件走 baseTimes(length), 修前得 ['0','1','a']
9
+ let row = Object.defineProperty({ a: 1, length: 2 }, Symbol.toStringTag, { value: 'Arguments' })
10
+ assert.strict.deepStrictEqual(getltdtkeys([row]), ['a', 'length'])
11
+ assert.strict.deepStrictEqual(getltdtkeys([{ x: 1 }, row, { y: 2 }]), ['x', 'a', 'length', 'y'])
12
+ })
13
+
14
+ it(`should return the own keys of a row that fakes Array or Arguments with a writable tag`, function() {
15
+ assert.strict.deepStrictEqual(getltdtkeys([{ a: 1, length: 2, [Symbol.toStringTag]: 'Arguments' }]), ['a', 'length'])
16
+ assert.strict.deepStrictEqual(getltdtkeys([{ a: 1, length: 2, [Symbol.toStringTag]: 'Array' }]), ['a', 'length'])
17
+ })
18
+
19
+ it(`should treat length as an ordinary key of a row (any non-negative integer, small values)`, function() {
20
+ assert.strict.deepStrictEqual(getltdtkeys([{ length: 2, a: 'x' }]), ['length', 'a'])
21
+ assert.strict.deepStrictEqual(getltdtkeys([{ length: 0, a: 'x' }, { length: 1000, b: 'y' }]), ['length', 'a', 'b'])
22
+ assert.strict.deepStrictEqual(getltdtkeys([{ a: 1, length: -0 }]), ['a', 'length'])
23
+ })
24
+
25
+ it(`should keep the behavior for rows that are arrays (including holes), strings, typed arrays, null and primitives`, function() {
26
+ //列為真陣列者沿用 lodash keys: 含空洞索引(Object.keys 不含)
27
+ assert.strict.deepStrictEqual(getltdtkeys([[1, 2]]), ['0', '1'])
28
+ assert.strict.deepStrictEqual(getltdtkeys([[, 1]]), ['0', '1']) // eslint-disable-line no-sparse-arrays
29
+ assert.strict.deepStrictEqual(getltdtkeys([new Uint8Array(2)]), ['0', '1'])
30
+ assert.strict.deepStrictEqual(getltdtkeys([null, undefined, 5, true, 'ab', { a: 1 }]), ['0', '1', 'a'])
31
+ assert.strict.deepStrictEqual(getltdtkeys([new Map([['k', 1]]), new Date(0), /a/, () => 1]), [])
32
+ })
33
+
34
+ it(`should return the own enumerable string keys of class instances, null-prototype rows and rows with inherited keys`, function() {
35
+ class Foo {
36
+ constructor() {
37
+ this.a = 1
38
+ }
39
+ }
40
+ let np = Object.create(null)
41
+ np.n = 1
42
+ let inh = Object.create({ p: 1 })
43
+ inh.q = 2
44
+ assert.strict.deepStrictEqual(getltdtkeys([new Foo(), np, inh]), ['a', 'n', 'q'])
45
+ })
46
+
47
+ it(`should return the same keys as the lodash keys on 500 random rows without length keys`, function() {
48
+ let seed = 20261020
49
+ let rnd = () => {
50
+ seed = (seed * 1103515245 + 12345) % 2147483648
51
+ return seed / 2147483648
52
+ }
53
+ let names = ['a', 'b', 'c', '0', '1', '10', 'constructor', 'toString', 'x y', '中文']
54
+ let rows = []
55
+ for (let i = 0; i < 500; i++) {
56
+ let o = {}
57
+ let n = Math.floor(rnd() * 5)
58
+ for (let j = 0; j < n; j++) {
59
+ o[names[Math.floor(rnd() * names.length)]] = j
60
+ }
61
+ rows.push(o)
62
+ }
63
+ let expected = []
64
+ for (let o of rows) {
65
+ for (let k of Object.keys(o)) {
66
+ if (!expected.includes(k)) {
67
+ expected.push(k)
68
+ }
69
+ }
70
+ }
71
+ assert.strict.deepStrictEqual(getltdtkeys(rows), expected)
72
+ })
73
+
74
+ })
75
+
5
76
  describe(`getltdtkeys`, function() {
6
77
  let k
7
78
  let o = {}
@@ -0,0 +1,202 @@
1
+ //clearXssWalkRunner.mjs: 於限額子行程執行 clearXSS 之走訪案例(R-XSS-WALK-01): 極深巢狀、大型共用結構(DAG)、大型循環
2
+ // 修前之實作對深巢狀同步拋 RangeError(未捕捉, 離開碼非 0)、對 DAG 依路徑數指數重走(2^n, 逾時被終止)
3
+ // 約定同runChildCase: node [--max-old-space-size=N] clearXssWalkRunner.mjs <caseName>, 結果以一行'@@R@@'開頭之JSON輸出至stdout
4
+ // caseName:
5
+ // 'deep:<obj|arr|mixed|map|set>:<層數>': 迭代建構之深巢狀(葉為字串)
6
+ // 'dag:<obj|arr|map|set|mixed>:<層數>': 每層兩個參照指向同一子結構, 葉為字串; 計 filterXSS 呼叫數
7
+ // 'cycle:<長度>': 長度為n之物件環(最後一個指回第一個), 每個節點帶一個字串
8
+ import clearXSS from '../../src/clearXSS.mjs'
9
+ import fxss from '../../src/_filterXSS.mjs'
10
+
11
+
12
+ let x = '<script>alert(1)</script>'
13
+ let fx = '&lt;script>alert(1)&lt;/script>'
14
+
15
+ //計 filterXSS 呼叫數(fxss為可變單例, clearXSS每次呼叫經fxss.getFilterXSS取得)
16
+ let calls = 0
17
+ let origGet = fxss.getFilterXSS
18
+ fxss.getFilterXSS = () => {
19
+ let f = origGet()
20
+ let w = (c, o) => {
21
+ calls++
22
+ return f(c, o)
23
+ }
24
+ w.escapeAttrValue = f.escapeAttrValue
25
+ return w
26
+ }
27
+
28
+ let caseName = process.argv[2] || ''
29
+ let [kind, sub, sn] = caseName.split(':')
30
+ let n = Number(kind === 'cycle' ? sub : sn)
31
+
32
+ //wrap, 依種類包一層
33
+ let wrap = (kind2, i, cur) => {
34
+ if (kind2 === 'obj') {
35
+ return { a: cur }
36
+ }
37
+ if (kind2 === 'arr') {
38
+ return [cur]
39
+ }
40
+ if (kind2 === 'map') {
41
+ return new Map([['k', cur]])
42
+ }
43
+ if (kind2 === 'set') {
44
+ return new Set([cur])
45
+ }
46
+ return (i % 2 === 0) ? { a: cur } : [cur] //mixed
47
+ }
48
+
49
+ //child, 取子節點(迭代取葉用)
50
+ let child = (v) => {
51
+ if (Array.isArray(v)) {
52
+ return v[0]
53
+ }
54
+ if (v instanceof Map) {
55
+ return v.get('k')
56
+ }
57
+ if (v instanceof Set) {
58
+ return [...v][0]
59
+ }
60
+ return v.a
61
+ }
62
+
63
+ //leaf, 迭代取葉並回傳深度
64
+ let leafOf = (v) => {
65
+ let d = 0
66
+ while (typeof v === 'object' && v !== null) {
67
+ v = child(v)
68
+ d++
69
+ }
70
+ return { v, d }
71
+ }
72
+
73
+ let out = { kind, sub, n }
74
+ clearXSS({ b: x }) //先載入js-xss
75
+ if (global.gc) {
76
+ global.gc()
77
+ }
78
+
79
+ if (kind === 'deep') {
80
+ let inp = x
81
+ for (let i = 0; i < n; i++) {
82
+ inp = wrap(sub, i, inp)
83
+ }
84
+ let h0 = process.memoryUsage().heapUsed
85
+ calls = 0
86
+ let t0 = process.hrtime.bigint()
87
+ let r = clearXSS(inp)
88
+ out.ms = Number(process.hrtime.bigint() - t0) / 1e6
89
+ out.heapMB = (process.memoryUsage().heapUsed - h0) / 1048576
90
+ let lo = leafOf(r)
91
+ let li = leafOf(inp)
92
+ out.leafCleaned = lo.v === fx
93
+ out.inputIntact = li.v === x
94
+ out.depthOut = lo.d
95
+ out.depthIn = li.d
96
+ out.notSame = r !== inp
97
+ out.calls = calls
98
+ }
99
+ else if (kind === 'dag') {
100
+ let cur = sub === 'map' ? new Map([['v', x]]) : sub === 'set' ? new Set([x]) : sub === 'arr' ? [x] : { v: x } //mixed之葉同obj
101
+ for (let i = 0; i < n; i++) {
102
+ if (sub === 'obj') {
103
+ cur = { l: cur, r: cur }
104
+ }
105
+ else if (sub === 'arr') {
106
+ cur = [cur, cur]
107
+ }
108
+ else if (sub === 'map') {
109
+ cur = new Map([['l', cur], ['r', cur]])
110
+ }
111
+ else if (sub === 'set') {
112
+ cur = new Set([{ p: cur }, { q: cur }]) //Set元素不可重複, 兩個包裝物件各引用同一子Set
113
+ }
114
+ else {
115
+ cur = (i % 2 === 0) ? { l: cur, r: cur } : [cur, cur]
116
+ }
117
+ }
118
+ calls = 0
119
+ let t0 = process.hrtime.bigint()
120
+ let r = clearXSS(cur)
121
+ out.ms = Number(process.hrtime.bigint() - t0) / 1e6
122
+ out.calls = calls
123
+ //共用: 沿 l 與 r 兩側各走到底, 每層兩側須為同一輸出物件
124
+ let shared = true
125
+ let v = r
126
+ let steps = 0
127
+ while (typeof v === 'object' && v !== null && steps < n + 5) {
128
+ if (sub === 'obj') {
129
+ if (v.l === undefined) {
130
+ break
131
+ }
132
+ shared = shared && v.l === v.r
133
+ v = v.l
134
+ }
135
+ else if (sub === 'arr') {
136
+ if (v.length !== 2) {
137
+ break
138
+ }
139
+ shared = shared && v[0] === v[1]
140
+ v = v[0]
141
+ }
142
+ else if (sub === 'map') {
143
+ if (!v.has('l')) {
144
+ break
145
+ }
146
+ shared = shared && v.get('l') === v.get('r')
147
+ v = v.get('l')
148
+ }
149
+ else if (sub === 'set') {
150
+ let es = [...v]
151
+ if (typeof es[0] !== 'object' || es[0] === null || es[0].p === undefined) {
152
+ break
153
+ }
154
+ shared = shared && es[0].p === es[1].q
155
+ v = es[0].p
156
+ }
157
+ else {
158
+ if (Array.isArray(v)) {
159
+ shared = shared && v[0] === v[1]
160
+ v = v[0]
161
+ }
162
+ else {
163
+ if (v.l === undefined) {
164
+ break
165
+ }
166
+ shared = shared && v.l === v.r
167
+ v = v.l
168
+ }
169
+ }
170
+ steps++
171
+ }
172
+ out.shared = shared
173
+ out.steps = steps
174
+ }
175
+ else if (kind === 'cycle') {
176
+ let head = { i: 0, s: x }
177
+ let cur = head
178
+ for (let i = 1; i < n; i++) {
179
+ let nx = { i, s: x }
180
+ cur.next = nx
181
+ cur = nx
182
+ }
183
+ cur.next = head
184
+ let t0 = process.hrtime.bigint()
185
+ let r = clearXSS(head)
186
+ out.ms = Number(process.hrtime.bigint() - t0) / 1e6
187
+ //走一圈: 每個節點字串已清除, 第n步回到起點
188
+ let v = r
189
+ let ok = true
190
+ for (let i = 0; i < n; i++) {
191
+ ok = ok && v.i === i && v.s === fx
192
+ v = v.next
193
+ }
194
+ out.cleaned = ok
195
+ out.closed = v === r
196
+ out.inputIntact = head.s === x && cur.next === head
197
+ }
198
+ else {
199
+ throw new Error('unknown case: ' + caseName)
200
+ }
201
+
202
+ console.log('@@R@@' + JSON.stringify(out))