bajo 2.21.1 → 2.23.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 +108 -92
- 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 +1 -1
- package/{class/_helper.js → lib/helper.js} +206 -94
- package/lib/hook.js +228 -0
- package/package.json +1 -1
- package/wiki/CHANGES.md +11 -0
- package/wiki/ECOSYSTEM.md +6 -6
- 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
package/docs/class_bajo.js.html
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
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: class/bajo.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_bajo.js</h1></header><article><pre class="prettyprint source lang-js"><code>import Tools from './tools.js'
|
|
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">class_bajo.js</h1></header><article><pre class="prettyprint source lang-js"><code>import Tools from './tools.js'
|
|
4
4
|
import Plugin from './plugin.js'
|
|
5
5
|
import increment from 'add-filename-increment'
|
|
6
6
|
import fs from 'fs-extra'
|
|
@@ -10,9 +10,7 @@ import lodash from 'lodash'
|
|
|
10
10
|
import { createRequire } from 'module'
|
|
11
11
|
import fastGlob from 'fast-glob'
|
|
12
12
|
import querystring from 'querystring'
|
|
13
|
-
import
|
|
14
|
-
import logLevels from '../lib/log-levels.js'
|
|
15
|
-
import { types as formatTypes, formats } from '../lib/formats.js'
|
|
13
|
+
import { logLevels } from './log.js'
|
|
16
14
|
import * as yaml from 'js-yaml'
|
|
17
15
|
import aneka from 'aneka'
|
|
18
16
|
import {
|
|
@@ -22,8 +20,11 @@ import {
|
|
|
22
20
|
collectConfigHandlers,
|
|
23
21
|
bootOrder,
|
|
24
22
|
bootPlugins,
|
|
25
|
-
exitHandler
|
|
26
|
-
|
|
23
|
+
exitHandler,
|
|
24
|
+
importModule,
|
|
25
|
+
types as formatTypes,
|
|
26
|
+
formats
|
|
27
|
+
} from '../lib/helper.js'
|
|
27
28
|
|
|
28
29
|
const require = createRequire(import.meta.url)
|
|
29
30
|
|
|
@@ -37,9 +38,10 @@ const {
|
|
|
37
38
|
const { resolvePath, getGlobalModuleDir } = aneka
|
|
38
39
|
|
|
39
40
|
/**
|
|
40
|
-
* Name based
|
|
41
|
+
* Name based `{ns}:{path}` format.
|
|
41
42
|
*
|
|
42
43
|
* @typedef {string} TNsPathPairs
|
|
44
|
+
* @memberof Bajo
|
|
43
45
|
* @see TNsPathResult
|
|
44
46
|
* @see Bajo#buildNsPath
|
|
45
47
|
* @see Bajo#breakNsPath
|
|
@@ -48,12 +50,28 @@ const { resolvePath, getGlobalModuleDir } = aneka
|
|
|
48
50
|
/**
|
|
49
51
|
* Object returned by {@link Bajo#getUnitFormat|bajo:getUnitFormat}.
|
|
50
52
|
*
|
|
51
|
-
* @typedef {Object}
|
|
53
|
+
* @typedef {Object} TFormatResult
|
|
54
|
+
* @memberof Bajo
|
|
52
55
|
* @property {string} unitSys - Unit system.
|
|
53
56
|
* @property {Object} format - Format object.
|
|
54
57
|
* @see Bajo#getUnitFormat
|
|
55
58
|
*/
|
|
56
59
|
|
|
60
|
+
/**
|
|
61
|
+
* Object returned by {@link Bajo#breakNsPath|bajo:breakNsPath}.
|
|
62
|
+
*
|
|
63
|
+
* @typedef {Object} TNsPathResult
|
|
64
|
+
* @memberof Bajo
|
|
65
|
+
* @property {string} ns - Namespace
|
|
66
|
+
* @property {string} [subNs] - Sub namespace
|
|
67
|
+
* @property {string} [subSubNs] - Sub of sub namespace
|
|
68
|
+
* @property {string} path - Path without query string or hash
|
|
69
|
+
* @property {string} fullPath - Full path, including query string and hash
|
|
70
|
+
* @see TNsPathPairs
|
|
71
|
+
* @see Bajo#buildNsPath
|
|
72
|
+
* @see Bajo#breakNsPath
|
|
73
|
+
*/
|
|
74
|
+
|
|
57
75
|
/**
|
|
58
76
|
* The Core. The main engine. The one and only plugin that control app's boot process and
|
|
59
77
|
* making sure all other plugins working nicely.
|
|
@@ -62,28 +80,38 @@ const { resolvePath, getGlobalModuleDir } = aneka
|
|
|
62
80
|
*/
|
|
63
81
|
class Bajo extends Plugin {
|
|
64
82
|
/**
|
|
83
|
+
* Constructor.
|
|
84
|
+
*
|
|
65
85
|
* @param {App} app - App instance. Usefull to call app method inside a plugin.
|
|
66
86
|
*/
|
|
67
87
|
constructor (app) {
|
|
68
88
|
super('bajo', app)
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Alias
|
|
92
|
+
* @type {string}
|
|
93
|
+
*/
|
|
69
94
|
this.alias = 'bajo'
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* White space characters
|
|
98
|
+
* @type {string[]}
|
|
99
|
+
*/
|
|
70
100
|
this.whiteSpace = [' ', '\t', '\n', '\r']
|
|
101
|
+
|
|
71
102
|
/**
|
|
72
103
|
* Config object.
|
|
73
104
|
*
|
|
74
|
-
* @type {
|
|
105
|
+
* @type {Bajo.TObject}
|
|
75
106
|
* @see {@tutorial config}
|
|
76
107
|
*/
|
|
77
108
|
this.config = {}
|
|
78
109
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
{ ns: 'bajo', ext: '.yml', readHandler: this.fromYml, writeHandler: this.toYml }
|
|
85
|
-
]
|
|
86
|
-
|
|
110
|
+
/**
|
|
111
|
+
* Hooks container.
|
|
112
|
+
*
|
|
113
|
+
* @type {Array<Bajo.THook>}
|
|
114
|
+
*/
|
|
87
115
|
this.hooks = []
|
|
88
116
|
}
|
|
89
117
|
|
|
@@ -114,7 +142,20 @@ class Bajo extends Plugin {
|
|
|
114
142
|
}
|
|
115
143
|
}
|
|
116
144
|
|
|
117
|
-
|
|
145
|
+
/**
|
|
146
|
+
* Break file path to its namespace & path infos.
|
|
147
|
+
*
|
|
148
|
+
* @method
|
|
149
|
+
* @param {Object} options - Options object
|
|
150
|
+
* @param {string} [options.file] - File path to break
|
|
151
|
+
* @param {string} [options.dir] - Base directory to remove from file path
|
|
152
|
+
* @param {string} [options.ns] - Namespace to use. If not provided, will be extracted from file path
|
|
153
|
+
* @param {string} [options.suffix] - Suffix to remove from file path
|
|
154
|
+
* @param {boolean} [options.getType] - Whether to extract type from file path
|
|
155
|
+
* @returns {Object} Namespace and path information
|
|
156
|
+
*/
|
|
157
|
+
breakNsPathFromFile = (options = {}) => {
|
|
158
|
+
const { file = '', dir = '', ns, suffix = '', getType } = options
|
|
118
159
|
let item = file.replace(dir + suffix, '')
|
|
119
160
|
let type
|
|
120
161
|
if (getType) {
|
|
@@ -138,12 +179,12 @@ class Bajo extends Plugin {
|
|
|
138
179
|
* Build ns/path pairs.
|
|
139
180
|
*
|
|
140
181
|
* @method
|
|
141
|
-
* @param {object} [options={}] - Options object
|
|
142
|
-
* @param {string} [options.ns=''] - Namespace
|
|
143
|
-
* @param {string} [options.subNs] - Sub namespace
|
|
144
|
-
* @param {string} [options.subSubNs] - Sub sub namespace
|
|
145
|
-
* @param {string} [options.path] - Path
|
|
146
|
-
* @returns {TNsPathPairs} Ns/path pairs
|
|
182
|
+
* @param {object} [options={}] - Options object
|
|
183
|
+
* @param {string} [options.ns=''] - Namespace
|
|
184
|
+
* @param {string} [options.subNs] - Sub namespace
|
|
185
|
+
* @param {string} [options.subSubNs] - Sub sub namespace
|
|
186
|
+
* @param {string} [options.path] - Path
|
|
187
|
+
* @returns {TNsPathPairs} Ns/path pairs
|
|
147
188
|
*/
|
|
148
189
|
buildNsPath = ({ ns = '', subNs, subSubNs, path } = {}) => {
|
|
149
190
|
if (subNs) ns += '.' + subNs
|
|
@@ -152,25 +193,11 @@ class Bajo extends Plugin {
|
|
|
152
193
|
}
|
|
153
194
|
|
|
154
195
|
/**
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
* @typedef {Object} TNsPathResult
|
|
158
|
-
* @property {string} ns - Namespace.
|
|
159
|
-
* @property {string} [subNs] - Sub namespace.
|
|
160
|
-
* @property {string} [subSubNs] - Sub of sub namespace.
|
|
161
|
-
* @property {string} path - Path without query string or hash.
|
|
162
|
-
* @property {string} fullPath - Full path, including query string and hash.
|
|
163
|
-
* @see TNsPathPairs
|
|
164
|
-
* @see Bajo#buildNsPath
|
|
165
|
-
* @see Bajo#breakNsPath
|
|
166
|
-
*/
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Break name to its namespace & path infos.
|
|
196
|
+
* Break name to its namespace & path infos
|
|
170
197
|
*
|
|
171
198
|
* @method
|
|
172
199
|
* @param {(TNsPathPairs|string)} name - Name to break
|
|
173
|
-
* @param {boolean} [checkNs=true] - If
|
|
200
|
+
* @param {boolean} [checkNs=true] - If `true` (default), namespace will be checked for its validity
|
|
174
201
|
* @returns {TNsPathResult}
|
|
175
202
|
*/
|
|
176
203
|
breakNsPath = (name = '', checkNs = true) => {
|
|
@@ -224,11 +251,11 @@ class Bajo extends Plugin {
|
|
|
224
251
|
* @method
|
|
225
252
|
* @async
|
|
226
253
|
* @param {Object} options - Options.
|
|
227
|
-
* @param {string} [options.ns] - Namespace. If not provided, defaults to
|
|
254
|
+
* @param {string} [options.ns] - Namespace. If not provided, defaults to `bajo`
|
|
228
255
|
* @param {function} [options.handler] - Handler to call while building the collection item.
|
|
229
256
|
* @param {string[]} [options.dupChecks=[]] - Array of keys to check for duplicates.
|
|
230
257
|
* @param {string} options.container - Key used as container name.
|
|
231
|
-
* @param {boolean} [options.useDefaultName=true] - If true (default) and
|
|
258
|
+
* @param {boolean} [options.useDefaultName=true] - If true (default) and `name` key is not provided, returned collection will be named `default`.
|
|
232
259
|
* @fires bajo:beforeBuildCollection
|
|
233
260
|
* @fires bajo:afterBuildCollection
|
|
234
261
|
* @returns {Object[]} The collection
|
|
@@ -241,16 +268,6 @@ class Bajo extends Plugin {
|
|
|
241
268
|
let items = get(cfg, container, [])
|
|
242
269
|
if (!isArray(items)) items = [items]
|
|
243
270
|
this.app[ns].log.trace('collecting%s', this.t(container))
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* Run before collection is built.
|
|
247
|
-
*
|
|
248
|
-
* @global
|
|
249
|
-
* @event bajo:beforeBuildCollection
|
|
250
|
-
* @param {string} container
|
|
251
|
-
* @see {@tutorial hook}
|
|
252
|
-
* @see Bajo#buildCollections
|
|
253
|
-
*/
|
|
254
271
|
await this.runHook(`${ns}:beforeBuildCollection`, container)
|
|
255
272
|
const deleted = []
|
|
256
273
|
for (const index in items) {
|
|
@@ -279,17 +296,6 @@ class Bajo extends Plugin {
|
|
|
279
296
|
}
|
|
280
297
|
|
|
281
298
|
if (!noDefault && !items.find(item => item.name === 'default')) this.app[ns].fatal('missing%s%s', 'default', container)
|
|
282
|
-
|
|
283
|
-
/**
|
|
284
|
-
* Run after collection is built
|
|
285
|
-
*
|
|
286
|
-
* @global
|
|
287
|
-
* @event bajo:afterBuildCollection
|
|
288
|
-
* @param {string} container
|
|
289
|
-
* @param {Object[]} items
|
|
290
|
-
* @see {@tutorial hook}
|
|
291
|
-
* @see Bajo#buildCollections
|
|
292
|
-
*/
|
|
293
299
|
await this.runHook(`${ns}:afterBuildCollection`, container, items)
|
|
294
300
|
this.app[ns].log.debug('collected%s%d', this.t(container), items.length)
|
|
295
301
|
return items
|
|
@@ -301,7 +307,7 @@ class Bajo extends Plugin {
|
|
|
301
307
|
* - If name is a string, the corresponding plugin's method will be called with passed args as its parameters
|
|
302
308
|
* - If name is a plugin instance, this will be used as the scope instead. The first args is now the handler name and the rest are its parameters
|
|
303
309
|
* - If name is a function, this function will be run under scope with the remaining args
|
|
304
|
-
* - If name is an object and has
|
|
310
|
+
* - If name is an object and has `handler` key in it, this function handler will be instead
|
|
305
311
|
*
|
|
306
312
|
* @method
|
|
307
313
|
* @async
|
|
@@ -341,15 +347,15 @@ class Bajo extends Plugin {
|
|
|
341
347
|
* This function iterates through all loaded plugins and call the provided handler scoped as the running plugin.
|
|
342
348
|
* And an object with the following key serves as its parameter:
|
|
343
349
|
*
|
|
344
|
-
* -
|
|
345
|
-
* -
|
|
350
|
+
* - `file`: file matched the glob pattern
|
|
351
|
+
* - `dir`: plugin's base directory
|
|
346
352
|
*
|
|
347
353
|
* @method
|
|
348
354
|
* @async
|
|
349
355
|
* @param {function} handler - Function handler. Can be an async function. Scoped to the running plugin.
|
|
350
356
|
* @param {(string|Object)} [options={}] - Options. If a string is provided, it serves as the glob pattern, otherwise:
|
|
351
357
|
* @param {(string|string[])} [options.glob] - Glob pattern. If provided,
|
|
352
|
-
* @param {boolean} [options.useBajo=false] - If true, add
|
|
358
|
+
* @param {boolean} [options.useBajo=false] - If true, add `bajo` to the running plugins too.
|
|
353
359
|
* @param {string} [options.prefix=''] - Prepend glob pattern with prefix.
|
|
354
360
|
* @param {boolean} [options.noUnderscore=true] - If true (default), matched file with name starts with underscore is ignored.
|
|
355
361
|
* @param {any} [options.returnItems] - If true, each value of returned handler call will be saved as an object with running plugin name as its keys.
|
|
@@ -405,7 +411,7 @@ class Bajo extends Plugin {
|
|
|
405
411
|
* @method
|
|
406
412
|
* @param {Object} [options={}] - Options.
|
|
407
413
|
* @param {string} [options.lang] - Language to use. Defaults to the one you set in config.
|
|
408
|
-
* @param {string} [options.unitSys] - Unit system to use. Defaults to language's unit system or
|
|
414
|
+
* @param {string} [options.unitSys] - Unit system to use. Defaults to language's unit system or `metric` if unspecified.
|
|
409
415
|
* @returns {TBajoFormatResult} Returned value.
|
|
410
416
|
*/
|
|
411
417
|
getUnitFormat = (options = {}) => {
|
|
@@ -425,7 +431,7 @@ class Bajo extends Plugin {
|
|
|
425
431
|
* @param {Object} [options={}] - Options.
|
|
426
432
|
* @param {boolean} [options.withUnit=true] - Return with its unit appended.
|
|
427
433
|
* @param {string} [options.lang] - Format value according to this language. Defaults to the one you set in config.
|
|
428
|
-
* @returns {(Array|string)} Return string if
|
|
434
|
+
* @returns {(Array|string)} Return string if `withUnit` is true. Otherwise is an array of `[value, unit, separator]`.
|
|
429
435
|
*/
|
|
430
436
|
formatByType = (type, value, dataType, options = {}) => {
|
|
431
437
|
const { defaultsDeep } = this.app.lib.aneka
|
|
@@ -506,8 +512,8 @@ class Bajo extends Plugin {
|
|
|
506
512
|
* Get class method by name.
|
|
507
513
|
*
|
|
508
514
|
* @method
|
|
509
|
-
* @param {string} name - Name in format
|
|
510
|
-
* @param {boolean} [thrown=true] - If
|
|
515
|
+
* @param {string} name - Name in format `ns:methodName`.
|
|
516
|
+
* @param {boolean} [thrown=true] - If `true` (default), throw exception in case of error.
|
|
511
517
|
* @returns {function} Class method.
|
|
512
518
|
*/
|
|
513
519
|
getMethod = (name = '', thrown = true) => {
|
|
@@ -543,11 +549,11 @@ class Bajo extends Plugin {
|
|
|
543
549
|
/**
|
|
544
550
|
* Import file/module from any loaded plugins.
|
|
545
551
|
*
|
|
546
|
-
* Method proxy from {@link module:
|
|
552
|
+
* Method proxy from {@link module:Helper.importModule}
|
|
547
553
|
*
|
|
548
554
|
* @method
|
|
549
555
|
* @async
|
|
550
|
-
* @see module:
|
|
556
|
+
* @see module:Helper.importModule
|
|
551
557
|
*/
|
|
552
558
|
importModule = async (file, { asDefaultImport, asHandler, noCache } = {}) => {
|
|
553
559
|
return await importModule.call(this, file, { asDefaultImport, asHandler, noCache })
|
|
@@ -557,27 +563,27 @@ class Bajo extends Plugin {
|
|
|
557
563
|
* Import one or more packages belongs to a plugin.
|
|
558
564
|
*
|
|
559
565
|
* If the last arguments passed is an object, this object serves as options object:
|
|
560
|
-
* -
|
|
561
|
-
* -
|
|
562
|
-
* -
|
|
563
|
-
* -
|
|
566
|
+
* - `returnDefault`: should return package's default export. Defaults to `true`
|
|
567
|
+
* - `throwNotFound`: should throw if package is not found. Defaults to `false`
|
|
568
|
+
* - `noCache`: always use fresh import. Defaults to `false`
|
|
569
|
+
* - `asObject`: see below. Defaults to `false`
|
|
564
570
|
*
|
|
565
571
|
* Return value:
|
|
566
|
-
* - if
|
|
572
|
+
* - if `options.asObject` is `true` (default `false`), return as object with package's names as it's keys
|
|
567
573
|
* - Otherwise depends on how many parameters are provided, it should return the named package or an array of packages
|
|
568
574
|
*
|
|
569
|
-
* Example: you want to import
|
|
570
|
-
*
|
|
575
|
+
* Example: you want to import `delay` and `chalk` from `bajo` plugin because you want to use it in your code
|
|
576
|
+
* `javascript
|
|
571
577
|
* const { importPkg } from this.app.bajo
|
|
572
578
|
* const [delay, chalk] = await importPkg('bajo:delay', 'bajo:chalk')
|
|
573
579
|
*
|
|
574
580
|
* await delay(1000)
|
|
575
581
|
* ...
|
|
576
|
-
*
|
|
582
|
+
* `
|
|
577
583
|
*
|
|
578
584
|
* @method
|
|
579
585
|
* @async
|
|
580
|
-
* @param {...TNsPathPairs} pkgs - One or more packages in format
|
|
586
|
+
* @param {...TNsPathPairs} pkgs - One or more packages in format `{ns}:{packageName}`.
|
|
581
587
|
* @returns {(Object|Array)} See above.
|
|
582
588
|
*/
|
|
583
589
|
importPkg = async (...pkgs) => {
|
|
@@ -649,7 +655,7 @@ class Bajo extends Plugin {
|
|
|
649
655
|
*
|
|
650
656
|
* @method
|
|
651
657
|
* @param {string} dir - Directory to check.
|
|
652
|
-
* @param {boolean} [returnPkg] - Set
|
|
658
|
+
* @param {boolean} [returnPkg] - Set `true` to return its package.json content.
|
|
653
659
|
* @returns {(boolean|Object)}
|
|
654
660
|
*/
|
|
655
661
|
isValidApp = (dir, returnPkg) => {
|
|
@@ -662,7 +668,7 @@ class Bajo extends Plugin {
|
|
|
662
668
|
*
|
|
663
669
|
* @method
|
|
664
670
|
* @param {string} dir - Directory to check.
|
|
665
|
-
* @param {boolean} [returnPkg] - Set
|
|
671
|
+
* @param {boolean} [returnPkg] - Set `true` to return its package.json content.
|
|
666
672
|
* @returns {(boolean|Object)}
|
|
667
673
|
*/
|
|
668
674
|
isValidPlugin = (dir, returnPkg) => {
|
|
@@ -709,10 +715,10 @@ class Bajo extends Plugin {
|
|
|
709
715
|
}
|
|
710
716
|
|
|
711
717
|
/**
|
|
712
|
-
* Read and parse file as config object. Supported types:
|
|
713
|
-
* More supports can be added using plugin. {@link https://github.com/ardhi/bajo-config|bajo-config} gives you additional supports for
|
|
718
|
+
* Read and parse file as config object. Supported types: `.js`, `.json` and `.yml/.yaml`.
|
|
719
|
+
* More supports can be added using plugin. {@link https://github.com/ardhi/bajo-config|bajo-config} gives you additional supports for `.yml`, `.yaml` and `.toml` file.
|
|
714
720
|
*
|
|
715
|
-
* If file extension is
|
|
721
|
+
* If file extension is `.*`, it will be auto detected and parsed accordingly
|
|
716
722
|
*
|
|
717
723
|
* @method
|
|
718
724
|
* @async
|
|
@@ -720,7 +726,7 @@ class Bajo extends Plugin {
|
|
|
720
726
|
* @param {Object} [options={}] - Options.
|
|
721
727
|
* @param {boolean} [options.ignoreError] - Any exception will be silently discarded.
|
|
722
728
|
* @param {string} [options.ns] - If given, use this as the scope.
|
|
723
|
-
* @param {string} [options.pattern] - If given and auto detection is on (extension is
|
|
729
|
+
* @param {string} [options.pattern] - If given and auto detection is on (extension is `.*`), it will be used for instead the default one.
|
|
724
730
|
* @param {Object} [options.defValue={}] - Default value to use if value returned empty.
|
|
725
731
|
* @param {Object} [options.parserOpts={}] - Parser setting.
|
|
726
732
|
* @param {Object} [options.globOpts={}] - {@link https://github.com/mrmlnc/fast-glob|fast-glob} options.
|
|
@@ -745,7 +751,7 @@ class Bajo extends Plugin {
|
|
|
745
751
|
const output = async (obj) => {
|
|
746
752
|
let orig = parseObject(obj)
|
|
747
753
|
if (!baseNs || extend === false) {
|
|
748
|
-
await this.runHook('bajo:afterReadConfig', file, orig, options)
|
|
754
|
+
await this.runHook('bajo.default:afterReadConfig', file, orig, options)
|
|
749
755
|
if (cache.name) await this.app.cache.save(cache.name, orig, cache.ttlDur)
|
|
750
756
|
return orig
|
|
751
757
|
}
|
|
@@ -841,7 +847,7 @@ class Bajo extends Plugin {
|
|
|
841
847
|
*
|
|
842
848
|
* @method
|
|
843
849
|
* @param {string} file - File to read.
|
|
844
|
-
* @param {boolean} [thrownNotFound=false] - If
|
|
850
|
+
* @param {boolean} [thrownNotFound=false] - If `true`, silently ignore if file is not found.
|
|
845
851
|
* @returns {Object}
|
|
846
852
|
*/
|
|
847
853
|
readJson = (file, thrownNotFound = false) => {
|
|
@@ -1045,6 +1051,7 @@ class Bajo extends Plugin {
|
|
|
1045
1051
|
* Read config using all registered config handlers. The first handler that returns a
|
|
1046
1052
|
* valid object or array will be used.
|
|
1047
1053
|
*
|
|
1054
|
+
* @method
|
|
1048
1055
|
* @param {string} input - The input string to be processed by the config handlers.
|
|
1049
1056
|
* @param {string[]} [exts] - Optional array of extensions to filter the config handlers. If provided, only handlers with matching extensions will be used.
|
|
1050
1057
|
* @param {object} [options={}] - Options to be passed to the config handlers.
|
|
@@ -1066,4 +1073,4 @@ class Bajo extends Plugin {
|
|
|
1066
1073
|
}
|
|
1067
1074
|
|
|
1068
1075
|
export default Bajo
|
|
1069
|
-
</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-
|
|
1076
|
+
</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>
|