UNPKG

wsemi

Version:

A support package for web developer.

778 lines (757 loc) 58.9 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>convertToTree.mjs - Documentation</title> <script src="scripts/prettify/prettify.js"></script> <script src="scripts/prettify/lang-css.js"></script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/prettify.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc.css"> <script src="scripts/nav.js" defer></script> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <input type="checkbox" id="nav-trigger" class="nav-trigger" /> <label for="nav-trigger" class="navicon-button x"> <div class="navicon"></div> </label> <label for="nav-trigger" class="overlay"></label> <nav > <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="wsemi.html">wsemi</a><ul class='methods'><li data-type='method'><a href="wsemi.html#.ab2blob">ab2blob</a></li><li data-type='method'><a href="wsemi.html#.ab2u8arr">ab2u8arr</a></li><li data-type='method'><a href="wsemi.html#.addExcelWorksheetFromData">addExcelWorksheetFromData</a></li><li data-type='method'><a href="wsemi.html#.addMonth">addMonth</a></li><li data-type='method'><a href="wsemi.html#.aes2str">aes2str</a></li><li data-type='method'><a href="wsemi.html#.alive">alive</a></li><li data-type='method'><a href="wsemi.html#.arr2dt">arr2dt</a></li><li data-type='method'><a href="wsemi.html#.arrAccum">arrAccum</a></li><li data-type='method'><a href="wsemi.html#.arrAdd">arrAdd</a></li><li data-type='method'><a href="wsemi.html#.arrAt">arrAt</a></li><li data-type='method'><a href="wsemi.html#.arrDiff">arrDiff</a></li><li data-type='method'><a href="wsemi.html#.arrFilterByKeywords">arrFilterByKeywords</a></li><li data-type='method'><a href="wsemi.html#.arrFilterByNum">arrFilterByNum</a></li><li data-type='method'><a href="wsemi.html#.arrFilterByPnum">arrFilterByPnum</a></li><li data-type='method'><a href="wsemi.html#.arrFilterByPnumAndToLog">arrFilterByPnumAndToLog</a></li><li data-type='method'><a href="wsemi.html#.arrFind">arrFind</a></li><li data-type='method'><a href="wsemi.html#.arrGroupByMaxmin">arrGroupByMaxmin</a></li><li data-type='method'><a href="wsemi.html#.arrHas">arrHas</a></li><li data-type='method'><a href="wsemi.html#.arrInsert">arrInsert</a></li><li data-type='method'><a href="wsemi.html#.arrLookupByMaxmin">arrLookupByMaxmin</a></li><li data-type='method'><a href="wsemi.html#.arrMax">arrMax</a></li><li data-type='method'><a href="wsemi.html#.arrMin">arrMin</a></li><li data-type='method'><a href="wsemi.html#.arrMulti">arrMulti</a></li><li data-type='method'><a href="wsemi.html#.arrNorm">arrNorm</a></li><li data-type='method'><a href="wsemi.html#.arrProduct">arrProduct</a></li><li data-type='method'><a href="wsemi.html#.arrReduce">arrReduce</a></li><li data-type='method'><a href="wsemi.html#.arrSep">arrSep</a></li><li data-type='method'><a href="wsemi.html#.arrSort">arrSort</a></li><li data-type='method'><a href="wsemi.html#.asind">asind</a></li><li data-type='method'><a href="wsemi.html#.atan2d">atan2d</a></li><li data-type='method'><a href="wsemi.html#.atand">atand</a></li><li data-type='method'><a href="wsemi.html#.attstr">attstr</a></li><li data-type='method'><a href="wsemi.html#.b642obj">b642obj</a></li><li data-type='method'><a href="wsemi.html#.b642str">b642str</a></li><li data-type='method'><a href="wsemi.html#.b642u16arr">b642u16arr</a></li><li data-type='method'><a href="wsemi.html#.b642u8arr">b642u8arr</a></li><li data-type='method'><a href="wsemi.html#.binstr">binstr</a></li><li data-type='method'><a href="wsemi.html#.blob2ab">blob2ab</a></li><li data-type='method'><a href="wsemi.html#.blob2b64">blob2b64</a></li><li data-type='method'><a href="wsemi.html#.blob2str">blob2str</a></li><li data-type='method'><a href="wsemi.html#.blob2u8arr">blob2u8arr</a></li><li data-type='method'><a href="wsemi.html#.blobs2b64s">blobs2b64s</a></li><li data-type='method'><a href="wsemi.html#.blobs2u8arrs">blobs2u8arrs</a></li><li data-type='method'><a href="wsemi.html#.bodyLog">bodyLog</a></li><li data-type='method'><a href="wsemi.html#.browserView">browserView</a></li><li data-type='method'><a href="wsemi.html#.browserViewFromBlob">browserViewFromBlob</a></li><li data-type='method'><a href="wsemi.html#.browserViewFromText">browserViewFromText</a></li><li data-type='method'><a href="wsemi.html#.browserViewFromU8arr">browserViewFromU8arr</a></li><li data-type='method'><a href="wsemi.html#.bs2u8arr">bs2u8arr</a></li><li data-type='method'><a href="wsemi.html#.bufRead">bufRead</a></li><li data-type='method'><a href="wsemi.html#.bufReadDbl">bufReadDbl</a></li><li data-type='method'><a href="wsemi.html#.bufWrite">bufWrite</a></li><li data-type='method'><a href="wsemi.html#.bufWriteDbl">bufWriteDbl</a></li><li data-type='method'><a href="wsemi.html#.cache">cache</a></li><li data-type='method'><a href="wsemi.html#.cbol">cbol</a></li><li data-type='method'><a href="wsemi.html#.cdbl">cdbl</a></li><li data-type='method'><a href="wsemi.html#.cfilesize">cfilesize</a></li><li data-type='method'><a href="wsemi.html#.cfinancial">cfinancial</a></li><li data-type='method'><a href="wsemi.html#.cint">cint</a></li><li data-type='method'><a href="wsemi.html#.clearXSS">clearXSS</a></li><li data-type='method'><a href="wsemi.html#.color">color</a></li><li data-type='method'><a href="wsemi.html#.composeToTree">composeToTree</a></li><li data-type='method'><a href="wsemi.html#.convertToTree">convertToTree</a></li><li data-type='method'><a href="wsemi.html#.copyStrToClipboard">copyStrToClipboard</a></li><li data-type='method'><a href="wsemi.html#.cosd">cosd</a></li><li data-type='method'><a href="wsemi.html#.cotd">cotd</a></li><li data-type='method'><a href="wsemi.html#.createExcelWorkbook">createExcelWorkbook</a></li><li data-type='method'><a href="wsemi.html#.cscd">cscd</a></li><li data-type='method'><a href="wsemi.html#.cstr">cstr</a></li><li data-type='method'><a href="wsemi.html#.day2cht">day2cht</a></li><li data-type='method'><a href="wsemi.html#.debounce">debounce</a></li><li data-type='method'><a href="wsemi.html#.delay">delay</a></li><li data-type='method'><a href="wsemi.html#.dig">dig</a></li><li data-type='method'><a href="wsemi.html#.digExp">digExp</a></li><li data-type='method'><a href="wsemi.html#.domAlert">domAlert</a></li><li data-type='method'><a href="wsemi.html#.domAppend">domAppend</a></li><li data-type='method'><a href="wsemi.html#.domCancelEvent">domCancelEvent</a></li><li data-type='method'><a href="wsemi.html#.domCompareText">domCompareText</a></li><li data-type='method'><a href="wsemi.html#.domCompareTextDyn">domCompareTextDyn</a></li><li data-type='method'><a href="wsemi.html#.domConvertToPic">domConvertToPic</a></li><li data-type='method'><a href="wsemi.html#.domConvertToPicDyn">domConvertToPicDyn</a></li><li data-type='method'><a href="wsemi.html#.domDetect">domDetect</a></li><li data-type='method'><a href="wsemi.html#.domDrag">domDrag</a></li><li data-type='method'><a href="wsemi.html#.domDragBarAndScroll">domDragBarAndScroll</a></li><li data-type='method'><a href="wsemi.html#.domDragPreview">domDragPreview</a></li><li data-type='method'><a href="wsemi.html#.domDropFiles">domDropFiles</a></li><li data-type='method'><a href="wsemi.html#.domElementsFromPoint">domElementsFromPoint</a></li><li data-type='method'><a href="wsemi.html#.domFadeIn">domFadeIn</a></li><li data-type='method'><a href="wsemi.html#.domFadeOut">domFadeOut</a></li><li data-type='method'><a href="wsemi.html#.domFind">domFind</a></li><li data-type='method'><a href="wsemi.html#.domFinds">domFinds</a></li><li data-type='method'><a href="wsemi.html#.domGetAttr">domGetAttr</a></li><li data-type='method'><a href="wsemi.html#.domGetBoudRect">domGetBoudRect</a></li><li data-type='method'><a href="wsemi.html#.domGetBoudRectRefSelf">domGetBoudRectRefSelf</a></li><li data-type='method'><a href="wsemi.html#.domGetFileAccept">domGetFileAccept</a></li><li data-type='method'><a href="wsemi.html#.domGetFiles">domGetFiles</a></li><li data-type='method'><a href="wsemi.html#.domGetParents">domGetParents</a></li><li data-type='method'><a href="wsemi.html#.domGetPointFromEvent">domGetPointFromEvent</a></li><li data-type='method'><a href="wsemi.html#.domGetScrollableParent">domGetScrollableParent</a></li><li data-type='method'><a href="wsemi.html#.domGetWindowSize">domGetWindowSize</a></li><li data-type='method'><a href="wsemi.html#.domIsClientXYIn">domIsClientXYIn</a></li><li data-type='method'><a href="wsemi.html#.domIsFocused">domIsFocused</a></li><li data-type='method'><a href="wsemi.html#.domIsVisible">domIsVisible</a></li><li data-type='method'><a href="wsemi.html#.domPrepend">domPrepend</a></li><li data-type='method'><a href="wsemi.html#.domRemove">domRemove</a></li><li data-type='method'><a href="wsemi.html#.domRenderMarkdownMind">domRenderMarkdownMind</a></li><li data-type='method'><a href="wsemi.html#.domRenderMarkdownMindDyn">domRenderMarkdownMindDyn</a></li><li data-type='method'><a href="wsemi.html#.domRipple">domRipple</a></li><li data-type='method'><a href="wsemi.html#.domScrollIntoView">domScrollIntoView</a></li><li data-type='method'><a href="wsemi.html#.domScrollTo">domScrollTo</a></li><li data-type='method'><a href="wsemi.html#.domShowImages">domShowImages</a></li><li data-type='method'><a href="wsemi.html#.domShowImagesDyn">domShowImagesDyn</a></li><li data-type='method'><a href="wsemi.html#.domShowInputAndGetFiles">domShowInputAndGetFiles</a></li><li data-type='method'><a href="wsemi.html#.domShowInputAndGetFilesU8Arrs">domShowInputAndGetFilesU8Arrs</a></li><li data-type='method'><a href="wsemi.html#.domTooltip">domTooltip</a></li><li data-type='method'><a href="wsemi.html#.domTriggerEvent">domTriggerEvent</a></li><li data-type='method'><a href="wsemi.html#.domVirtualCreate">domVirtualCreate</a></li><li data-type='method'><a href="wsemi.html#.domVirtualCreateQueue">domVirtualCreateQueue</a></li><li data-type='method'><a href="wsemi.html#.downloadExcelFileFromData">downloadExcelFileFromData</a></li><li data-type='method'><a href="wsemi.html#.downloadExcelFileFromDataDyn">downloadExcelFileFromDataDyn</a></li><li data-type='method'><a href="wsemi.html#.downloadFileFromB64">downloadFileFromB64</a></li><li data-type='method'><a href="wsemi.html#.downloadFileFromBlob">downloadFileFromBlob</a></li><li data-type='method'><a href="wsemi.html#.downloadFileFromText">downloadFileFromText</a></li><li data-type='method'><a href="wsemi.html#.downloadFileFromU8Arr">downloadFileFromU8Arr</a></li><li data-type='method'><a href="wsemi.html#.dtmapping">dtmapping</a></li><li data-type='method'><a href="wsemi.html#.dtpick">dtpick</a></li><li data-type='method'><a href="wsemi.html#.evem">evem</a></li><li data-type='method'><a href="wsemi.html#.execProcess">execProcess</a></li><li data-type='method'><a href="wsemi.html#.execScript">execScript</a></li><li data-type='method'><a href="wsemi.html#.f2c">f2c</a></li><li data-type='method'><a href="wsemi.html#.filepathToTree">filepathToTree</a></li><li data-type='method'><a href="wsemi.html#.files2data">files2data</a></li><li data-type='method'><a href="wsemi.html#.flattenToConn">flattenToConn</a></li><li data-type='method'><a href="wsemi.html#.flattenTree">flattenTree</a></li><li data-type='method'><a href="wsemi.html#.fsCleanFolder">fsCleanFolder</a></li><li data-type='method'><a href="wsemi.html#.fsCopyFolder">fsCopyFolder</a></li><li data-type='method'><a href="wsemi.html#.fsCreateFile">fsCreateFile</a></li><li data-type='method'><a href="wsemi.html#.fsCreateFolder">fsCreateFolder</a></li><li data-type='method'><a href="wsemi.html#.fsDeleteFile">fsDeleteFile</a></li><li data-type='method'><a href="wsemi.html#.fsDeleteFolder">fsDeleteFolder</a></li><li data-type='method'><a href="wsemi.html#.fsEvem">fsEvem</a></li><li data-type='method'><a href="wsemi.html#.fsGetFilesInFolder">fsGetFilesInFolder</a></li><li data-type='method'><a href="wsemi.html#.fsGetFoldersInFolder">fsGetFoldersInFolder</a></li><li data-type='method'><a href="wsemi.html#.fsIsFile">fsIsFile</a></li><li data-type='method'><a href="wsemi.html#.fsIsFolder">fsIsFolder</a></li><li data-type='method'><a href="wsemi.html#.fsReadText">fsReadText</a></li><li data-type='method'><a href="wsemi.html#.fsRenameFile">fsRenameFile</a></li><li data-type='method'><a href="wsemi.html#.fsRenameFolder">fsRenameFolder</a></li><li data-type='method'><a href="wsemi.html#.fsTreeFolder">fsTreeFolder</a></li><li data-type='method'><a href="wsemi.html#.fsWatchFile">fsWatchFile</a></li><li data-type='method'><a href="wsemi.html#.fsWriteText">fsWriteText</a></li><li data-type='method'><a href="wsemi.html#.genGradientColor">genGradientColor</a></li><li data-type='method'><a href="wsemi.html#.genID">genID</a></li><li data-type='method'><a href="wsemi.html#.genPm">genPm</a></li><li data-type='method'><a href="wsemi.html#.getBufferSize">getBufferSize</a></li><li data-type='method'><a href="wsemi.html#.getClearPathName">getClearPathName</a></li><li data-type='method'><a href="wsemi.html#.getCsvStrFromData">getCsvStrFromData</a></li><li data-type='method'><a href="wsemi.html#.getDataFromExcelFileU8Arr">getDataFromExcelFileU8Arr</a></li><li data-type='method'><a href="wsemi.html#.getDataFromExcelFileU8ArrDyn">getDataFromExcelFileU8ArrDyn</a></li><li data-type='method'><a href="wsemi.html#.getDirName">getDirName</a></li><li data-type='method'><a href="wsemi.html#.getEnv">getEnv</a></li><li data-type='method'><a href="wsemi.html#.getExcelU8ArrFromData">getExcelU8ArrFromData</a></li><li data-type='method'><a href="wsemi.html#.getExcelU8ArrFromWorkbook">getExcelU8ArrFromWorkbook</a></li><li data-type='method'><a href="wsemi.html#.getExcelWorkbookFromData">getExcelWorkbookFromData</a></li><li data-type='method'><a href="wsemi.html#.getExcelWorkbookFromWorksheet">getExcelWorkbookFromWorksheet</a></li><li data-type='method'><a href="wsemi.html#.getExcelWorksheetFromData">getExcelWorksheetFromData</a></li><li data-type='method'><a href="wsemi.html#.getFileAccept">getFileAccept</a></li><li data-type='method'><a href="wsemi.html#.getFileName">getFileName</a></li><li data-type='method'><a href="wsemi.html#.getFileTrueName">getFileTrueName</a></li><li data-type='method'><a href="wsemi.html#.getGlobal">getGlobal</a></li><li data-type='method'><a href="wsemi.html#.getObjSize">getObjSize</a></li><li data-type='method'><a href="wsemi.html#.getTimeBetween">getTimeBetween</a></li><li data-type='method'><a href="wsemi.html#.getTimeFromUnit">getTimeFromUnit</a></li><li data-type='method'><a href="wsemi.html#.getTimeObject">getTimeObject</a></li><li data-type='method'><a href="wsemi.html#.getTimeRange">getTimeRange</a></li><li data-type='method'><a href="wsemi.html#.getUserAgent">getUserAgent</a></li><li data-type='method'><a href="wsemi.html#.getUserAgentDyn">getUserAgentDyn</a></li><li data-type='method'><a href="wsemi.html#.getltdtkeys">getltdtkeys</a></li><li data-type='method'><a href="wsemi.html#.haskey">haskey</a></li><li data-type='method'><a href="wsemi.html#.html2pic">html2pic</a></li><li data-type='method'><a href="wsemi.html#.html2picDyn">html2picDyn</a></li><li data-type='method'><a href="wsemi.html#.html2str">html2str</a></li><li data-type='method'><a href="wsemi.html#.html2strDyn">html2strDyn</a></li><li data-type='method'><a href="wsemi.html#.htmlDecode">htmlDecode</a></li><li data-type='method'><a href="wsemi.html#.htmlEncode">htmlEncode</a></li><li data-type='method'><a href="wsemi.html#.importResources">importResources</a></li><li data-type='method'><a href="wsemi.html#.interp1">interp1</a></li><li data-type='method'><a href="wsemi.html#.isDev">isDev</a></li><li data-type='method'><a href="wsemi.html#.isEle">isEle</a></li><li data-type='method'><a href="wsemi.html#.isEleExistByID">isEleExistByID</a></li><li data-type='method'><a href="wsemi.html#.isEmail">isEmail</a></li><li data-type='method'><a href="wsemi.html#.isIE">isIE</a></li><li data-type='method'><a href="wsemi.html#.isNarrow">isNarrow</a></li><li data-type='method'><a href="wsemi.html#.isStrHasCapital">isStrHasCapital</a></li><li data-type='method'><a href="wsemi.html#.isStrHasLowerCase">isStrHasLowerCase</a></li><li data-type='method'><a href="wsemi.html#.isStrHasNumber">isStrHasNumber</a></li><li data-type='method'><a href="wsemi.html#.isUserIdentify">isUserIdentify</a></li><li data-type='method'><a href="wsemi.html#.isUserName">isUserName</a></li><li data-type='method'><a href="wsemi.html#.isUserPW">isUserPW</a></li><li data-type='method'><a href="wsemi.html#.isWindow">isWindow</a></li><li data-type='method'><a href="wsemi.html#.isab">isab</a></li><li data-type='method'><a href="wsemi.html#.isarr">isarr</a></li><li data-type='method'><a href="wsemi.html#.isarr0">isarr0</a></li><li data-type='method'><a href="wsemi.html#.isblob">isblob</a></li><li data-type='method'><a href="wsemi.html#.isbol">isbol</a></li><li data-type='method'><a href="wsemi.html#.isday">isday</a></li><li data-type='method'><a href="wsemi.html#.isearr">isearr</a></li><li data-type='method'><a href="wsemi.html#.iseobj">iseobj</a></li><li data-type='method'><a href="wsemi.html#.iser">iser</a></li><li data-type='method'><a href="wsemi.html#.isernot">isernot</a></li><li data-type='method'><a href="wsemi.html#.isestr">isestr</a></li><li data-type='method'><a href="wsemi.html#.isfun">isfun</a></li><li data-type='method'><a href="wsemi.html#.isint">isint</a></li><li data-type='method'><a href="wsemi.html#.ismonth">ismonth</a></li><li data-type='method'><a href="wsemi.html#.isn0int">isn0int</a></li><li data-type='method'><a href="wsemi.html#.isn0num">isn0num</a></li><li data-type='method'><a href="wsemi.html#.isnbr">isnbr</a></li><li data-type='method'><a href="wsemi.html#.isnint">isnint</a></li><li data-type='method'><a href="wsemi.html#.isnnum">isnnum</a></li><li data-type='method'><a href="wsemi.html#.isnull">isnull</a></li><li data-type='method'><a href="wsemi.html#.isnum">isnum</a></li><li data-type='method'><a href="wsemi.html#.isobj">isobj</a></li><li data-type='method'><a href="wsemi.html#.isobj0">isobj0</a></li><li data-type='method'><a href="wsemi.html#.isp0int">isp0int</a></li><li data-type='method'><a href="wsemi.html#.isp0num">isp0num</a></li><li data-type='method'><a href="wsemi.html#.ispint">ispint</a></li><li data-type='method'><a href="wsemi.html#.ispm">ispm</a></li><li data-type='method'><a href="wsemi.html#.ispnum">ispnum</a></li><li data-type='method'><a href="wsemi.html#.isstr">isstr</a></li><li data-type='method'><a href="wsemi.html#.isstr0">isstr0</a></li><li data-type='method'><a href="wsemi.html#.istime">istime</a></li><li data-type='method'><a href="wsemi.html#.istimeTZ">istimeTZ</a></li><li data-type='method'><a href="wsemi.html#.istimems">istimems</a></li><li data-type='method'><a href="wsemi.html#.istimemsTZ">istimemsTZ</a></li><li data-type='method'><a href="wsemi.html#.isu16arr">isu16arr</a></li><li data-type='method'><a href="wsemi.html#.isu8arr">isu8arr</a></li><li data-type='method'><a href="wsemi.html#.isundefined">isundefined</a></li><li data-type='method'><a href="wsemi.html#.j2o">j2o</a></li><li data-type='method'><a href="wsemi.html#.keysmat2ltdt">keysmat2ltdt</a></li><li data-type='method'><a href="wsemi.html#.log">log</a></li><li data-type='method'><a href="wsemi.html#.ltdt2vrtsable">ltdt2vrtsable</a></li><li data-type='method'><a href="wsemi.html#.ltdtDiff">ltdtDiff</a></li><li data-type='method'><a href="wsemi.html#.ltdtDiffByKey">ltdtDiffByKey</a></li><li data-type='method'><a href="wsemi.html#.ltdtkeys2mat">ltdtkeys2mat</a></li><li data-type='method'><a href="wsemi.html#.ltdtkeysheads2mat">ltdtkeysheads2mat</a></li><li data-type='method'><a href="wsemi.html#.ltdtmapping">ltdtmapping</a></li><li data-type='method'><a href="wsemi.html#.ltdtmerge">ltdtmerge</a></li><li data-type='method'><a href="wsemi.html#.ltdtpick">ltdtpick</a></li><li data-type='method'><a href="wsemi.html#.ltdtpull">ltdtpull</a></li><li data-type='method'><a href="wsemi.html#.mat2ltdt">mat2ltdt</a></li><li data-type='method'><a href="wsemi.html#.matConcat">matConcat</a></li><li data-type='method'><a href="wsemi.html#.matDiff">matDiff</a></li><li data-type='method'><a href="wsemi.html#.matat">matat</a></li><li data-type='method'><a href="wsemi.html#.now2str">now2str</a></li><li data-type='method'><a href="wsemi.html#.now2strp">now2strp</a></li><li data-type='method'><a href="wsemi.html#.nowDay2str">nowDay2str</a></li><li data-type='method'><a href="wsemi.html#.nowms2str">nowms2str</a></li><li data-type='method'><a href="wsemi.html#.nowms2strp">nowms2strp</a></li><li data-type='method'><a href="wsemi.html#.o2j">o2j</a></li><li data-type='method'><a href="wsemi.html#.obj2b64">obj2b64</a></li><li data-type='method'><a href="wsemi.html#.obj2pb64">obj2pb64</a></li><li data-type='method'><a href="wsemi.html#.obj2str">obj2str</a></li><li data-type='method'><a href="wsemi.html#.obj2stru8arr">obj2stru8arr</a></li><li data-type='method'><a href="wsemi.html#.obj2u8arr">obj2u8arr</a></li><li data-type='method'><a href="wsemi.html#.objSortBy">objSortBy</a></li><li data-type='method'><a href="wsemi.html#.objSortByKeys">objSortByKeys</a></li><li data-type='method'><a href="wsemi.html#.ocr">ocr</a></li><li data-type='method'><a href="wsemi.html#.ocrDyn">ocrDyn</a></li><li data-type='method'><a href="wsemi.html#.oo">oo</a></li><li data-type='method'><a href="wsemi.html#.openLink">openLink</a></li><li data-type='method'><a href="wsemi.html#.pb642obj">pb642obj</a></li><li data-type='method'><a href="wsemi.html#.pmChain">pmChain</a></li><li data-type='method'><a href="wsemi.html#.pmConvertResolve">pmConvertResolve</a></li><li data-type='method'><a href="wsemi.html#.pmHook">pmHook</a></li><li data-type='method'><a href="wsemi.html#.pmHookReject">pmHookReject</a></li><li data-type='method'><a href="wsemi.html#.pmIni">pmIni</a></li><li data-type='method'><a href="wsemi.html#.pmInvResolve">pmInvResolve</a></li><li data-type='method'><a href="wsemi.html#.pmMap">pmMap</a></li><li data-type='method'><a href="wsemi.html#.pmQueue">pmQueue</a></li><li data-type='method'><a href="wsemi.html#.pmSeries">pmSeries</a></li><li data-type='method'><a href="wsemi.html#.pmThrottle">pmThrottle</a></li><li data-type='method'><a href="wsemi.html#.pseudoRandom">pseudoRandom</a></li><li data-type='method'><a href="wsemi.html#.pseudoRandomIntRange">pseudoRandomIntRange</a></li><li data-type='method'><a href="wsemi.html#.pseudoRandomRange">pseudoRandomRange</a></li><li data-type='method'><a href="wsemi.html#.queue">queue</a></li><li data-type='method'><a href="wsemi.html#.rang">rang</a></li><li data-type='method'><a href="wsemi.html#.rep">rep</a></li><li data-type='method'><a href="wsemi.html#.repObj">repObj</a></li><li data-type='method'><a href="wsemi.html#.replace">replace</a></li><li data-type='method'><a href="wsemi.html#.replaceObj">replaceObj</a></li><li data-type='method'><a href="wsemi.html#.replacePlus">replacePlus</a></li><li data-type='method'><a href="wsemi.html#.round">round</a></li><li data-type='method'><a href="wsemi.html#.secd">secd</a></li><li data-type='method'><a href="wsemi.html#.sep">sep</a></li><li data-type='method'><a href="wsemi.html#.sepInt">sepInt</a></li><li data-type='method'><a href="wsemi.html#.sind">sind</a></li><li data-type='method'><a href="wsemi.html#.split">split</a></li><li data-type='method'><a href="wsemi.html#.str2aes">str2aes</a></li><li data-type='method'><a href="wsemi.html#.str2b64">str2b64</a></li><li data-type='method'><a href="wsemi.html#.str2hint">str2hint</a></li><li data-type='method'><a href="wsemi.html#.str2md5">str2md5</a></li><li data-type='method'><a href="wsemi.html#.str2obj">str2obj</a></li><li data-type='method'><a href="wsemi.html#.str2sha512">str2sha512</a></li><li data-type='method'><a href="wsemi.html#.str2u8arr">str2u8arr</a></li><li data-type='method'><a href="wsemi.html#.strCompare">strCompare</a></li><li data-type='method'><a href="wsemi.html#.strDiff">strDiff</a></li><li data-type='method'><a href="wsemi.html#.strFindFuzz">strFindFuzz</a></li><li data-type='method'><a href="wsemi.html#.strFindFuzzDyn">strFindFuzzDyn</a></li><li data-type='method'><a href="wsemi.html#.strFindSimilar">strFindSimilar</a></li><li data-type='method'><a href="wsemi.html#.strdelleft">strdelleft</a></li><li data-type='method'><a href="wsemi.html#.strdelright">strdelright</a></li><li data-type='method'><a href="wsemi.html#.strleft">strleft</a></li><li data-type='method'><a href="wsemi.html#.strmid">strmid</a></li><li data-type='method'><a href="wsemi.html#.strright">strright</a></li><li data-type='method'><a href="wsemi.html#.stru8arr2obj">stru8arr2obj</a></li><li data-type='method'><a href="wsemi.html#.tand">tand</a></li><li data-type='method'><a href="wsemi.html#.time2day">time2day</a></li><li data-type='method'><a href="wsemi.html#.time2hour">time2hour</a></li><li data-type='method'><a href="wsemi.html#.time2min">time2min</a></li><li data-type='method'><a href="wsemi.html#.timeTZ2day">timeTZ2day</a></li><li data-type='method'><a href="wsemi.html#.timeTZ2expire">timeTZ2expire</a></li><li data-type='method'><a href="wsemi.html#.timeTZ2hour">timeTZ2hour</a></li><li data-type='method'><a href="wsemi.html#.timeTZ2min">timeTZ2min</a></li><li data-type='method'><a href="wsemi.html#.timeTZ2past">timeTZ2past</a></li><li data-type='method'><a href="wsemi.html#.timems2day">timems2day</a></li><li data-type='method'><a href="wsemi.html#.timems2hour">timems2hour</a></li><li data-type='method'><a href="wsemi.html#.timems2min">timems2min</a></li><li data-type='method'><a href="wsemi.html#.timems2time">timems2time</a></li><li data-type='method'><a href="wsemi.html#.timemsTZ2day">timemsTZ2day</a></li><li data-type='method'><a href="wsemi.html#.timemsTZ2expire">timemsTZ2expire</a></li><li data-type='method'><a href="wsemi.html#.timemsTZ2hour">timemsTZ2hour</a></li><li data-type='method'><a href="wsemi.html#.timemsTZ2min">timemsTZ2min</a></li><li data-type='method'><a href="wsemi.html#.timemsTZ2past">timemsTZ2past</a></li><li data-type='method'><a href="wsemi.html#.timemsTZ2time">timemsTZ2time</a></li><li data-type='method'><a href="wsemi.html#.treeObj">treeObj</a></li><li data-type='method'><a href="wsemi.html#.treeToFilepath">treeToFilepath</a></li><li data-type='method'><a href="wsemi.html#.trim">trim</a></li><li data-type='method'><a href="wsemi.html#.u16arr2b64">u16arr2b64</a></li><li data-type='method'><a href="wsemi.html#.u16arr2u8arr">u16arr2u8arr</a></li><li data-type='method'><a href="wsemi.html#.u8arr2ab">u8arr2ab</a></li><li data-type='method'><a href="wsemi.html#.u8arr2b64">u8arr2b64</a></li><li data-type='method'><a href="wsemi.html#.u8arr2blob">u8arr2blob</a></li><li data-type='method'><a href="wsemi.html#.u8arr2bs">u8arr2bs</a></li><li data-type='method'><a href="wsemi.html#.u8arr2obj">u8arr2obj</a></li><li data-type='method'><a href="wsemi.html#.u8arr2str">u8arr2str</a></li><li data-type='method'><a href="wsemi.html#.u8arr2u16arr">u8arr2u16arr</a></li><li data-type='method'><a href="wsemi.html#.urlParse">urlParse</a></li><li data-type='method'><a href="wsemi.html#.verifyValue">verifyValue</a></li><li data-type='method'><a href="wsemi.html#.waitFun">waitFun</a></li></ul></li></ul> </nav> <div id="main"> <h1 class="page-title">convertToTree.mjs</h1> <section> <article> <pre class="prettyprint source linenums"><code>import get from 'lodash/get' import isestr from './isestr.mjs' import iseobj from './iseobj.mjs' import isearr from './isearr.mjs' import isbol from './isbol.mjs' import flattenToConn from './flattenToConn.mjs' import composeToTree from './composeToTree.mjs' /** * 展開物件或陣列成為樹狀陣列 * * Unit Test: {@link https://github.com/yuda-lyu/wsemi/blob/master/test/convertToTree.test.mjs Github} * @memberOf wsemi * @param {Array|Object} data 輸入項目物件或陣列 * @param {Object} [opt={}] 輸入設定物件,預設{} * @param {String} [bindKey='id'] 輸入識別用欄位字串,預設'id' * @param {String} [bindParent='parentId'] 輸入存放父節點欄位字串,預設'parentId' * @param {String} [bindText='value'] 輸入存放值欄位字串,預設'value' * @param {String} [bindChildren='children'] 輸入產生樹狀物件時,各節點內存放子節點欄位字串,預設'children' * @param {String} [bindType='type'] 輸入存放值種類欄位字串,預設'type' * @param {String} [bindNumOfChilren='numOfChilren'] 輸入存放值為物件或陣列時所屬子節點數量欄位字串,預設'numOfChilren' * @param {String} [bindRoot='root'] 輸入若為物件時,自動給予根節點鍵值字串,預設'root' * @param {Boolean} [saveExtProps=false] 輸入是否儲存項目物件從屬資訊布林值,預設false * @returns {Array} 回傳樹狀陣列 * @example * * let r * * let obj = { * a: 1, * b: 12.3, * c: 'abc', * d: '45-de', * x: true, * y: null, * z: function() {}, * e: [], * f: [ * 91, * 912.3, * 'abc', * '945-de', * true, * null, * function() {}, * [ * 5, * 54.3, * 'xyz', * ] * ], * g: {}, * h: { * ga: 81, * gb: 812.3, * gc: 'abc', * gd: '845-de', * ge: [ * 71, * 712.3, * 'abc', * '745-de', * true, * null, * function() {}, * ], * gf: { * gfa: 61, * gfb: 612.3, * gfc: 'abc', * gfd: '645-de', * gfe: true, * gff: null, * gfg: function() {}, * }, * gx: true, * gy: null, * gz: function() {}, * }, * i: Symbol('foo'), * [Symbol('i-sym-key-a')]: 'i-sym-value', * [Symbol('i-sym-key-b')]: { * symfa: 61, * symfb: 612.3, * symfc: 'abc', * symfd: '645-de', * symfe: true, * symff: null, * symfg: function() {}, * }, * } * r = convertToTree(obj) * console.log('convertToTree obj', JSON.stringify(r, null, 2)) * // => convertToTree obj [ * // { * // "id": "root", * // "parentId": "", * // "type": "object", * // "key": "root", * // "numOfChilren": 12, * // "children": [ * // { * // "id": "root-a", * // "parentId": "root", * // "type": "node", * // "key": "a", * // "text": 1 * // }, * // { * // "id": "root-b", * // "parentId": "root", * // "type": "node", * // "key": "b", * // "text": 12.3 * // }, * // { * // "id": "root-c", * // "parentId": "root", * // "type": "node", * // "key": "c", * // "text": "abc" * // }, * // { * // "id": "root-d", * // "parentId": "root", * // "type": "node", * // "key": "d", * // "text": "45-de" * // }, * // { * // "id": "root-x", * // "parentId": "root", * // "type": "node", * // "key": "x", * // "text": true * // }, * // { * // "id": "root-y", * // "parentId": "root", * // "type": "node", * // "key": "y", * // "text": null * // }, * // { * // "id": "root-z", * // "parentId": "root", * // "type": "node", * // "key": "z" * // }, * // { * // "id": "root-e", * // "parentId": "root", * // "type": "array", * // "key": "e", * // "numOfChilren": 0 * // }, * // { * // "id": "root-f", * // "parentId": "root", * // "type": "array", * // "key": "f", * // "numOfChilren": 8, * // "children": [ * // { * // "id": "root-f-0", * // "parentId": "root-f", * // "type": "node", * // "key": 0, * // "text": 91 * // }, * // { * // "id": "root-f-1", * // "parentId": "root-f", * // "type": "node", * // "key": 1, * // "text": 912.3 * // }, * // { * // "id": "root-f-2", * // "parentId": "root-f", * // "type": "node", * // "key": 2, * // "text": "abc" * // }, * // { * // "id": "root-f-3", * // "parentId": "root-f", * // "type": "node", * // "key": 3, * // "text": "945-de" * // }, * // { * // "id": "root-f-4", * // "parentId": "root-f", * // "type": "node", * // "key": 4, * // "text": true * // }, * // { * // "id": "root-f-5", * // "parentId": "root-f", * // "type": "node", * // "key": 5, * // "text": null * // }, * // { * // "id": "root-f-6", * // "parentId": "root-f", * // "type": "node", * // "key": 6 * // }, * // { * // "id": "root-f-7", * // "parentId": "root-f", * // "type": "array", * // "key": 7, * // "numOfChilren": 3, * // "children": [ * // { * // "id": "root-f-7-0", * // "parentId": "root-f-7", * // "type": "node", * // "key": 0, * // "text": 5 * // }, * // { * // "id": "root-f-7-1", * // "parentId": "root-f-7", * // "type": "node", * // "key": 1, * // "text": 54.3 * // }, * // { * // "id": "root-f-7-2", * // "parentId": "root-f-7", * // "type": "node", * // "key": 2, * // "text": "xyz" * // } * // ] * // } * // ] * // }, * // { * // "id": "root-g", * // "parentId": "root", * // "type": "object", * // "key": "g", * // "numOfChilren": 0 * // }, * // { * // "id": "root-h", * // "parentId": "root", * // "type": "object", * // "key": "h", * // "numOfChilren": 9, * // "children": [ * // { * // "id": "root-h-ga", * // "parentId": "root-h", * // "type": "node", * // "key": "ga", * // "text": 81 * // }, * // { * // "id": "root-h-gb", * // "parentId": "root-h", * // "type": "node", * // "key": "gb", * // "text": 812.3 * // }, * // { * // "id": "root-h-gc", * // "parentId": "root-h", * // "type": "node", * // "key": "gc", * // "text": "abc" * // }, * // { * // "id": "root-h-gd", * // "parentId": "root-h", * // "type": "node", * // "key": "gd", * // "text": "845-de" * // }, * // { * // "id": "root-h-ge", * // "parentId": "root-h", * // "type": "array", * // "key": "ge", * // "numOfChilren": 7, * // "children": [ * // { * // "id": "root-h-ge-0", * // "parentId": "root-h-ge", * // "type": "node", * // "key": 0, * // "text": 71 * // }, * // { * // "id": "root-h-ge-1", * // "parentId": "root-h-ge", * // "type": "node", * // "key": 1, * // "text": 712.3 * // }, * // { * // "id": "root-h-ge-2", * // "parentId": "root-h-ge", * // "type": "node", * // "key": 2, * // "text": "abc" * // }, * // { * // "id": "root-h-ge-3", * // "parentId": "root-h-ge", * // "type": "node", * // "key": 3, * // "text": "745-de" * // }, * // { * // "id": "root-h-ge-4", * // "parentId": "root-h-ge", * // "type": "node", * // "key": 4, * // "text": true * // }, * // { * // "id": "root-h-ge-5", * // "parentId": "root-h-ge", * // "type": "node", * // "key": 5, * // "text": null * // }, * // { * // "id": "root-h-ge-6", * // "parentId": "root-h-ge", * // "type": "node", * // "key": 6 * // } * // ] * // }, * // { * // "id": "root-h-gf", * // "parentId": "root-h", * // "type": "object", * // "key": "gf", * // "numOfChilren": 7, * // "children": [ * // { * // "id": "root-h-gf-gfa", * // "parentId": "root-h-gf", * // "type": "node", * // "key": "gfa", * // "text": 61 * // }, * // { * // "id": "root-h-gf-gfb", * // "parentId": "root-h-gf", * // "type": "node", * // "key": "gfb", * // "text": 612.3 * // }, * // { * // "id": "root-h-gf-gfc", * // "parentId": "root-h-gf", * // "type": "node", * // "key": "gfc", * // "text": "abc" * // }, * // { * // "id": "root-h-gf-gfd", * // "parentId": "root-h-gf", * // "type": "node", * // "key": "gfd", * // "text": "645-de" * // }, * // { * // "id": "root-h-gf-gfe", * // "parentId": "root-h-gf", * // "type": "node", * // "key": "gfe", * // "text": true * // }, * // { * // "id": "root-h-gf-gff", * // "parentId": "root-h-gf", * // "type": "node", * // "key": "gff", * // "text": null * // }, * // { * // "id": "root-h-gf-gfg", * // "parentId": "root-h-gf", * // "type": "node", * // "key": "gfg" * // } * // ] * // }, * // { * // "id": "root-h-gx", * // "parentId": "root-h", * // "type": "node", * // "key": "gx", * // "text": true * // }, * // { * // "id": "root-h-gy", * // "parentId": "root-h", * // "type": "node", * // "key": "gy", * // "text": null * // }, * // { * // "id": "root-h-gz", * // "parentId": "root-h", * // "type": "node", * // "key": "gz" * // } * // ] * // }, * // { * // "id": "root-i", * // "parentId": "root", * // "type": "node", * // "key": "i" * // }, * // { * // "id": "root-Symbol(i-sym-key-a)", * // "parentId": "root", * // "type": "node", * // "text": "i-sym-value" * // }, * // { * // "id": "root-Symbol(i-sym-key-b)", * // "parentId": "root", * // "type": "object", * // "numOfChilren": 7, * // "children": [ * // { * // "id": "root-Symbol(i-sym-key-b)-symfa", * // "parentId": "root-Symbol(i-sym-key-b)", * // "type": "node", * // "key": "symfa", * // "text": 61 * // }, * // { * // "id": "root-Symbol(i-sym-key-b)-symfb", * // "parentId": "root-Symbol(i-sym-key-b)", * // "type": "node", * // "key": "symfb", * // "text": 612.3 * // }, * // { * // "id": "root-Symbol(i-sym-key-b)-symfc", * // "parentId": "root-Symbol(i-sym-key-b)", * // "type": "node", * // "key": "symfc", * // "text": "abc" * // }, * // { * // "id": "root-Symbol(i-sym-key-b)-symfd", * // "parentId": "root-Symbol(i-sym-key-b)", * // "type": "node", * // "key": "symfd", * // "text": "645-de" * // }, * // { * // "id": "root-Symbol(i-sym-key-b)-symfe", * // "parentId": "root-Symbol(i-sym-key-b)", * // "type": "node", * // "key": "symfe", * // "text": true * // }, * // { * // "id": "root-Symbol(i-sym-key-b)-symff", * // "parentId": "root-Symbol(i-sym-key-b)", * // "type": "node", * // "key": "symff", * // "text": null * // }, * // { * // "id": "root-Symbol(i-sym-key-b)-symfg", * // "parentId": "root-Symbol(i-sym-key-b)", * // "type": "node", * // "key": "symfg" * // } * // ] * // } * // ] * // } * // ] * * let arr = [ * 91, * 912.3, * 'abc', * '945-de', * true, * null, * function() {}, * [ * 5, * 54.3, * 'xyz', * { * gf: { * gfa: 61, * gfb: 612.3, * gfc: 'abc', * gfd: '645-de', * gfe: true, * gff: null, * gfg: function() {}, * }, * }, * ], * { * h: { * ga: 81, * gb: 812.3, * gc: 'abc', * gd: '845-de', * ge: [ * 71, * 712.3, * 'abc', * '745-de', * true, * null, * function() {}, * ], * gx: true, * gy: null, * gz: function() {}, * }, * i: Symbol('foo'), * [Symbol('i-sym-key-a')]: 'i-sym-value', * [Symbol('i-sym-key-b')]: { * symfa: 61, * symfb: 612.3, * symfc: 'abc', * symfd: '645-de', * symfe: true, * symff: null, * symfg: function() {}, * }, * }, * ] * r = convertToTree(arr) * console.log('convertToTree arr', JSON.stringify(r, null, 2)) * // => convertToTree arr [ * // { * // "id": "root", * // "parentId": "", * // "type": "array", * // "key": "root", * // "numOfChilren": 9, * // "children": [ * // { * // "id": "root-0", * // "parentId": "root", * // "type": "node", * // "key": 0, * // "text": 91 * // }, * // { * // "id": "root-1", * // "parentId": "root", * // "type": "node", * // "key": 1, * // "text": 912.3 * // }, * // { * // "id": "root-2", * // "parentId": "root", * // "type": "node", * // "key": 2, * // "text": "abc" * // }, * // { * // "id": "root-3", * // "parentId": "root", * // "type": "node", * // "key": 3, * // "text": "945-de" * // }, * // { * // "id": "root-4", * // "parentId": "root", * // "type": "node", * // "key": 4, * // "text": true * // }, * // { * // "id": "root-5", * // "parentId": "root", * // "type": "node", * // "key": 5, * // "text": null * // }, * // { * // "id": "root-6", * // "parentId": "root", * // "type": "node", * // "key": 6 * // }, * // { * // "id": "root-7", * // "parentId": "root", * // "type": "array", * // "key": 7, * // "numOfChilren": 4, * // "children": [ * // { * // "id": "root-7-0", * // "parentId": "root-7", * // "type": "node", * // "key": 0, * // "text": 5 * // }, * // { * // "id": "root-7-1", * // "parentId": "root-7", * // "type": "node", * // "key": 1, * // "text": 54.3 * // }, * // { * // "id": "root-7-2", * // "parentId": "root-7", * // "type": "node", * // "key": 2, * // "text": "xyz" * // }, * // { * // "id": "root-7-3", * // "parentId": "root-7", * // "type": "object", * // "key": 3, * // "numOfChilren": 1, * // "children": [ * // { * // "id": "root-7-3-gf", * // "parentId": "root-7-3", * // "type": "object", * // "key": "gf", * // "numOfChilren": 7, * // "children": [ * // { * // "id": "root-7-3-gf-gfa", * // "parentId": "root-7-3-gf", * // "type": "node", * // "key": "gfa", * // "text": 61 * // }, * // { * // "id": "root-7-3-gf-gfb", * // "parentId": "root-7-3-gf", * // "type": "node", * // "key": "gfb", * // "text": 612.3 * // }, * // { * // "id": "root-7-3-gf-gfc", * // "parentId": "root-7-3-gf", * // "type": "node", * // "key": "gfc", * // "text": "abc" * // }, * // { * // "id": "root-7-3-gf-gfd", * // "parentId": "root-7-3-gf", * // "type": "node", * // "key": "gfd", * // "text": "645-de" * // }, * // { * // "id": "root-7-3-gf-gfe", * // "parentId": "root-7-3-gf", * // "type": "node", * // "key": "gfe", * // "text": true * // }, * // { * // "id": "root-7-3-gf-gff", * // "parentId": "root-7-3-gf", * // "type": "node", * // "key": "gff", * // "text": null * // }, * // { * // "id": "root-7-3-gf-gfg", * // "parentId": "root-7-3-gf", * // "type": "node", * // "key": "gfg" * // } * // ] * // } * // ] * // } * // ] * // }, * // { * // "id": "root-8", * // "parentId": "root", * // "type": "object", * // "key": 8, * // "numOfChilren": 2, * // "children": [ * // { * // "id": "root-8-h", * // "parentId": "root-8", * // "type": "object", * // "key": "h", * // "numOfChilren": 8, * // "children": [ * // { * // "id": "root-8-h-ga", * // "parentId": "root-8-h", * // "type": "node", * // "key": "ga", * // "text": 81 * // }, * // { * // "id": "root-8-h-gb", * // "parentId": "root-8-h", * // "type": "node", * // "key": "gb", * // "