bajo 2.21.0 → 2.22.0
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.
- package/.jsdoc.conf.json +1 -1
- package/class/app.js +139 -115
- package/class/bajo.js +96 -89
- package/class/base.js +25 -9
- package/class/cache.js +32 -19
- package/class/err.js +11 -9
- package/class/log.js +102 -52
- package/class/plugin.js +45 -35
- package/class/print.js +45 -44
- package/class/tools.js +7 -1
- package/docs/App.html +1 -23
- package/docs/Bajo.html +1 -6
- package/docs/Base.html +1 -1
- package/docs/Cache.html +1 -1
- package/docs/Err.html +2 -2
- package/docs/Log.html +4 -4
- package/docs/Plugin.html +1 -1
- package/docs/Print.html +1 -1
- package/docs/Tools.html +1 -1
- package/docs/class_app.js.html +141 -117
- package/docs/class_bajo.js.html +98 -91
- package/docs/class_base.js.html +27 -11
- package/docs/class_cache.js.html +34 -21
- package/docs/class_err.js.html +13 -11
- package/docs/class_log.js.html +104 -54
- package/docs/class_plugin.js.html +47 -37
- package/docs/class_print.js.html +47 -46
- package/docs/class_tools.js.html +9 -3
- package/docs/data/search.json +1 -1
- package/docs/global.html +1 -1
- package/docs/index.html +1 -1
- package/docs/index.js.html +8 -4
- package/docs/{class__helper.js.html → lib_helper.js.html} +208 -96
- package/docs/lib_hook.js.html +231 -0
- package/docs/module-Helper.html +8 -1
- package/docs/module-Hook.html +3 -0
- package/docs/module-Lib.html +1 -8
- package/index.js +6 -2
- package/{class/_helper.js → lib/helper.js} +206 -94
- package/lib/hook.js +228 -0
- package/package.json +1 -1
- package/wiki/CHANGES.md +10 -0
- package/docs/class_helper_bajo.js.html +0 -398
- package/docs/class_helper_base.js.html +0 -246
- package/docs/class_misc_err.js.html +0 -129
- package/docs/class_misc_log.js.html +0 -210
- package/docs/class_misc_print.js.html +0 -267
- package/docs/lib_current-loc.js.html +0 -36
- package/docs/lib_find-deep.js.html +0 -27
- package/docs/lib_formats.js.html +0 -68
- package/docs/lib_freeze.js.html +0 -54
- package/docs/lib_import-module.js.html +0 -61
- package/docs/lib_index.js.html +0 -9
- package/docs/lib_log-levels.js.html +0 -38
- package/docs/lib_parse-args-argv.js.html +0 -83
- package/docs/lib_parse-env.js.html +0 -53
- package/docs/lib_resolve-path.js.html +0 -27
- package/docs/lib_shim.js.html +0 -40
- package/docs/module-Helper_Bajo.html +0 -3
- package/docs/module-Helper_Base.html +0 -3
- package/lib/find-deep.js +0 -24
- package/lib/formats.js +0 -65
- package/lib/freeze.js +0 -51
- package/lib/import-module.js +0 -58
- package/lib/index.js +0 -6
- package/lib/log-levels.js +0 -35
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
<!DOCTYPE html><html lang="en" style="font-size:16px"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Source:
|
|
1
|
+
<!DOCTYPE html><html lang="en" style="font-size:16px"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Source: lib/helper.js</title><!--[if lt IE 9]>
|
|
2
2
|
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
|
3
|
-
<![endif]--><script src="scripts/third-party/hljs.js" defer="defer"></script><script src="scripts/third-party/hljs-line-num.js" defer="defer"></script><script src="scripts/third-party/popper.js" defer="defer"></script><script src="scripts/third-party/tippy.js" defer="defer"></script><script src="scripts/third-party/tocbot.min.js"></script><script>var baseURL="/",locationPathname="";baseURL=(locationPathname=document.location.pathname).substr(0,locationPathname.lastIndexOf("/")+1)</script><link rel="stylesheet" href="styles/clean-jsdoc-theme.min.css"><svg aria-hidden="true" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="display:none"><defs><symbol id="copy-icon" viewbox="0 0 488.3 488.3"><g><path d="M314.25,85.4h-227c-21.3,0-38.6,17.3-38.6,38.6v325.7c0,21.3,17.3,38.6,38.6,38.6h227c21.3,0,38.6-17.3,38.6-38.6V124 C352.75,102.7,335.45,85.4,314.25,85.4z M325.75,449.6c0,6.4-5.2,11.6-11.6,11.6h-227c-6.4,0-11.6-5.2-11.6-11.6V124 c0-6.4,5.2-11.6,11.6-11.6h227c6.4,0,11.6,5.2,11.6,11.6V449.6z"/><path d="M401.05,0h-227c-21.3,0-38.6,17.3-38.6,38.6c0,7.5,6,13.5,13.5,13.5s13.5-6,13.5-13.5c0-6.4,5.2-11.6,11.6-11.6h227 c6.4,0,11.6,5.2,11.6,11.6v325.7c0,6.4-5.2,11.6-11.6,11.6c-7.5,0-13.5,6-13.5,13.5s6,13.5,13.5,13.5c21.3,0,38.6-17.3,38.6-38.6 V38.6C439.65,17.3,422.35,0,401.05,0z"/></g></symbol><symbol id="search-icon" viewBox="0 0 512 512"><g><g><path d="M225.474,0C101.151,0,0,101.151,0,225.474c0,124.33,101.151,225.474,225.474,225.474 c124.33,0,225.474-101.144,225.474-225.474C450.948,101.151,349.804,0,225.474,0z M225.474,409.323 c-101.373,0-183.848-82.475-183.848-183.848S124.101,41.626,225.474,41.626s183.848,82.475,183.848,183.848 S326.847,409.323,225.474,409.323z"/></g></g><g><g><path d="M505.902,476.472L386.574,357.144c-8.131-8.131-21.299-8.131-29.43,0c-8.131,8.124-8.131,21.306,0,29.43l119.328,119.328 c4.065,4.065,9.387,6.098,14.715,6.098c5.321,0,10.649-2.033,14.715-6.098C514.033,497.778,514.033,484.596,505.902,476.472z"/></g></g></symbol><symbol id="font-size-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M11.246 15H4.754l-2 5H.6L7 4h2l6.4 16h-2.154l-2-5zm-.8-2L8 6.885 5.554 13h4.892zM21 12.535V12h2v8h-2v-.535a4 4 0 1 1 0-6.93zM19 18a2 2 0 1 0 0-4 2 2 0 0 0 0 4z"/></symbol><symbol id="add-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M11 11V5h2v6h6v2h-6v6h-2v-6H5v-2z"/></symbol><symbol id="minus-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M5 11h14v2H5z"/></symbol><symbol id="dark-theme-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M10 7a7 7 0 0 0 12 4.9v.1c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2h.1A6.979 6.979 0 0 0 10 7zm-6 5a8 8 0 0 0 15.062 3.762A9 9 0 0 1 8.238 4.938 7.999 7.999 0 0 0 4 12z"/></symbol><symbol id="light-theme-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 18a6 6 0 1 1 0-12 6 6 0 0 1 0 12zm0-2a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM11 1h2v3h-2V1zm0 19h2v3h-2v-3zM3.515 4.929l1.414-1.414L7.05 5.636 5.636 7.05 3.515 4.93zM16.95 18.364l1.414-1.414 2.121 2.121-1.414 1.414-2.121-2.121zm2.121-14.85l1.414 1.415-2.121 2.121-1.414-1.414 2.121-2.121zM5.636 16.95l1.414 1.414-2.121 2.121-1.414-1.414 2.121-2.121zM23 11v2h-3v-2h3zM4 11v2H1v-2h3z"/></symbol><symbol id="reset-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M18.537 19.567A9.961 9.961 0 0 1 12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10c0 2.136-.67 4.116-1.81 5.74L17 12h3a8 8 0 1 0-2.46 5.772l.997 1.795z"/></symbol><symbol id="down-icon" viewBox="0 0 16 16"><path fill-rule="evenodd" clip-rule="evenodd" d="M12.7803 6.21967C13.0732 6.51256 13.0732 6.98744 12.7803 7.28033L8.53033 11.5303C8.23744 11.8232 7.76256 11.8232 7.46967 11.5303L3.21967 7.28033C2.92678 6.98744 2.92678 6.51256 3.21967 6.21967C3.51256 5.92678 3.98744 5.92678 4.28033 6.21967L8 9.93934L11.7197 6.21967C12.0126 5.92678 12.4874 5.92678 12.7803 6.21967Z"></path></symbol><symbol id="codepen-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M16.5 13.202L13 15.535v3.596L19.197 15 16.5 13.202zM14.697 12L12 10.202 9.303 12 12 13.798 14.697 12zM20 10.869L18.303 12 20 13.131V10.87zM19.197 9L13 4.869v3.596l3.5 2.333L19.197 9zM7.5 10.798L11 8.465V4.869L4.803 9 7.5 10.798zM4.803 15L11 19.131v-3.596l-3.5-2.333L4.803 15zM4 13.131L5.697 12 4 10.869v2.262zM2 9a1 1 0 0 1 .445-.832l9-6a1 1 0 0 1 1.11 0l9 6A1 1 0 0 1 22 9v6a1 1 0 0 1-.445.832l-9 6a1 1 0 0 1-1.11 0l-9-6A1 1 0 0 1 2 15V9z"/></symbol><symbol id="close-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 10.586l4.95-4.95 1.414 1.414-4.95 4.95 4.95 4.95-1.414 1.414-4.95-4.95-4.95 4.95-1.414-1.414 4.95-4.95-4.95-4.95L7.05 5.636z"/></symbol><symbol id="menu-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M3 4h18v2H3V4zm0 7h18v2H3v-2zm0 7h18v2H3v-2z"/></symbol></defs></svg></head><body data-theme="light"><div class="sidebar-container"><div class="sidebar" id="sidebar"><a href="/" class="sidebar-title sidebar-title-anchor">Bajo API</a><div class="sidebar-items-container"><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-classes"><div>Classes</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="App.html">App</a></div><div class="sidebar-section-children"><a href="Bajo.html">Bajo</a></div><div class="sidebar-section-children"><a href="Base.html">Base</a></div><div class="sidebar-section-children"><a href="Cache.html">Cache</a></div><div class="sidebar-section-children"><a href="Err.html">Err</a></div><div class="sidebar-section-children"><a href="Log.html">Log</a></div><div class="sidebar-section-children"><a href="Plugin.html">Plugin</a></div><div class="sidebar-section-children"><a href="Print.html">Print</a></div><div class="sidebar-section-children"><a href="Tools.html">Tools</a></div></div><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-events"><div>Events</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="global.html#event:bajo:afterAll%257Bmethod%257D">bajo:afterAll{method}</a></div><div class="sidebar-section-children"><a href="global.html#event:bajo:afterBootComplete">bajo:afterBootComplete</a></div><div class="sidebar-section-children"><a href="global.html#event:bajo:afterBuildCollection">bajo:afterBuildCollection</a></div><div class="sidebar-section-children"><a href="global.html#event:bajo:afterCollectHooks">bajo:afterCollectHooks</a></div><div class="sidebar-section-children"><a href="global.html#event:bajo:beforeAll%257Bmethod%257D">bajo:beforeAll{method}</a></div><div class="sidebar-section-children"><a href="global.html#event:bajo:beforeBuildCollection">bajo:beforeBuildCollection</a></div><div class="sidebar-section-children"><a href="global.html#event:%257Bns%257D:after%257Bmethod%257D">{ns}:after{method}</a></div><div class="sidebar-section-children"><a href="global.html#event:%257Bns%257D:beforeAppletRun">{ns}:beforeAppletRun</a></div><div class="sidebar-section-children"><a href="global.html#event:%257Bns%257D:before%257Bmethod%257D">{ns}:before{method}</a></div><div class="sidebar-section-children"><a href="module-Helper%257Bns%257D_afterAppletRun.html">Helper{ns}:afterAppletRun</a></div></div><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-modules"><div>Modules</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="module-Helper.html">Helper</a></div><div class="sidebar-section-children"><a href="module-Lib.html">Lib</a></div></div><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-global"><div>Global</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="global.html#TAppConfigHandler">TAppConfigHandler</a></div><div class="sidebar-section-children"><a href="global.html#TAppEnv">TAppEnv</a></div><div class="sidebar-section-children"><a href="global.html#TBajoDataType">TBajoDataType</a></div><div class="sidebar-section-children"><a href="global.html#TBajoFormatResult">TBajoFormatResult</a></div><div class="sidebar-section-children"><a href="global.html#TBajoFormatType">TBajoFormatType</a></div><div class="sidebar-section-children"><a href="global.html#TLogJson">TLogJson</a></div><div class="sidebar-section-children"><a href="global.html#TLogLevels">TLogLevels</a></div><div class="sidebar-section-children"><a href="global.html#TNsPathPairs">TNsPathPairs</a></div><div class="sidebar-section-children"><a href="global.html#TNsPathResult">TNsPathResult</a></div><div class="sidebar-section-children"><a href="global.html#TPrintOptions">TPrintOptions</a></div><div class="sidebar-section-children"><a href="global.html#boot">boot</a></div></div></div></div></div><div class="navbar-container" id="VuAckcnZhf"><nav class="navbar"><div class="navbar-left-items"><div class="navbar-item"><a id="" href="https://www.npmjs.com/package/bajo" target="">NPM</a></div><div class="navbar-item"><a id="" href="https://github.com/ardhi/bajo" target="">Github</a></div><div class="navbar-item"><a id="" href="https://bajo.app" target="">Bajo</a></div></div><div class="navbar-right-items"><div class="navbar-right-item"><button class="icon-button search-button" aria-label="open-search"><svg><use xlink:href="#search-icon"></use></svg></button></div><div class="navbar-right-item"><button class="icon-button theme-toggle" aria-label="toggle-theme"><svg><use class="theme-svg-use" xlink:href="#dark-theme-icon"></use></svg></button></div><div class="navbar-right-item"><button class="icon-button font-size" aria-label="change-font-size"><svg><use xlink:href="#font-size-icon"></use></svg></button></div></div><nav></nav></nav></div><div class="toc-container"><div class="toc-content"><span class="bold">On this page</span><div id="eed4d2a0bfd64539bb9df78095dec881"></div></div></div><div class="body-wrapper"><div class="main-content"><div class="main-wrapper"><section id="source-page" class="source-page"><header><h1 id="title" class="has-anchor">class__helper.js</h1></header><article><pre class="prettyprint source lang-js"><code>import Print from './print.js'
|
|
4
|
-
import Log from '
|
|
3
|
+
<![endif]--><script src="scripts/third-party/hljs.js" defer="defer"></script><script src="scripts/third-party/hljs-line-num.js" defer="defer"></script><script src="scripts/third-party/popper.js" defer="defer"></script><script src="scripts/third-party/tippy.js" defer="defer"></script><script src="scripts/third-party/tocbot.min.js"></script><script>var baseURL="/",locationPathname="";baseURL=(locationPathname=document.location.pathname).substr(0,locationPathname.lastIndexOf("/")+1)</script><link rel="stylesheet" href="styles/clean-jsdoc-theme.min.css"><svg aria-hidden="true" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="display:none"><defs><symbol id="copy-icon" viewbox="0 0 488.3 488.3"><g><path d="M314.25,85.4h-227c-21.3,0-38.6,17.3-38.6,38.6v325.7c0,21.3,17.3,38.6,38.6,38.6h227c21.3,0,38.6-17.3,38.6-38.6V124 C352.75,102.7,335.45,85.4,314.25,85.4z M325.75,449.6c0,6.4-5.2,11.6-11.6,11.6h-227c-6.4,0-11.6-5.2-11.6-11.6V124 c0-6.4,5.2-11.6,11.6-11.6h227c6.4,0,11.6,5.2,11.6,11.6V449.6z"/><path d="M401.05,0h-227c-21.3,0-38.6,17.3-38.6,38.6c0,7.5,6,13.5,13.5,13.5s13.5-6,13.5-13.5c0-6.4,5.2-11.6,11.6-11.6h227 c6.4,0,11.6,5.2,11.6,11.6v325.7c0,6.4-5.2,11.6-11.6,11.6c-7.5,0-13.5,6-13.5,13.5s6,13.5,13.5,13.5c21.3,0,38.6-17.3,38.6-38.6 V38.6C439.65,17.3,422.35,0,401.05,0z"/></g></symbol><symbol id="search-icon" viewBox="0 0 512 512"><g><g><path d="M225.474,0C101.151,0,0,101.151,0,225.474c0,124.33,101.151,225.474,225.474,225.474 c124.33,0,225.474-101.144,225.474-225.474C450.948,101.151,349.804,0,225.474,0z M225.474,409.323 c-101.373,0-183.848-82.475-183.848-183.848S124.101,41.626,225.474,41.626s183.848,82.475,183.848,183.848 S326.847,409.323,225.474,409.323z"/></g></g><g><g><path d="M505.902,476.472L386.574,357.144c-8.131-8.131-21.299-8.131-29.43,0c-8.131,8.124-8.131,21.306,0,29.43l119.328,119.328 c4.065,4.065,9.387,6.098,14.715,6.098c5.321,0,10.649-2.033,14.715-6.098C514.033,497.778,514.033,484.596,505.902,476.472z"/></g></g></symbol><symbol id="font-size-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M11.246 15H4.754l-2 5H.6L7 4h2l6.4 16h-2.154l-2-5zm-.8-2L8 6.885 5.554 13h4.892zM21 12.535V12h2v8h-2v-.535a4 4 0 1 1 0-6.93zM19 18a2 2 0 1 0 0-4 2 2 0 0 0 0 4z"/></symbol><symbol id="add-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M11 11V5h2v6h6v2h-6v6h-2v-6H5v-2z"/></symbol><symbol id="minus-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M5 11h14v2H5z"/></symbol><symbol id="dark-theme-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M10 7a7 7 0 0 0 12 4.9v.1c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2h.1A6.979 6.979 0 0 0 10 7zm-6 5a8 8 0 0 0 15.062 3.762A9 9 0 0 1 8.238 4.938 7.999 7.999 0 0 0 4 12z"/></symbol><symbol id="light-theme-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 18a6 6 0 1 1 0-12 6 6 0 0 1 0 12zm0-2a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM11 1h2v3h-2V1zm0 19h2v3h-2v-3zM3.515 4.929l1.414-1.414L7.05 5.636 5.636 7.05 3.515 4.93zM16.95 18.364l1.414-1.414 2.121 2.121-1.414 1.414-2.121-2.121zm2.121-14.85l1.414 1.415-2.121 2.121-1.414-1.414 2.121-2.121zM5.636 16.95l1.414 1.414-2.121 2.121-1.414-1.414 2.121-2.121zM23 11v2h-3v-2h3zM4 11v2H1v-2h3z"/></symbol><symbol id="reset-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M18.537 19.567A9.961 9.961 0 0 1 12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10c0 2.136-.67 4.116-1.81 5.74L17 12h3a8 8 0 1 0-2.46 5.772l.997 1.795z"/></symbol><symbol id="down-icon" viewBox="0 0 16 16"><path fill-rule="evenodd" clip-rule="evenodd" d="M12.7803 6.21967C13.0732 6.51256 13.0732 6.98744 12.7803 7.28033L8.53033 11.5303C8.23744 11.8232 7.76256 11.8232 7.46967 11.5303L3.21967 7.28033C2.92678 6.98744 2.92678 6.51256 3.21967 6.21967C3.51256 5.92678 3.98744 5.92678 4.28033 6.21967L8 9.93934L11.7197 6.21967C12.0126 5.92678 12.4874 5.92678 12.7803 6.21967Z"></path></symbol><symbol id="codepen-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M16.5 13.202L13 15.535v3.596L19.197 15 16.5 13.202zM14.697 12L12 10.202 9.303 12 12 13.798 14.697 12zM20 10.869L18.303 12 20 13.131V10.87zM19.197 9L13 4.869v3.596l3.5 2.333L19.197 9zM7.5 10.798L11 8.465V4.869L4.803 9 7.5 10.798zM4.803 15L11 19.131v-3.596l-3.5-2.333L4.803 15zM4 13.131L5.697 12 4 10.869v2.262zM2 9a1 1 0 0 1 .445-.832l9-6a1 1 0 0 1 1.11 0l9 6A1 1 0 0 1 22 9v6a1 1 0 0 1-.445.832l-9 6a1 1 0 0 1-1.11 0l-9-6A1 1 0 0 1 2 15V9z"/></symbol><symbol id="close-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 10.586l4.95-4.95 1.414 1.414-4.95 4.95 4.95 4.95-1.414 1.414-4.95-4.95-4.95 4.95-1.414-1.414 4.95-4.95-4.95-4.95L7.05 5.636z"/></symbol><symbol id="menu-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M3 4h18v2H3V4zm0 7h18v2H3v-2zm0 7h18v2H3v-2z"/></symbol></defs></svg></head><body data-theme="light"><div class="sidebar-container"><div class="sidebar" id="sidebar"><a href="/" class="sidebar-title sidebar-title-anchor">Bajo API</a><div class="sidebar-items-container"><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-classes"><div>Classes</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="App.html">App</a></div><div class="sidebar-section-children"><a href="Bajo.html">Bajo</a></div><div class="sidebar-section-children"><a href="Base.html">Base</a></div><div class="sidebar-section-children"><a href="Cache.html">Cache</a></div><div class="sidebar-section-children"><a href="Err.html">Err</a></div><div class="sidebar-section-children"><a href="Log.html">Log</a></div><div class="sidebar-section-children"><a href="Plugin.html">Plugin</a></div><div class="sidebar-section-children"><a href="Print.html">Print</a></div><div class="sidebar-section-children"><a href="Tools.html">Tools</a></div></div><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-modules"><div>Modules</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="module-Helper.html">Helper</a></div><div class="sidebar-section-children"><a href="module-Hook.html">Hook</a></div></div><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-global"><div>Global</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="global.html#boot">boot</a></div></div></div></div></div><div class="navbar-container" id="VuAckcnZhf"><nav class="navbar"><div class="navbar-left-items"><div class="navbar-item"><a id="" href="https://www.npmjs.com/package/bajo" target="">NPM</a></div><div class="navbar-item"><a id="" href="https://github.com/ardhi/bajo" target="">Github</a></div><div class="navbar-item"><a id="" href="https://bajo.app" target="">Bajo</a></div></div><div class="navbar-right-items"><div class="navbar-right-item"><button class="icon-button search-button" aria-label="open-search"><svg><use xlink:href="#search-icon"></use></svg></button></div><div class="navbar-right-item"><button class="icon-button theme-toggle" aria-label="toggle-theme"><svg><use class="theme-svg-use" xlink:href="#dark-theme-icon"></use></svg></button></div><div class="navbar-right-item"><button class="icon-button font-size" aria-label="change-font-size"><svg><use xlink:href="#font-size-icon"></use></svg></button></div></div><nav></nav></nav></div><div class="toc-container"><div class="toc-content"><span class="bold">On this page</span><div id="eed4d2a0bfd64539bb9df78095dec881"></div></div></div><div class="body-wrapper"><div class="main-content"><div class="main-wrapper"><section id="source-page" class="source-page"><header><h1 id="title" class="has-anchor">lib_helper.js</h1></header><article><pre class="prettyprint source lang-js"><code>import Print from '../class/print.js'
|
|
4
|
+
import Log from '../class/log.js'
|
|
5
5
|
import os from 'os'
|
|
6
6
|
import fs from 'fs-extra'
|
|
7
7
|
import lodash from 'lodash'
|
|
@@ -15,8 +15,12 @@ import utc from 'dayjs/plugin/utc.js'
|
|
|
15
15
|
import customParseFormat from 'dayjs/plugin/customParseFormat.js'
|
|
16
16
|
import localizedFormat from 'dayjs/plugin/localizedFormat.js'
|
|
17
17
|
import weekOfYear from 'dayjs/plugin/weekOfYear.js'
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
const { resolvePath } = aneka
|
|
19
|
+
const {
|
|
20
|
+
isFunction, isPlainObject, cloneDeep, merge, forOwn, groupBy, find, reduce, map,
|
|
21
|
+
trim, keys, intersection, each, camelCase, get, orderBy, pick, values, set,
|
|
22
|
+
without, uniq, isEmpty
|
|
23
|
+
} = lodash
|
|
20
24
|
|
|
21
25
|
/**
|
|
22
26
|
* Internal helpers called by Bajo and other classes. It should remains
|
|
@@ -25,11 +29,6 @@ import findDeep from '../lib/find-deep.js'
|
|
|
25
29
|
* @module Helper
|
|
26
30
|
*/
|
|
27
31
|
|
|
28
|
-
const {
|
|
29
|
-
merge, forOwn, groupBy, find, reduce, map, trim, keys, intersection, each,
|
|
30
|
-
camelCase, get, orderBy, isFunction, isPlainObject, pick, values, set, without, uniq, isEmpty
|
|
31
|
-
} = lodash
|
|
32
|
-
|
|
33
32
|
const omitted = ['spawn', 'cwd', 'name', 'alias', 'applet', 'a', 'plugins']
|
|
34
33
|
|
|
35
34
|
const defConfig = {
|
|
@@ -106,7 +105,7 @@ const defMain = `async function factory (pkgName) {
|
|
|
106
105
|
export default factory
|
|
107
106
|
`
|
|
108
107
|
|
|
109
|
-
|
|
108
|
+
function outmatchNs (source, pattern) {
|
|
110
109
|
const { breakNsPath } = this.bajo
|
|
111
110
|
const [src, subSrc] = source.split(':')
|
|
112
111
|
if (!subSrc) return pattern === src
|
|
@@ -119,7 +118,7 @@ export function outmatchNs (source, pattern) {
|
|
|
119
118
|
}
|
|
120
119
|
}
|
|
121
120
|
|
|
122
|
-
|
|
121
|
+
function parseObject (obj, options = {}) {
|
|
123
122
|
const me = this
|
|
124
123
|
const { ns = 'bajo', lang } = options
|
|
125
124
|
options.translator = {
|
|
@@ -140,7 +139,8 @@ dayjs.extend(localizedFormat)
|
|
|
140
139
|
dayjs.extend(weekOfYear)
|
|
141
140
|
|
|
142
141
|
/**
|
|
143
|
-
* @typedef {Object}
|
|
142
|
+
* @typedef {Object} TLib
|
|
143
|
+
* @memberof App
|
|
144
144
|
* @property {Object} _ Access to {@link https://lodash.com|lodash}.
|
|
145
145
|
* @property {Object} fs Access to {@link https://github.com/jprichardson/node-fs-extra|fs-extra}.
|
|
146
146
|
* @property {Object} fastGlob Access to {@link https://github.com/mrmlnc/fast-glob|fast-glob}.
|
|
@@ -161,7 +161,9 @@ export const lib = {
|
|
|
161
161
|
dayjs,
|
|
162
162
|
aneka,
|
|
163
163
|
freeze,
|
|
164
|
-
findDeep
|
|
164
|
+
findDeep,
|
|
165
|
+
outmatchNs,
|
|
166
|
+
parseObject
|
|
165
167
|
}
|
|
166
168
|
|
|
167
169
|
/**
|
|
@@ -174,7 +176,6 @@ export const lib = {
|
|
|
174
176
|
*
|
|
175
177
|
* @async
|
|
176
178
|
* @method
|
|
177
|
-
* @memberof module:Helper
|
|
178
179
|
*/
|
|
179
180
|
export async function buildBaseConfig () {
|
|
180
181
|
// dirs
|
|
@@ -216,7 +217,6 @@ export async function buildBaseConfig () {
|
|
|
216
217
|
* - attach these plugins to the app instance
|
|
217
218
|
*
|
|
218
219
|
* @async
|
|
219
|
-
* @memberof module:Helper
|
|
220
220
|
*/
|
|
221
221
|
export async function buildPlugins () {
|
|
222
222
|
const { resolvePath } = this.app.lib.aneka
|
|
@@ -250,7 +250,6 @@ export async function buildPlugins () {
|
|
|
250
250
|
* Collect all config handlers, including the one provided by plugins
|
|
251
251
|
*
|
|
252
252
|
* @async
|
|
253
|
-
* @memberof module:Helper
|
|
254
253
|
*/
|
|
255
254
|
export async function collectConfigHandlers () {
|
|
256
255
|
for (const pkg of this.app.pluginPkgs) {
|
|
@@ -276,7 +275,6 @@ export async function collectConfigHandlers () {
|
|
|
276
275
|
* - Set environment (```dev``` or ```prod```)
|
|
277
276
|
*
|
|
278
277
|
* @async
|
|
279
|
-
* @memberof module:Helper
|
|
280
278
|
*/
|
|
281
279
|
export async function buildExtConfig () {
|
|
282
280
|
// config merging
|
|
@@ -327,7 +325,6 @@ export async function buildExtConfig () {
|
|
|
327
325
|
* Setup plugins boot orders by reading plugin's ```.bootorder``` file if provided.
|
|
328
326
|
*
|
|
329
327
|
* @async
|
|
330
|
-
* @memberof module:Helper
|
|
331
328
|
*/
|
|
332
329
|
export async function bootOrder () {
|
|
333
330
|
const { freeze } = this.app.lib
|
|
@@ -356,7 +353,6 @@ export async function bootOrder () {
|
|
|
356
353
|
* Build configurations
|
|
357
354
|
*
|
|
358
355
|
* @async
|
|
359
|
-
* @memberof module:Helper
|
|
360
356
|
*/
|
|
361
357
|
export async function buildConfigs () {
|
|
362
358
|
this.bajo.log.debug('readConfigs')
|
|
@@ -371,7 +367,6 @@ export async function buildConfigs () {
|
|
|
371
367
|
* Ensure for names and aliases to be unique and no clashes with other plugins
|
|
372
368
|
*
|
|
373
369
|
* @async
|
|
374
|
-
* @memberof module:Helper
|
|
375
370
|
*/
|
|
376
371
|
export async function checkNameAliases () {
|
|
377
372
|
this.bajo.log.debug('checkAliasNameClash')
|
|
@@ -391,7 +386,6 @@ export async function checkNameAliases () {
|
|
|
391
386
|
* Ensure dependencies are met
|
|
392
387
|
*
|
|
393
388
|
* @async
|
|
394
|
-
* @memberof module:Helper
|
|
395
389
|
*/
|
|
396
390
|
export async function checkDependencies () {
|
|
397
391
|
const { join } = this.bajo
|
|
@@ -427,8 +421,6 @@ export async function checkDependencies () {
|
|
|
427
421
|
* Collect and build hooks and push them to the bajo's hook system
|
|
428
422
|
*
|
|
429
423
|
* @async
|
|
430
|
-
* @memberof module:Helper
|
|
431
|
-
* @fires bajo:afterCollectHooks
|
|
432
424
|
*/
|
|
433
425
|
export async function collectHooks () {
|
|
434
426
|
const { eachPlugins, runHook, isLogInRange, importModule } = this.bajo
|
|
@@ -472,15 +464,6 @@ export async function collectHooks () {
|
|
|
472
464
|
})
|
|
473
465
|
}
|
|
474
466
|
|
|
475
|
-
/**
|
|
476
|
-
* Run after hooks are collected
|
|
477
|
-
*
|
|
478
|
-
* @global
|
|
479
|
-
* @event bajo:afterCollectHooks
|
|
480
|
-
* @param {Object[]} hooks - Array of hook objects
|
|
481
|
-
* @see {@tutorial hook}
|
|
482
|
-
* @see module:Helper/Base.collectHooks
|
|
483
|
-
*/
|
|
484
467
|
await runHook('bajo:afterCollectHooks', this.bajo.hooks)
|
|
485
468
|
me.bajo.log.debug('collected%s%d', this.t('hooks'), me.bajo.hooks.length)
|
|
486
469
|
}
|
|
@@ -489,11 +472,14 @@ export async function collectHooks () {
|
|
|
489
472
|
* Finally, run all plugins
|
|
490
473
|
*
|
|
491
474
|
* @async
|
|
492
|
-
* @
|
|
493
|
-
* @
|
|
494
|
-
* @
|
|
495
|
-
* @
|
|
496
|
-
* @
|
|
475
|
+
* @see module:Hook~bajo:beforeAllInit
|
|
476
|
+
* @see module:Hook~{ns}:beforeInit
|
|
477
|
+
* @see module:Hook~{ns}:afterInit
|
|
478
|
+
* @see module:Hook~bajo:afterAllInit
|
|
479
|
+
* @see module:Hook~bajo:beforeAllStart
|
|
480
|
+
* @see module:Hook~{ns}:beforeStart
|
|
481
|
+
* @see module:Hook~{ns}:afterStart
|
|
482
|
+
* @see module:Hook~bajo:afterAllStart
|
|
497
483
|
*/
|
|
498
484
|
export async function run () {
|
|
499
485
|
const me = this
|
|
@@ -502,49 +488,14 @@ export async function run () {
|
|
|
502
488
|
const methods = ['init']
|
|
503
489
|
if (!me.applet) methods.push('start')
|
|
504
490
|
for (const method of methods) {
|
|
505
|
-
/**
|
|
506
|
-
* Run before all ```{method}``` executed. Accepted ```{method}```: ```Init``` or ```Start```
|
|
507
|
-
*
|
|
508
|
-
* @global
|
|
509
|
-
* @event bajo:beforeAll{method}
|
|
510
|
-
* @param {string} method - Accepted methods: ```Init```, ```Start```
|
|
511
|
-
* @see module:Helper/Base.run
|
|
512
|
-
*/
|
|
513
491
|
await runHook(`bajo:${camelCase(`before all ${method}`)}`)
|
|
514
492
|
await eachPlugins(async function () {
|
|
515
493
|
const { ns } = this
|
|
516
|
-
/**
|
|
517
|
-
* Run before ```{method}``` is executed within ```{ns}``` context
|
|
518
|
-
*
|
|
519
|
-
* - ```{ns}``` - namespace
|
|
520
|
-
* - ```{method}``` - Accepted methods: ```Init``` or ```Start```
|
|
521
|
-
*
|
|
522
|
-
* @global
|
|
523
|
-
* @event {ns}:before{method}
|
|
524
|
-
* @see module:Helper/Base.run
|
|
525
|
-
*/
|
|
526
494
|
await runHook(`${ns}:${camelCase(`before ${method}`)}`)
|
|
527
495
|
await me[ns][method]()
|
|
528
|
-
/**
|
|
529
|
-
* Run after ```{method}``` is executed within ```{ns}``` context
|
|
530
|
-
*
|
|
531
|
-
* - ```{ns}``` - namespace
|
|
532
|
-
* - ```{method}``` - Accepted methods: ```Init``` or ```Start```
|
|
533
|
-
*
|
|
534
|
-
* @global
|
|
535
|
-
* @event {ns}:after{method}
|
|
536
|
-
* @see module:Helper/Base.run
|
|
537
|
-
*/
|
|
538
496
|
await runHook(`${ns}:${camelCase(`after ${method}`)}`)
|
|
539
497
|
if (method === 'start') freeze(me[ns].config)
|
|
540
498
|
})
|
|
541
|
-
/**
|
|
542
|
-
* Run after all ```{method}``` executed. Accepted ```{method}```: ```Init``` or ```Start```
|
|
543
|
-
*
|
|
544
|
-
* @global
|
|
545
|
-
* @event bajo:afterAll{method}
|
|
546
|
-
* @see module:Helper/Base.run
|
|
547
|
-
*/
|
|
548
499
|
await runHook(`bajo:${camelCase(`after all ${method}`)}`)
|
|
549
500
|
}
|
|
550
501
|
if (me.bajo.config.log.level === 'trace') {
|
|
@@ -564,7 +515,6 @@ export async function run () {
|
|
|
564
515
|
* 5. {@link module:Helper/Base.run|run plugins}
|
|
565
516
|
*
|
|
566
517
|
* @async
|
|
567
|
-
* @memberof module:Helper
|
|
568
518
|
*/
|
|
569
519
|
export async function bootPlugins () {
|
|
570
520
|
await buildConfigs.call(this.app)
|
|
@@ -578,7 +528,6 @@ export async function bootPlugins () {
|
|
|
578
528
|
* Attach plugins exit handlers and make sure the app shutdowns gracefully
|
|
579
529
|
*
|
|
580
530
|
* @async
|
|
581
|
-
* @memberof module:Helper
|
|
582
531
|
*/
|
|
583
532
|
export async function exitHandler () {
|
|
584
533
|
if (!this.config.exitHandler) return
|
|
@@ -643,7 +592,6 @@ export async function exitHandler () {
|
|
|
643
592
|
* @async
|
|
644
593
|
* @fires {ns}:beforeAppletRun
|
|
645
594
|
* @fires {ns}:afterAppletRun
|
|
646
|
-
* @memberof module:Helper
|
|
647
595
|
*/
|
|
648
596
|
export async function runAsApplet () {
|
|
649
597
|
const { isString, map, find } = this.app.lib._
|
|
@@ -667,27 +615,191 @@ export async function runAsApplet () {
|
|
|
667
615
|
const applet = find(this.app.applets, a => (a.ns === ns || a.alias === ns))
|
|
668
616
|
if (!applet) this.print.fatal('notFound%s%s', this.app.t('applet'), name)
|
|
669
617
|
|
|
670
|
-
/**
|
|
671
|
-
* Run before applet is run. ```[ns]``` is applet's namespace
|
|
672
|
-
*
|
|
673
|
-
* @global
|
|
674
|
-
* @event {ns}:beforeAppletRun
|
|
675
|
-
* @param {...any} params
|
|
676
|
-
* @see {@tutorial hook}
|
|
677
|
-
* @see module:Helper/Bajo.runAsApplet
|
|
678
|
-
*/
|
|
679
618
|
await this.runHook(`${applet.ns}:beforeAppletRun`, ...this.app.args)
|
|
680
619
|
await this.app.bajoCli.runApplet(applet, path, ...this.app.args)
|
|
681
|
-
/**
|
|
682
|
-
* Run after applet is run. ```[ns]``` is applet's namespace
|
|
683
|
-
*
|
|
684
|
-
* @global
|
|
685
|
-
* @event {ns}:afterAppletRun
|
|
686
|
-
* @param {...any} params
|
|
687
|
-
* @see {@tutorial hook}
|
|
688
|
-
* @see module:Helper/Bajo.runAsApplet
|
|
689
|
-
* @memberof module:Helper
|
|
690
|
-
*/
|
|
691
620
|
await this.runHook(`${applet.ns}:afterAppletRun`, ...this.app.args)
|
|
692
621
|
}
|
|
693
|
-
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
* Import file/module from any loaded plugins.
|
|
625
|
+
*
|
|
626
|
+
* E.g. your plugin structure looks like this:
|
|
627
|
+
* ```
|
|
628
|
+
* |- src
|
|
629
|
+
* | |- lib
|
|
630
|
+
* | | |- my-module.js
|
|
631
|
+
* |- index.js
|
|
632
|
+
* |- package.json
|
|
633
|
+
* ```
|
|
634
|
+
*
|
|
635
|
+
* And this is how to import ```my-module.js```:
|
|
636
|
+
* ```javascript
|
|
637
|
+
* const { importModule } = this.app.bajo
|
|
638
|
+
* const myModule = await importModule('myPlugin:/src/lib/my-module.js')
|
|
639
|
+
* ```
|
|
640
|
+
*
|
|
641
|
+
* @method
|
|
642
|
+
* @async
|
|
643
|
+
* @param {TNsPathPairs} file File to import.
|
|
644
|
+
* @param {Object} [options={}] Options.
|
|
645
|
+
* @param {boolean} [options.asDefaultImport=true] If ```true``` (default), return default imported module.
|
|
646
|
+
* @param {boolean} [options.asHandler] If ```true```, return as a {@link HandlerType|handler}.
|
|
647
|
+
* @param {boolean} [options.noCache] If ```true```, always import as a fresh copy.
|
|
648
|
+
* @returns {any}
|
|
649
|
+
* @see Bajo#importModule
|
|
650
|
+
*/
|
|
651
|
+
export async function importModule (file, { asDefaultImport = true, asHandler, noCache } = {}) {
|
|
652
|
+
const load = async (file, asDefaultImport, noCache = false) => {
|
|
653
|
+
file = resolvePath(file, true)
|
|
654
|
+
if (noCache) file += `?_=${Date.now()}`
|
|
655
|
+
const imported = await import(file)
|
|
656
|
+
if (asDefaultImport) return imported.default
|
|
657
|
+
return imported
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
if (this) file = this.app.getPluginFile(file)
|
|
661
|
+
if (!fs.existsSync(file)) return
|
|
662
|
+
let mod = await load(file, asDefaultImport, noCache)
|
|
663
|
+
if (!asHandler) return mod
|
|
664
|
+
if (isFunction(mod)) mod = { level: 999, handler: mod }
|
|
665
|
+
if (!isPlainObject(mod)) {
|
|
666
|
+
if (this) throw this.error('fileNotModuleHandler%s', file)
|
|
667
|
+
throw new Error(`File '${file}' is NOT a handler module`)
|
|
668
|
+
}
|
|
669
|
+
return mod
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
/**
|
|
673
|
+
* Freeze object.
|
|
674
|
+
*
|
|
675
|
+
* @method
|
|
676
|
+
* @param {Object} obj Object to freeze.
|
|
677
|
+
* @param {boolean} [shallow=false] If ```false``` (default), deep freeze object.
|
|
678
|
+
*/
|
|
679
|
+
export function freeze (obj, options = {}) {
|
|
680
|
+
const { shallow = false, clone = false } = options
|
|
681
|
+
if (shallow) Object.freeze(obj)
|
|
682
|
+
else deepFreeze(obj, clone)
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
// take from https://github.com/3imed-jaberi/deepfreeze/blob/master/index.js
|
|
686
|
+
export function deepFreeze (object, clone = false) {
|
|
687
|
+
function _deepFreeze (_object) {
|
|
688
|
+
if (Object.isFrozen(_object)) return _object
|
|
689
|
+
if (_object instanceof Map) {
|
|
690
|
+
_object.set = _object.clear = _object.delete = function () {
|
|
691
|
+
throw new Error('Map is read-only')
|
|
692
|
+
}
|
|
693
|
+
return _object
|
|
694
|
+
}
|
|
695
|
+
if (_object instanceof Set) {
|
|
696
|
+
_object.add = _object.clear = _object.delete = function () {
|
|
697
|
+
throw new Error('Set is read-only')
|
|
698
|
+
}
|
|
699
|
+
return _object
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
Object.freeze(_object)
|
|
703
|
+
Object.getOwnPropertyNames(_object).forEach(function (key) {
|
|
704
|
+
if (Object.hasOwn(_object, key) && _object[key] !== null &&
|
|
705
|
+
(typeof _object[key] === 'object' || typeof _object[key] === 'function') &&
|
|
706
|
+
!Object.isFrozen(_object[key])
|
|
707
|
+
) _deepFreeze(_object[key])
|
|
708
|
+
})
|
|
709
|
+
|
|
710
|
+
return _object
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
if (!Object.isFrozen(object)) Object.defineProperty(object, 'isDeepFrozen', { value: () => true })
|
|
714
|
+
object = clone ? cloneDeep(object) : object
|
|
715
|
+
return _deepFreeze(object)
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
/**
|
|
719
|
+
* Find item deep in paths.
|
|
720
|
+
*
|
|
721
|
+
* @method
|
|
722
|
+
* @param {string} item Item to find.
|
|
723
|
+
* @param {Array} paths Array of path to look for.
|
|
724
|
+
* @returns {string}
|
|
725
|
+
*/
|
|
726
|
+
export function findDeep (item, paths) {
|
|
727
|
+
let dir
|
|
728
|
+
for (const p of paths) {
|
|
729
|
+
const d = `${p}/${item}`
|
|
730
|
+
if (fs.existsSync(d)) {
|
|
731
|
+
dir = d
|
|
732
|
+
break
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
return dir
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
/**
|
|
739
|
+
* Supported data types.
|
|
740
|
+
*
|
|
741
|
+
* @typedef {Object} TDataType
|
|
742
|
+
* @memberof Bajo
|
|
743
|
+
* @type {Array}
|
|
744
|
+
* @property {string} 0 string
|
|
745
|
+
* @property {string} 1 float
|
|
746
|
+
* @property {string} 2 double
|
|
747
|
+
* @property {string} 3 integer
|
|
748
|
+
* @property {string} 4 smallint
|
|
749
|
+
* @property {string} 5 date
|
|
750
|
+
* @property {string} 6 time
|
|
751
|
+
* @property {string} 7 datetime
|
|
752
|
+
* @property {string} 8 array
|
|
753
|
+
* @property {string} 9 object
|
|
754
|
+
* @property {string} 10 auto
|
|
755
|
+
*/
|
|
756
|
+
|
|
757
|
+
/**
|
|
758
|
+
* General format types,
|
|
759
|
+
*
|
|
760
|
+
* @typedef {Object} TFormatType
|
|
761
|
+
* @memberof Bajo
|
|
762
|
+
* @type {Array}
|
|
763
|
+
* @property {string} 0 speed
|
|
764
|
+
* @property {string} 1 distance
|
|
765
|
+
* @property {string} 2 area
|
|
766
|
+
* @property {string} 3 degree
|
|
767
|
+
*/
|
|
768
|
+
export const types = ['speed', 'distance', 'area', 'degree']
|
|
769
|
+
|
|
770
|
+
export const formats = {
|
|
771
|
+
metric: {
|
|
772
|
+
speedFn: (val) => val,
|
|
773
|
+
speedUnit: 'kmh',
|
|
774
|
+
distanceFn: (val) => val,
|
|
775
|
+
distanceUnit: 'km',
|
|
776
|
+
areaFn: (val) => val,
|
|
777
|
+
areaUnit: 'km²',
|
|
778
|
+
degreeFn: (val) => val,
|
|
779
|
+
degreeUnit: '°',
|
|
780
|
+
degreeUnitSep: ''
|
|
781
|
+
},
|
|
782
|
+
imperial: {
|
|
783
|
+
speedFn: (val) => val / 1.609,
|
|
784
|
+
speedUnit: 'mih',
|
|
785
|
+
distanceFn: (val) => val / 1.609,
|
|
786
|
+
distanceUnit: 'mi',
|
|
787
|
+
areaFn: (val) => val / 2.59,
|
|
788
|
+
areaUnit: 'mi²',
|
|
789
|
+
degreeFn: (val) => val,
|
|
790
|
+
degreeUnit: '°',
|
|
791
|
+
degreeUnitSep: ''
|
|
792
|
+
},
|
|
793
|
+
nautical: {
|
|
794
|
+
speedFn: (val) => val / 1.852,
|
|
795
|
+
speedUnit: 'knot',
|
|
796
|
+
distanceFn: (val) => val / 1.852,
|
|
797
|
+
distanceUnit: 'nm',
|
|
798
|
+
areaFn: (val) => val / 2.92,
|
|
799
|
+
areaUnit: 'nm²',
|
|
800
|
+
degreeFn: (val) => val,
|
|
801
|
+
degreeUnit: '°',
|
|
802
|
+
degreeUnitSep: ''
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
</code></pre></article></section></div></div></div><div class="search-container" id="PkfLWpAbet" style="display:none"><div class="wrapper" id="iCxFxjkHbP"><button class="icon-button search-close-button" id="VjLlGakifb" aria-label="close search"><svg><use xlink:href="#close-icon"></use></svg></button><div class="search-box-c"><svg><use xlink:href="#search-icon"></use></svg> <input type="text" id="vpcKVYIppa" class="search-input" placeholder="Search..." autofocus></div><div class="search-result-c" id="fWwVHRuDuN"><span class="search-result-c-text">Type anything to view search result</span></div></div></div><div class="mobile-menu-icon-container"><button class="icon-button" id="mobile-menu" data-isopen="false" aria-label="menu"><svg><use xlink:href="#menu-icon"></use></svg></button></div><div id="mobile-sidebar" class="mobile-sidebar-container"><div class="mobile-sidebar-wrapper"><a href="/" class="sidebar-title sidebar-title-anchor">Bajo API</a><div class="mobile-nav-links"><div class="navbar-item"><a id="" href="https://www.npmjs.com/package/bajo" target="">NPM</a></div><div class="navbar-item"><a id="" href="https://github.com/ardhi/bajo" target="">Github</a></div><div class="navbar-item"><a id="" href="https://bajo.app" target="">Bajo</a></div></div><div class="mobile-sidebar-items-c"><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-classes"><div>Classes</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="App.html">App</a></div><div class="sidebar-section-children"><a href="Bajo.html">Bajo</a></div><div class="sidebar-section-children"><a href="Base.html">Base</a></div><div class="sidebar-section-children"><a href="Cache.html">Cache</a></div><div class="sidebar-section-children"><a href="Err.html">Err</a></div><div class="sidebar-section-children"><a href="Log.html">Log</a></div><div class="sidebar-section-children"><a href="Plugin.html">Plugin</a></div><div class="sidebar-section-children"><a href="Print.html">Print</a></div><div class="sidebar-section-children"><a href="Tools.html">Tools</a></div></div><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-modules"><div>Modules</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="module-Helper.html">Helper</a></div><div class="sidebar-section-children"><a href="module-Hook.html">Hook</a></div></div><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-global"><div>Global</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="global.html#boot">boot</a></div></div></div><div class="mobile-navbar-actions"><div class="navbar-right-item"><button class="icon-button search-button" aria-label="open-search"><svg><use xlink:href="#search-icon"></use></svg></button></div><div class="navbar-right-item"><button class="icon-button theme-toggle" aria-label="toggle-theme"><svg><use class="theme-svg-use" xlink:href="#dark-theme-icon"></use></svg></button></div><div class="navbar-right-item"><button class="icon-button font-size" aria-label="change-font-size"><svg><use xlink:href="#font-size-icon"></use></svg></button></div></div></div></div><script type="text/javascript" src="scripts/core.min.js"></script><script src="scripts/search.min.js" defer="defer"></script><script src="scripts/third-party/fuse.js" defer="defer"></script><script type="text/javascript">var tocbotInstance=tocbot.init({tocSelector:"#eed4d2a0bfd64539bb9df78095dec881",contentSelector:".main-content",headingSelector:"h1, h2, h3",hasInnerContainers:!0,scrollContainer:".main-content",headingsOffset:130,onClick:bringLinkToView})</script></body></html>
|