bajo 1.2.9 → 2.0.1
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 +6 -3
- package/README.md +8 -148
- package/class/app.js +113 -0
- package/{boot/class/bajo-core.js → class/bajo.js} +448 -35
- package/{boot/class/error.js → class/base/err.js} +29 -3
- package/class/base/log.js +205 -0
- package/class/base/plugin.js +168 -0
- package/class/base/print.js +272 -0
- package/class/helper/bajo.js +344 -0
- package/class/helper/plugin.js +169 -0
- package/{boot/class/bajo-plugin.js → class/plugin.js} +60 -3
- package/docs/App.html +3 -0
- package/docs/Bajo.html +15 -0
- package/docs/BasePlugin.html +5 -0
- package/docs/Err.html +3 -0
- package/docs/Log.html +3 -0
- package/docs/Plugin.html +3 -0
- package/docs/Print.html +3 -0
- package/docs/bitcoin.jpeg +0 -0
- package/docs/class_app.js.html +116 -0
- package/docs/class_bajo.js.html +1100 -0
- package/docs/class_base_err.js.html +99 -0
- package/docs/class_base_log.js.html +208 -0
- package/docs/class_base_plugin.js.html +180 -0
- package/docs/class_base_print.js.html +275 -0
- package/docs/class_helper_bajo.js.html +347 -0
- package/docs/class_helper_plugin.js.html +172 -0
- package/docs/class_plugin.js.html +121 -0
- package/docs/data/search.json +1 -0
- package/docs/fonts/Inconsolata-Regular.ttf +0 -0
- package/docs/fonts/OpenSans-Regular.ttf +0 -0
- package/docs/fonts/WorkSans-Bold.ttf +0 -0
- package/docs/global.html +3 -0
- package/docs/index.html +3 -0
- package/docs/lib_create-method.js.html +42 -0
- package/docs/lib_formats.js.html +68 -0
- package/docs/lib_log-levels.js.html +28 -0
- package/docs/lib_resolve-path.js.html +30 -0
- package/docs/lib_shim.js.html +35 -0
- package/docs/module-class_helper_bajo.html +3 -0
- package/docs/module-class_helper_plugin.html +3 -0
- package/docs/module-lib_create-method.html +3 -0
- package/docs/module-lib_formats.html +3 -0
- package/docs/module-lib_log-levels.html +3 -0
- package/docs/module-lib_resolve-path.html +3 -0
- package/docs/module-lib_shim.html +3 -0
- package/docs/scripts/core.js +726 -0
- package/docs/scripts/core.min.js +23 -0
- package/docs/scripts/resize.js +90 -0
- package/docs/scripts/search.js +265 -0
- package/docs/scripts/search.min.js +6 -0
- package/docs/scripts/third-party/Apache-License-2.0.txt +202 -0
- package/docs/scripts/third-party/fuse.js +9 -0
- package/docs/scripts/third-party/hljs-line-num-original.js +369 -0
- package/docs/scripts/third-party/hljs-line-num.js +1 -0
- package/docs/scripts/third-party/hljs-original.js +5171 -0
- package/docs/scripts/third-party/hljs.js +1 -0
- package/docs/scripts/third-party/popper.js +5 -0
- package/docs/scripts/third-party/tippy.js +1 -0
- package/docs/scripts/third-party/tocbot.js +672 -0
- package/docs/scripts/third-party/tocbot.min.js +1 -0
- package/docs/styles/clean-jsdoc-theme-base.css +1159 -0
- package/docs/styles/clean-jsdoc-theme-dark.css +412 -0
- package/docs/styles/clean-jsdoc-theme-light.css +482 -0
- package/docs/styles/clean-jsdoc-theme-scrollbar.css +30 -0
- package/docs/styles/clean-jsdoc-theme-without-scrollbar.min.css +1 -0
- package/docs/styles/clean-jsdoc-theme.min.css +1 -0
- package/docs/tutorial-contribution.html +3 -0
- package/docs/tutorial-ecosystem.html +3 -0
- package/docs/tutorial-getting-started.html +13 -0
- package/docs/tutorial-plugin-dev.html +3 -0
- package/docs/tutorial-user-guide.html +3 -0
- package/lib/create-method.js +39 -0
- package/{boot/lib → lib}/formats.js +28 -0
- package/{boot/lib → lib}/log-levels.js +16 -0
- package/{boot/lib → lib}/parse-args-argv.js +1 -1
- package/{boot/lib → lib}/resolve-path.js +12 -0
- package/{boot/lib → lib}/shim.js +10 -0
- package/misc-docs/bitcoin.jpeg +0 -0
- package/misc-docs/contribution.md +20 -0
- package/{docs → misc-docs}/ecosystem.md +41 -12
- package/misc-docs/getting-started.md +142 -0
- package/misc-docs/plugin-dev.md +0 -0
- package/misc-docs/toc.json +17 -0
- package/misc-docs/user-guide.md +1 -0
- package/package.json +14 -13
- package/bajoBook/book/doc/.metadata.json +0 -28
- package/bajoBook/book/doc/How-to-Make-a-Paper-Boat-564x400@2x.jpg +0 -0
- package/bajoBook/book/doc/pages/guides/definition.md +0 -7
- package/bajoBook/book/doc/pages/guides/intro.md +0 -3
- package/bajoBook/book/doc/pages/guides/setup.md +0 -22
- package/bajoBook/book/reference/.metadata.json +0 -152
- package/bajoBook/book/reference/concept-leadership-business-with-paper-boats.jpg +0 -0
- package/bajoBook/book/reference/pages/configuration/configuration-file.md +0 -52
- package/bajoBook/book/reference/pages/helper/break-ns-path.md +0 -24
- package/bajoBook/book/reference/pages/helper/build-collections.md +0 -19
- package/bajoBook/book/reference/pages/helper/call-helper-or-handler.md +0 -35
- package/bajoBook/book/reference/pages/helper/current-loc.md +0 -28
- package/bajoBook/book/reference/pages/helper/dayjs.md +0 -13
- package/bajoBook/book/reference/pages/helper/defaults-deep.md +0 -29
- package/bajoBook/book/reference/pages/helper/dump.md +0 -32
- package/bajoBook/book/reference/pages/helper/each-plugins.md +0 -24
- package/bajoBook/book/reference/pages/helper/envs.md +0 -11
- package/bajoBook/book/reference/pages/helper/error.md +0 -29
- package/bajoBook/book/reference/pages/helper/fatal.md +0 -18
- package/bajoBook/book/reference/pages/helper/freeze.md +0 -13
- package/bajoBook/book/reference/pages/helper/generate-id.md +0 -36
- package/bajoBook/book/reference/pages/helper/get-config.md +0 -27
- package/bajoBook/book/reference/pages/helper/get-global-module-dir.md +0 -13
- package/bajoBook/book/reference/pages/helper/get-helper.md +0 -13
- package/bajoBook/book/reference/pages/helper/get-item-by-name.md +0 -13
- package/bajoBook/book/reference/pages/helper/get-key-by-value.md +0 -13
- package/bajoBook/book/reference/pages/helper/get-module-dir.md +0 -13
- package/bajoBook/book/reference/pages/helper/get-plugin-data-dir.md +0 -13
- package/bajoBook/book/reference/pages/helper/get-plugin-name.md +0 -13
- package/bajoBook/book/reference/pages/helper/get-plugin.md +0 -13
- package/bajoBook/book/reference/pages/helper/import-module.md +0 -13
- package/bajoBook/book/reference/pages/helper/import-pkg.md +0 -13
- package/bajoBook/book/reference/pages/helper/is-empty-dir.md +0 -13
- package/bajoBook/book/reference/pages/helper/is-log-in-range.md +0 -13
- package/bajoBook/book/reference/pages/helper/is-set.md +0 -13
- package/bajoBook/book/reference/pages/helper/is-valid-app.md +0 -13
- package/bajoBook/book/reference/pages/helper/is-valid-plugin.md +0 -13
- package/bajoBook/book/reference/pages/helper/log-levels.md +0 -13
- package/bajoBook/book/reference/pages/helper/log.md +0 -13
- package/bajoBook/book/reference/pages/helper/paginate.md +0 -13
- package/bajoBook/book/reference/pages/helper/pascal-case.md +0 -13
- package/bajoBook/book/reference/pages/helper/print.md +0 -13
- package/bajoBook/book/reference/pages/helper/read-config.md +0 -13
- package/bajoBook/book/reference/pages/helper/read-json.md +0 -13
- package/bajoBook/book/reference/pages/helper/resolve-path.md +0 -13
- package/bajoBook/book/reference/pages/helper/resolve-tpl-path.md +0 -13
- package/bajoBook/book/reference/pages/helper/run-hook.md +0 -13
- package/bajoBook/book/reference/pages/helper/save-as-download.md +0 -13
- package/bajoBook/book/reference/pages/helper/titleize.md +0 -13
- package/bajoBook/book/reference/pages/helper/white-space.md +0 -13
- package/boot/class/app.js +0 -67
- package/boot/class/bajo-core/boot-order.js +0 -35
- package/boot/class/bajo-core/boot-plugins.js +0 -17
- package/boot/class/bajo-core/build-config.js +0 -86
- package/boot/class/bajo-core/build-plugins.js +0 -44
- package/boot/class/bajo-core/collect-config-handlers.js +0 -20
- package/boot/class/bajo-core/exit-handler.js +0 -53
- package/boot/class/bajo-core/run-as-applet.js +0 -26
- package/boot/class/bajo-plugin/attach-method.js +0 -14
- package/boot/class/bajo-plugin/build-config.js +0 -15
- package/boot/class/bajo-plugin/check-clash.js +0 -18
- package/boot/class/bajo-plugin/check-dependency.js +0 -39
- package/boot/class/bajo-plugin/collect-hooks.js +0 -31
- package/boot/class/bajo-plugin/run.js +0 -23
- package/boot/class/log.js +0 -96
- package/boot/class/plugin.js +0 -79
- package/boot/class/print.js +0 -153
- package/boot/lib/create-method.js +0 -33
- package/test/method/isSet.js +0 -43
- /package/{bajo → extend/bajo}/intl/en-US.json +0 -0
- /package/{bajo → extend/bajo}/intl/id.json +0 -0
- /package/{waibuStatic → extend/waibuStatic}/virtual.json +0 -0
- /package/{boot/index.js → index.js} +0 -0
- /package/{boot/lib → lib}/current-loc.js +0 -0
- /package/{boot/lib → lib}/dayjs.js +0 -0
- /package/{boot/lib → lib}/import-module.js +0 -0
- /package/{boot/lib → lib}/omitted-plugin-keys.js +0 -0
- /package/{boot/lib → lib}/parse-env.js +0 -0
- /package/{boot/lib → lib}/read-all-configs.js +0 -0
- /package/{docs/hook.md → misc-docs/.hook.md} +0 -0
|
@@ -0,0 +1,121 @@
|
|
|
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/plugin.js</title><!--[if lt IE 9]>
|
|
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 Framework</a><div class="sidebar-items-container"><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-class_helper_bajo.html">class/helper/bajo</a></div><div class="sidebar-section-children"><a href="module-class_helper_plugin.html">class/helper/plugin</a></div><div class="sidebar-section-children"><a href="module-lib_create-method.html">lib/create-method</a></div><div class="sidebar-section-children"><a href="module-lib_formats.html">lib/formats</a></div><div class="sidebar-section-children"><a href="module-lib_log-levels.html">lib/log-levels</a></div><div class="sidebar-section-children"><a href="module-lib_resolve-path.html">lib/resolve-path</a></div><div class="sidebar-section-children"><a href="module-lib_shim.html">lib/shim</a></div></div><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="BasePlugin.html">BasePlugin</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><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-tutorials"><div>Tutorials</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="tutorial-contribution.html">Contribution</a></div><div class="sidebar-section-children"><a href="tutorial-ecosystem.html">Ecosystem</a></div><div class="sidebar-section-children"><a href="tutorial-getting-started.html">Getting Started</a></div><div class="sidebar-section-children"><a href="tutorial-plugin-dev.html">Plugin Development</a></div><div class="sidebar-section-children"><a href="tutorial-user-guide.html">User Guide</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#NsPathType">NsPathType</a></div><div class="sidebar-section-children"><a href="global.html#ObjectFormatType">ObjectFormatType</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://bajo.app" target="">Bajo.app</a></div><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><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_plugin.js</h1></header><article><pre class="prettyprint source lang-js"><code>import BasePlugin from './base/plugin.js'
|
|
4
|
+
import lodash from 'lodash'
|
|
5
|
+
import omittedPluginKeys from '../lib/omitted-plugin-keys.js'
|
|
6
|
+
import readAllConfigs from '../lib/read-all-configs.js'
|
|
7
|
+
|
|
8
|
+
const { pick, omit } = lodash
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* This is the class that your own plugin suppose to extend. Don't use {@link BasePlugin}
|
|
12
|
+
* unless you know what you're doing.
|
|
13
|
+
*
|
|
14
|
+
* @class
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
class Plugin extends BasePlugin {
|
|
18
|
+
/**
|
|
19
|
+
* @param {string} pkgName - Package name (the one you use in package.json)
|
|
20
|
+
* @param {Object} app - App instance reference. Usefull to call app method inside a plugin
|
|
21
|
+
*/
|
|
22
|
+
constructor (pkgName, app) {
|
|
23
|
+
super(pkgName, app)
|
|
24
|
+
/**
|
|
25
|
+
* Plugin alias. Derived plugin must provide its own, unique alias. If it left blank,
|
|
26
|
+
* Bajo will provide this automatically
|
|
27
|
+
*
|
|
28
|
+
* @type {string}
|
|
29
|
+
*/
|
|
30
|
+
this.alias = ''
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Dependencies to other plugins. Enter all plugin's package name your plugin dependent from.
|
|
34
|
+
*
|
|
35
|
+
* Semver is also supported.
|
|
36
|
+
*
|
|
37
|
+
* @type {Array}
|
|
38
|
+
*/
|
|
39
|
+
this.dependencies = []
|
|
40
|
+
this.state = {}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Load config from file in data directory, program arguments and environment variables. Level of importance:
|
|
45
|
+
* ```Env Variables > Program Arguments > Config File```
|
|
46
|
+
*
|
|
47
|
+
* @method
|
|
48
|
+
* @async
|
|
49
|
+
*/
|
|
50
|
+
loadConfig = async () => {
|
|
51
|
+
const { defaultsDeep } = this.lib.aneka
|
|
52
|
+
const { get } = this.lib._
|
|
53
|
+
const { log, readJson, parseObject, getModuleDir } = this.app.bajo
|
|
54
|
+
log.trace('- %s', this.name)
|
|
55
|
+
const dir = this.name === this.app.bajo.mainNs ? (`${this.app.bajo.dir.base}/${this.app.bajo.mainNs}`) : getModuleDir(this.pkgName)
|
|
56
|
+
let cfg = await readAllConfigs.call(this.app, `${dir}/config`)
|
|
57
|
+
this.alias = this.alias ?? (this.pkgName.slice(0, 5) === 'bajo-' ? this.pkgName.slice(5).toLowerCase() : this.name.toLowerCase())
|
|
58
|
+
this.alias = this.alias.toLowerCase()
|
|
59
|
+
|
|
60
|
+
this.dir = {
|
|
61
|
+
pkg: dir,
|
|
62
|
+
data: `${this.app.bajo.dir.data}/plugins/${this.name}`
|
|
63
|
+
}
|
|
64
|
+
const file = `${dir + (this.name === this.app.bajo.mainNs ? '/..' : '')}/package.json`
|
|
65
|
+
const pkgJson = await readJson(file)
|
|
66
|
+
this.pkg = pick(pkgJson,
|
|
67
|
+
['name', 'version', 'description', 'author', 'license', 'homepage'])
|
|
68
|
+
if (this.name === this.app.bajo.mainNs) {
|
|
69
|
+
this.alias = this.app.bajo.mainNs
|
|
70
|
+
this.title = this.title ?? this.alias
|
|
71
|
+
}
|
|
72
|
+
// merge with config from datadir
|
|
73
|
+
try {
|
|
74
|
+
const altCfg = await readAllConfigs.call(this.app, `${this.app.bajo.dir.data}/config/${this.name}`)
|
|
75
|
+
cfg = defaultsDeep({}, omit(altCfg, omittedPluginKeys), cfg)
|
|
76
|
+
} catch (err) {}
|
|
77
|
+
const cfgEnv = omit(get(this, `app.env._.${this.name}`, {}), omittedPluginKeys) ?? {}
|
|
78
|
+
const cfgArgv = omit(get(this, `app.argv._.${this.name}`, {}), omittedPluginKeys) ?? {}
|
|
79
|
+
const envArgv = defaultsDeep({}, cfgEnv, cfgArgv)
|
|
80
|
+
cfg = defaultsDeep({}, envArgv ?? {}, cfg ?? {}, this.config ?? {})
|
|
81
|
+
this.title = this.title ?? cfg.title ?? this.alias
|
|
82
|
+
|
|
83
|
+
this.dependencies = this.dependencies ?? []
|
|
84
|
+
this.config = parseObject(cfg, { parseValue: true })
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* After config is read, plugin will be initialized. You can still change your config here,
|
|
89
|
+
* because after plugin is initialized, config will be deep frozen.
|
|
90
|
+
*
|
|
91
|
+
* @method
|
|
92
|
+
* @async
|
|
93
|
+
*/
|
|
94
|
+
init = async () => {
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* This method will be called after plugin's init
|
|
99
|
+
*
|
|
100
|
+
* @method
|
|
101
|
+
* @async
|
|
102
|
+
*/
|
|
103
|
+
start = async () => {
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
stop = async () => {
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Upon app termination, this method will be called first. Mostly useful for system cleanup,
|
|
111
|
+
* delete temporary files, freeing resources etc.
|
|
112
|
+
*
|
|
113
|
+
* @method
|
|
114
|
+
* @async
|
|
115
|
+
*/
|
|
116
|
+
exit = async () => {
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export default Plugin
|
|
121
|
+
</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 Framework</a><div class="mobile-nav-links"><div class="navbar-item"><a id="" href="https://bajo.app" target="">Bajo.app</a></div><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><div class="mobile-sidebar-items-c"><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-class_helper_bajo.html">class/helper/bajo</a></div><div class="sidebar-section-children"><a href="module-class_helper_plugin.html">class/helper/plugin</a></div><div class="sidebar-section-children"><a href="module-lib_create-method.html">lib/create-method</a></div><div class="sidebar-section-children"><a href="module-lib_formats.html">lib/formats</a></div><div class="sidebar-section-children"><a href="module-lib_log-levels.html">lib/log-levels</a></div><div class="sidebar-section-children"><a href="module-lib_resolve-path.html">lib/resolve-path</a></div><div class="sidebar-section-children"><a href="module-lib_shim.html">lib/shim</a></div></div><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="BasePlugin.html">BasePlugin</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><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-tutorials"><div>Tutorials</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="tutorial-contribution.html">Contribution</a></div><div class="sidebar-section-children"><a href="tutorial-ecosystem.html">Ecosystem</a></div><div class="sidebar-section-children"><a href="tutorial-getting-started.html">Getting Started</a></div><div class="sidebar-section-children"><a href="tutorial-plugin-dev.html">Plugin Development</a></div><div class="sidebar-section-children"><a href="tutorial-user-guide.html">User Guide</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#NsPathType">NsPathType</a></div><div class="sidebar-section-children"><a href="global.html#ObjectFormatType">ObjectFormatType</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>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"list":[{"title":"App","link":"<a href=\"App.html\">App</a>","description":"<p>Class constructor</p>"},{"title":"App#addPlugin","link":"<a href=\"App.html#addPlugin\">addPlugin</a>","description":"<p>Add a plugin to the app</p>"},{"title":"App#boot","link":"<a href=\"App.html#boot\">boot</a>","description":"<p>Booting the app</p>"},{"title":"App#dump","link":"<a href=\"App.html#dump\">dump</a>","description":"<p>Dumping variable on screen</p>"},{"title":"Bajo","link":"<a href=\"Bajo.html\">Bajo</a>"},{"title":"Bajo#applets","link":"<a href=\"Bajo.html#applets\">applets</a>","description":"<p>Storage for applets</p>"},{"title":"Bajo#breakNsPath","link":"<a href=\"Bajo.html#breakNsPath\">breakNsPath</a>","description":"<p>Break name to its namespace & path infos</p>"},{"title":"Bajo#buildCollections","link":"<a href=\"Bajo.html#buildCollections\">buildCollections</a>","description":"<p>Method to transform an array or object from config into an array of collection safely.</p>\n<p>Emitted hooks:</p>\n<ol>\n<li><code>{ns}:beforeBuildCollection (container)</code> - called before collection is built</li>\n<li><code>{ns}:afterBuildCollection (container, items)</code> - called after collection is built</li>\n</ol>"},{"title":"Bajo#callHandler","link":"<a href=\"Bajo.html#callHandler\">callHandler</a>","description":"<p>Calling any plugin's method by its name. Name format: <code>ns:methodName</code>.</p>\n<ul>\n<li>If name is a string, the corresponding plugin's method will be called with passed args as its parameters</li>\n<li>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</li>\n<li>If name is a function, this function will be run under scope with the remaining args</li>\n<li>If name is an object and has <code>handler</code> key in it, this function handler will be instead</li>\n</ul>"},{"title":"Bajo#configHandlers","link":"<a href=\"Bajo.html#configHandlers\">configHandlers</a>","description":"<p>Storage for config handlers. By default there are only two handlers available: <code>.js</code>\nand <code>.json</code>.</p>\n<p>Use plugin to add more type - e.g: {@link https://github.com/ardhi/bajo-config|bajo-config}\nlets you to use <code>.yaml</code> and <code>.toml</code></p>"},{"title":"Bajo#eachPlugins","link":"<a href=\"Bajo.html#eachPlugins\">eachPlugins</a>","description":"<p>This function iterates through all loaded plugins and call the provided handler scoped as the running plugin.\nAnd an object with the following key serves as its parameter:</p>\n<ul>\n<li><code>file</code>: file matched the glob pattern</li>\n<li><code>dir</code>: plugin's base directory</li>\n</ul>"},{"title":"Bajo#findDeep","link":"<a href=\"Bajo.html#findDeep\">findDeep</a>","description":"<p>Find item deep in paths</p>"},{"title":"Bajo#format","link":"<a href=\"Bajo.html#format\">format</a>","description":"<p>Format value</p>"},{"title":"Bajo#formatByType","link":"<a href=\"Bajo.html#formatByType\">formatByType</a>","description":"<p>Format value by type</p>"},{"title":"Bajo#freeze","link":"<a href=\"Bajo.html#freeze\">freeze</a>","description":"<p>Freeze object</p>"},{"title":"Bajo#generateId","link":"<a href=\"Bajo.html#generateId\">generateId</a>","description":"<p>Generate unique random characters that can be used as ID. Use {@link https://github.com/ai/nanoid|nanoid} under the hood</p>"},{"title":"Bajo#getGlobalModuleDir","link":"<a href=\"Bajo.html#getGlobalModuleDir\">getGlobalModuleDir</a>","description":"<p>Get NPM global module directory</p>"},{"title":"Bajo#getMethod","link":"<a href=\"Bajo.html#getMethod\">getMethod</a>","description":"<p>Get class method by name</p>"},{"title":"Bajo#getModuleDir","link":"<a href=\"Bajo.html#getModuleDir\">getModuleDir</a>","description":"<p>Get module directory, locally and globally</p>"},{"title":"Bajo#getPlugin","link":"<a href=\"Bajo.html#getPlugin\">getPlugin</a>","description":"<p>Get plugin by name</p>"},{"title":"Bajo#getPluginDataDir","link":"<a href=\"Bajo.html#getPluginDataDir\">getPluginDataDir</a>","description":"<p>Get plugin data directory</p>"},{"title":"Bajo#getPluginFile","link":"<a href=\"Bajo.html#getPluginFile\">getPluginFile</a>","description":"<p>Resolve file path from:</p>\n<ul>\n<li>local/absolute file</li>\n<li>ns based path (<code>myPlugin:/path/to/file.txt</code>)</li>\n</ul>"},{"title":"Bajo#getUnitFormat","link":"<a href=\"Bajo.html#getUnitFormat\">getUnitFormat</a>","description":"<p>Get unit format</p>"},{"title":"Bajo#importModule","link":"<a href=\"Bajo.html#importModule\">importModule</a>","description":"<p>Import file/module from any loaded plugins</p>\n<p>Your plugin structure:</p>\n<pre class=\"prettyprint source\"><code>|- src\n| |- lib\n| | |- my-module.js\n|- index.js\n|- package.json\n</code></pre>\n<p>Inside your app/plugin:</p>\n<pre class=\"prettyprint source lang-javascript\"><code>const { importModule } = this.app.bajo\nconst myModule = await importModule('myPlugin:/src/lib/my-module.js')\n</code></pre>"},{"title":"Bajo#importPkg","link":"<a href=\"Bajo.html#importPkg\">importPkg</a>","description":"<p>Import one or more package belongs to a plugin</p>\n<p>Example: you want to import packages <code>delay</code> and <code>chalk</code> from <code>bajo</code> namespace and use it inside your app/plugin</p>\n<pre class=\"prettyprint source lang-javascript\"><code>const { importPkg } from this.app.bajo\nconst [delay, chalk] = await importPkg('bajo:delay', 'bajo:chalk')\n\nawait delay(1000)\n...\n</code></pre>"},{"title":"Bajo#isEmptyDir","link":"<a href=\"Bajo.html#isEmptyDir\">isEmptyDir</a>","description":"<p>Check whether directory is empty or not. More info please {@link https://github.com/gulpjs/empty-dir|check here}.</p>"},{"title":"Bajo#isLogInRange","link":"<a href=\"Bajo.html#isLogInRange\">isLogInRange</a>","description":"<p>Check whether log level is within log's app current level</p>"},{"title":"Bajo#isValidApp","link":"<a href=\"Bajo.html#isValidApp\">isValidApp</a>","description":"<p>Check whether directory is a valid Bajo app</p>"},{"title":"Bajo#isValidPlugin","link":"<a href=\"Bajo.html#isValidPlugin\">isValidPlugin</a>","description":"<p>Check whether directory is a valid Bajo plugin</p>"},{"title":"Bajo#mainNs","link":"<a href=\"Bajo.html#mainNs\">mainNs</a>","description":"<p>Your main namespace. And yes, you suppose NOT to change this</p>"},{"title":"Bajo#numUnit","link":"<a href=\"Bajo.html#numUnit\">numUnit</a>","description":"<p>Return its numeric portion of a value</p>"},{"title":"Bajo#parseDt","link":"<a href=\"Bajo.html#parseDt\">parseDt</a>","description":"<p>Parse datetime string as Javascript object. Please visit {@link https://day.js.org|dayjs} for valid formats and more infos</p>"},{"title":"Bajo#parseDur","link":"<a href=\"Bajo.html#parseDur\">parseDur</a>","description":"<p>Parse duration to its millisecond value. Use {@link https://github.com/vercel/ms|ms} under the hood</p>"},{"title":"Bajo#parseObject","link":"<a href=\"Bajo.html#parseObject\">parseObject</a>","description":"<p>Parse an object and optionally normalize its values recursively. Use {@link https://github.com/ladjs/dotenv-parse-variables}\nto parse values, so please have a visit to know how it works</p>\n<p>If <code>options.parseValue</code> is <code>true</code>, any key ends with <code>Dur</code> and <code>Dt</code> will\nalso be parsed as millisecond and Javascript datetime accordingly</p>"},{"title":"Bajo#pluginNames","link":"<a href=\"Bajo.html#pluginNames\">pluginNames</a>","description":"<p>List of all loaded plugin's names</p>"},{"title":"Bajo#pluginPkgs","link":"<a href=\"Bajo.html#pluginPkgs\">pluginPkgs</a>","description":"<p>List of all loaded plugin's package names</p>"},{"title":"Bajo#readConfig","link":"<a href=\"Bajo.html#readConfig\">readConfig</a>","description":"<p>Read and parse file as config object. Supported types: <code>.js</code> and <code>.json</code>.\nMore supports can be added using plugin. {@link https://github.com/ardhi/bajo-config|bajo-config} gives you additional supports for <code>.yml</code>, <code>.yaml</code> and <code>.toml</code> file</p>\n<p>If file extension is <code>.*</code>, it will be auto detected and parsed accordingly</p>"},{"title":"Bajo#readJson","link":"<a href=\"Bajo.html#readJson\">readJson</a>","description":"<p>Read and parse json file</p>"},{"title":"Bajo#resolvePath","link":"<a href=\"Bajo.html#resolvePath\">resolvePath</a>","description":"<p>Resolve file name to filesystem's path. Windows path separator <code>\\</code>\nis normalized to Unix's <code>/</code></p>"},{"title":"Bajo#runAt","link":"<a href=\"Bajo.html#runAt\">runAt</a>","description":"<p>Date/time when your app start</p>"},{"title":"Bajo#runHook","link":"<a href=\"Bajo.html#runHook\">runHook</a>","description":"<p>Run named hook</p>"},{"title":"Bajo#saveAsDownload","link":"<a href=\"Bajo.html#saveAsDownload\">saveAsDownload</a>","description":"<p>Save item as file in Bajo's download directory. That is a directory inside your\nBajo plugin's data directory.</p>\n<p>If file exists already, file will automatically be\nrenamed incrementally.</p>"},{"title":"BasePlugin","link":"<a href=\"BasePlugin.html\">BasePlugin</a>"},{"title":"BasePlugin#app","link":"<a href=\"BasePlugin.html#app\">app</a>","description":"<p>Reference to app instance</p>"},{"title":"BasePlugin#config","link":"<a href=\"BasePlugin.html#config\">config</a>","description":"<p>Config object</p>"},{"title":"BasePlugin#err","link":"<a href=\"BasePlugin.html#err\">err</a>","description":"<p>Create an instance of {@link Err} object</p>"},{"title":"BasePlugin#error","link":"<a href=\"BasePlugin.html#error\">error</a>","description":"<p>Alias to err () method above</p>"},{"title":"BasePlugin#fatal","link":"<a href=\"BasePlugin.html#fatal\">fatal</a>","description":"<p>Create an instance of Err object, display it on screen and then force\nterminate the app process</p>"},{"title":"BasePlugin#getConfig","link":"<a href=\"BasePlugin.html#getConfig\">getConfig</a>","description":"<p>Get plugin's config value</p>"},{"title":"BasePlugin#initLog","link":"<a href=\"BasePlugin.html#initLog\">initLog</a>","description":"<p>Initialize log. Please refer to {@link Log} class for more info</p>"},{"title":"BasePlugin#initPrint","link":"<a href=\"BasePlugin.html#initPrint\">initPrint</a>","description":"<p>Initialize print engine. Please refer to {@link Print} class for more info</p>"},{"title":"BasePlugin#lib","link":"<a href=\"BasePlugin.html#lib\">lib</a>","description":"<p>Property to give you direct access to the most commonly used 3rd party library in a bajo based app.\nNo manual import necessary, always available, everywhere, anytime!</p>\n<p>Example:</p>\n<pre class=\"prettyprint source lang-javascript\"><code>const { camelCase, kebabCase } = this.lib._\nconsole.log(camelCase('Elit commodo sit et aliqua'))\n</code></pre>"},{"title":"BasePlugin#name","link":"<a href=\"BasePlugin.html#name\">name</a>","description":"<p>Plugin name. Simply the camel cased version of plugin's package name</p>"},{"title":"BasePlugin#pkgName","link":"<a href=\"BasePlugin.html#pkgName\">pkgName</a>","description":"<p>Package name, the one from package.json</p>"},{"title":"Err","link":"<a href=\"Err.html\">Err</a>"},{"title":"Err#fatal","link":"<a href=\"Err.html#fatal\">fatal</a>","description":"<p>Print error object on screen and terminate app process</p>"},{"title":"Err#formatErrorDetails","link":"<a href=\"Err.html#formatErrorDetails\">formatErrorDetails</a>","description":"<p>Pretty format error details</p>"},{"title":"Err#write","link":"<a href=\"Err.html#write\">write</a>","description":"<p>Create the error object</p>"},{"title":"Log","link":"<a href=\"Log.html\">Log</a>"},{"title":"Log#child","link":"<a href=\"Log.html#child\">child</a>","description":"<p>Create child logger</p>"},{"title":"Log#debug","link":"<a href=\"Log.html#debug\">debug</a>","description":"<p>Display & format message as <code>debug</code> level. See {@link Log#formatMsg|formatMsg} for details</p>"},{"title":"Log#error","link":"<a href=\"Log.html#error\">error</a>","description":"<p>Display & format message as <code>error</code> level. See {@link Log#formatMsg|formatMsg} for details</p>"},{"title":"Log#fatal","link":"<a href=\"Log.html#fatal\">fatal</a>","description":"<p>Display & format message as <code>fatal</code> level. See {@link Log#formatMsg|formatMsg} for details</p>"},{"title":"Log#formatMsg","link":"<a href=\"Log.html#formatMsg\">formatMsg</a>","description":"<p>Display & format message according to one of these rules:</p>\n<ol>\n<li><code>level</code> <code>text</code> <code>var 1</code> <code>var 2</code> <code>...var n</code> - Translate <code>text</code> and interpolate with <code>vars</code> for level <code>level</code></li>\n<li><code>level</code> <code>data</code> <code>text</code> <code>var 1</code> <code>var 2</code> <code>...var n</code> - As above, and append stringified <code>data</code></li>\n<li><code>level</code> <code>error</code> - Format as <strong>error</strong>. If current log level is <em>trace</em>, dump the error object on screen</li>\n</ol>"},{"title":"Log#info","link":"<a href=\"Log.html#info\">info</a>","description":"<p>Display & format message as <code>info</code> level. See {@link Log#formatMsg|formatMsg} for details</p>"},{"title":"Log#init","link":"<a href=\"Log.html#init\">init</a>","description":"<p>Initialize logger. Auto detect to use different logger via Bajo's config file</p>"},{"title":"Log#isExtLogger","link":"<a href=\"Log.html#isExtLogger\">isExtLogger</a>","description":"<p>Do we use external logger or Bajo's built-in one?</p>"},{"title":"Log#isIgnored","link":"<a href=\"Log.html#isIgnored\">isIgnored</a>","description":"<p>Is provided level being ignored by config?</p>"},{"title":"Log#trace","link":"<a href=\"Log.html#trace\">trace</a>","description":"<p>Display & format message as <code>trace</code> level. See {@link Log#formatMsg|formatMsg} for details</p>"},{"title":"Log#warn","link":"<a href=\"Log.html#warn\">warn</a>","description":"<p>Display & format message as <code>warn</code> level. See {@link Log#formatMsg|formatMsg} for details</p>"},{"title":"Log#write","link":"<a href=\"Log.html#write\">write</a>","description":"<p>Interpolate and translate text via plugin's print engine. Check Print class\nfor more information</p>"},{"title":"NsPathType","link":"<a href=\"global.html#NsPathType\">NsPathType</a>","description":"<p>Object returned by {@link BajoCore#breakNsPath|breakNsPath}</p>"},{"title":"ObjectFormatType","link":"<a href=\"global.html#ObjectFormatType\">ObjectFormatType</a>","description":"<p>Object returned by {@link BajoCore#getUnitFormat|getUnitFormat}</p>"},{"title":"Plugin","link":"<a href=\"Plugin.html\">Plugin</a>"},{"title":"Plugin#alias","link":"<a href=\"Plugin.html#alias\">alias</a>","description":"<p>Plugin alias. Derived plugin must provide its own, unique alias. If it left blank,\nBajo will provide this automatically</p>"},{"title":"Plugin#dependencies","link":"<a href=\"Plugin.html#dependencies\">dependencies</a>","description":"<p>Dependencies to other plugins. Enter all plugin's package name your plugin dependent from.</p>\n<p>Semver is also supported.</p>"},{"title":"Plugin#exit","link":"<a href=\"Plugin.html#exit\">exit</a>","description":"<p>Upon app termination, this method will be called first. Mostly useful for system cleanup,\ndelete temporary files, freeing resources etc.</p>"},{"title":"Plugin#init","link":"<a href=\"Plugin.html#init\">init</a>","description":"<p>After config is read, plugin will be initialized. You can still change your config here,\nbecause after plugin is initialized, config will be deep frozen.</p>"},{"title":"Plugin#loadConfig","link":"<a href=\"Plugin.html#loadConfig\">loadConfig</a>","description":"<p>Load config from file in data directory, program arguments and environment variables. Level of importance:\n<code>Env Variables > Program Arguments > Config File</code></p>"},{"title":"Plugin#start","link":"<a href=\"Plugin.html#start\">start</a>","description":"<p>This method will be called after plugin's init</p>"},{"title":"Print","link":"<a href=\"Print.html\">Print</a>","description":"<p>Class constructor</p>"},{"title":"Print#clear","link":"<a href=\"Print.html#clear\">clear</a>","description":"<p>Clear spinner text</p>"},{"title":"Print#fail","link":"<a href=\"Print.html#fail\">fail</a>","description":"<p>Print failed message, prefixed with a cross icon</p>"},{"title":"Print#fatal","link":"<a href=\"Print.html#fatal\">fatal</a>","description":"<p>Print failed message, prefixed with a cross icon and terminate the app process</p>"},{"title":"Print#getElapsed","link":"<a href=\"Print.html#getElapsed\">getElapsed</a>","description":"<p>Get elapsed time since print instance is created</p>"},{"title":"Print#info","link":"<a href=\"Print.html#info\">info</a>","description":"<p>Print failed message, prefixed with an info icon</p>"},{"title":"Print#init","link":"<a href=\"Print.html#init\">init</a>","description":"<p>Initialize print engine and read plugin's translation files</p>"},{"title":"Print#render","link":"<a href=\"Print.html#render\">render</a>","description":"<p>Force render spinner</p>"},{"title":"Print#setOpts","link":"<a href=\"Print.html#setOpts\">setOpts</a>","description":"<p>Set spinner options</p>"},{"title":"Print#setText","link":"<a href=\"Print.html#setText\">setText</a>","description":"<p>Set spinner text</p>"},{"title":"Print#spinner","link":"<a href=\"Print.html#spinner\">spinner</a>","description":"<p>Create a new spinner</p>"},{"title":"Print#start","link":"<a href=\"Print.html#start\">start</a>","description":"<p>Start the spinner</p>"},{"title":"Print#stop","link":"<a href=\"Print.html#stop\">stop</a>","description":"<p>Stop the spinner</p>"},{"title":"Print#succeed","link":"<a href=\"Print.html#succeed\">succeed</a>","description":"<p>Print success message, prefixed with a check icon</p>"},{"title":"Print#warn","link":"<a href=\"Print.html#warn\">warn</a>","description":"<p>Print warning message, prefixed with a warn icon</p>"},{"title":"Print#write","link":"<a href=\"Print.html#write\">write</a>","description":"<p>Interpolate and translate text according to the chosen language</p>"},{"title":"module:class/helper/bajo","link":"<a href=\"module-class_helper_bajo.html\">class/helper/bajo</a>"},{"title":"module:class/helper/bajo.bootOrder","link":"<a href=\"module-class_helper_bajo.html#.bootOrder\">bootOrder</a>","description":"<p>Setup plugins boot orders by reading plugin's <code>.bootorder</code> file if provided.</p>"},{"title":"module:class/helper/bajo.bootPlugins","link":"<a href=\"module-class_helper_bajo.html#.bootPlugins\">bootPlugins</a>","description":"<p>Iterate through all plugins loaded and do:</p>\n<ol>\n<li>{@link module:class/helper/bajo-plugin.buildConfigs|build configs}</li>\n<li>{@link module:class/helper/bajo-plugin.checkNameAliases|ensure names & aliases uniqueness}</li>\n<li>{@link module:class/helper/bajo-plugin.checkDependencies|ensure dependencies are met}</li>\n<li>{@link module:class/helper/bajo-plugin.attachMethods|build and attach dynamic methods}</li>\n<li>{@link module:class/helper/bajo-plugin.collectHooks|collect hooks}</li>\n<li>{@link module:class/helper/bajo-plugin.run|run plugins}</li>\n</ol>"},{"title":"module:class/helper/bajo.buildBaseConfig","link":"<a href=\"module-class_helper_bajo.html#.buildBaseConfig\">buildBaseConfig</a>","description":"<p>Building bajo base config. Mostly dealing with directory setups:</p>\n<ul>\n<li>determine base directory</li>\n<li>check whether data directory is valid</li>\n<li>ensure data config directory is there</li>\n</ul>"},{"title":"module:class/helper/bajo.buildExtConfig","link":"<a href=\"module-class_helper_bajo.html#.buildExtConfig\">buildExtConfig</a>","description":"<p>Bajo extra config:</p>\n<ul>\n<li>reading config file</li>\n<li>merge config with arguments & environments values</li>\n<li>Set environment (<code>dev</code> or <code>prod</code>)</li>\n</ul>"},{"title":"module:class/helper/bajo.buildPlugins","link":"<a href=\"module-class_helper_bajo.html#.buildPlugins\">buildPlugins</a>","description":"<p>Building all plugins:</p>\n<ul>\n<li>read the list of plugins from <code>.plugins</code> file</li>\n<li>iterate through the list and build related plugins</li>\n<li>attach these plugins to the app instance</li>\n</ul>"},{"title":"module:class/helper/bajo.collectConfigHandlers","link":"<a href=\"module-class_helper_bajo.html#.collectConfigHandlers\">collectConfigHandlers</a>","description":"<p>Collect all config handlers, including the one provided by plugins</p>"},{"title":"module:class/helper/bajo.exitHandler","link":"<a href=\"module-class_helper_bajo.html#.exitHandler\">exitHandler</a>","description":"<p>Attach plugins exit handlers and make sure the app shutdowns gracefully</p>"},{"title":"module:class/helper/bajo.runAsApplet","link":"<a href=\"module-class_helper_bajo.html#.runAsApplet\">runAsApplet</a>","description":"<p>If app is in <code>applet</code> mode, this little helper should take care plugin's applet boot process</p>"},{"title":"module:class/helper/plugin","link":"<a href=\"module-class_helper_plugin.html\">class/helper/plugin</a>"},{"title":"module:class/helper/plugin.attachMethods","link":"<a href=\"module-class_helper_plugin.html#.attachMethods\">attachMethods</a>","description":"<p>Scan plugins <code>method</code> directories, and turn + attach its found files as methods dynamically.</p>"},{"title":"module:class/helper/plugin.buildConfigs","link":"<a href=\"module-class_helper_plugin.html#.buildConfigs\">buildConfigs</a>","description":"<p>Build configurations</p>"},{"title":"module:class/helper/plugin.checkDependencies","link":"<a href=\"module-class_helper_plugin.html#.checkDependencies\">checkDependencies</a>","description":"<p>Ensure dependencies are met</p>"},{"title":"module:class/helper/plugin.checkNameAliases","link":"<a href=\"module-class_helper_plugin.html#.checkNameAliases\">checkNameAliases</a>","description":"<p>Ensure for names and aliases to be unique and no clashes with other plugins</p>"},{"title":"module:class/helper/plugin.collectHooks","link":"<a href=\"module-class_helper_plugin.html#.collectHooks\">collectHooks</a>","description":"<p>Collect and build hooks and push them to the bajo's hook system</p>"},{"title":"module:class/helper/plugin.run","link":"<a href=\"module-class_helper_plugin.html#.run\">run</a>","description":"<p>Finally, run all plugins</p>"},{"title":"module:lib/create-method","link":"<a href=\"module-lib_create-method.html\">lib/create-method</a>"},{"title":"module:lib/create-method~createMethod","link":"<a href=\"module-lib_create-method.html#~createMethod\">createMethod</a>","description":"<p>This function scan directory for <code>.js</code> and <code>.json</code> files, read its content, and\nturn it to become a class method by attach it to its scope (its class instance) dynamically.</p>\n<p>File path is camel-cased and become the method name. File that starts with underscore (eg: <code>_my-file.js</code>)\nis ignored; usefull to use such file as your shared library.</p>"},{"title":"module:lib/formats","link":"<a href=\"module-lib_formats.html\">lib/formats</a>"},{"title":"module:lib/formats~DataType","link":"<a href=\"module-lib_formats.html#~DataType\">DataType</a>"},{"title":"module:lib/formats~FormatType","link":"<a href=\"module-lib_formats.html#~FormatType\">FormatType</a>"},{"title":"module:lib/log-levels","link":"<a href=\"module-lib_log-levels.html\">lib/log-levels</a>"},{"title":"module:lib/log-levels~LogLevelsType","link":"<a href=\"module-lib_log-levels.html#~LogLevelsType\">LogLevelsType</a>"},{"title":"module:lib/resolve-path","link":"<a href=\"module-lib_resolve-path.html\">lib/resolve-path</a>"},{"title":"module:lib/resolve-path~resolvePath","link":"<a href=\"module-lib_resolve-path.html#~resolvePath\">resolvePath</a>","description":"<p>Resolve file name to filesystem's path. Windows path separator <code>\\</code>\nis normalized to Unix's <code>/</code></p>"},{"title":"module:lib/shim","link":"<a href=\"module-lib_shim.html\">lib/shim</a>"},{"title":"module:lib/shim~shim","link":"<a href=\"module-lib_shim.html#~shim\">shim</a>","description":"<p>Function to attach some of the methods needed but probably not provided by your node installation:</p>\n<ul>\n<li><code>String.prototype.replaceAll</code></li>\n<li><code>String.prototype.splice</code></li>\n</ul>"}]}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/docs/global.html
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
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>Global</title><!--[if lt IE 9]>
|
|
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 Framework</a><div class="sidebar-items-container"><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-class_helper_bajo.html">class/helper/bajo</a></div><div class="sidebar-section-children"><a href="module-class_helper_plugin.html">class/helper/plugin</a></div><div class="sidebar-section-children"><a href="module-lib_create-method.html">lib/create-method</a></div><div class="sidebar-section-children"><a href="module-lib_formats.html">lib/formats</a></div><div class="sidebar-section-children"><a href="module-lib_log-levels.html">lib/log-levels</a></div><div class="sidebar-section-children"><a href="module-lib_resolve-path.html">lib/resolve-path</a></div><div class="sidebar-section-children"><a href="module-lib_shim.html">lib/shim</a></div></div><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="BasePlugin.html">BasePlugin</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><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-tutorials"><div>Tutorials</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="tutorial-contribution.html">Contribution</a></div><div class="sidebar-section-children"><a href="tutorial-ecosystem.html">Ecosystem</a></div><div class="sidebar-section-children"><a href="tutorial-getting-started.html">Getting Started</a></div><div class="sidebar-section-children"><a href="tutorial-plugin-dev.html">Plugin Development</a></div><div class="sidebar-section-children"><a href="tutorial-user-guide.html">User Guide</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#NsPathType">NsPathType</a></div><div class="sidebar-section-children"><a href="global.html#ObjectFormatType">ObjectFormatType</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://bajo.app" target="">Bajo.app</a></div><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><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><article><div class="container-overview"></div><h2 id="type-definitions" class="subsection-title has-anchor">Type Definitions</h2><h3 class="name has-anchor" id="NsPathType">NsPathType</h3><div class="description"><p>Object returned by breakNsPath</p></div><div class="member-item-container flex"><strong>Type:</strong><ul><li><span class="param-type">Object</span></li></ul></div><b class="subsection-title">Properties</b><div class="allow-overflow"><table class="props"><thead><tr><th>Name</th><th>Type</th><th>Attributes</th><th class="last">Description</th></tr></thead><tbody><tr><td class="name"><code>ns</code></td><td class="type"><span class="param-type">string</span></td><td class="attributes"></td><td class="description last"><p>Namespace</p></td></tr><tr><td class="name"><code>subNs</code></td><td class="type"><span class="param-type">string</span></td><td class="attributes"><optional><br></td><td class="description last"><p>Sub namespace</p></td></tr><tr><td class="name"><code>subSubNs</code></td><td class="type"><span class="param-type">string</span></td><td class="attributes"><optional><br></td><td class="description last"><p>Sub of sub namespace</p></td></tr><tr><td class="name"><code>path</code></td><td class="type"><span class="param-type">string</span></td><td class="attributes"></td><td class="description last"><p>Path without query string or hash</p></td></tr><tr><td class="name"><code>fullPath</code></td><td class="type"><span class="param-type">string</span></td><td class="attributes"></td><td class="description last"><p>Full path, including query string and hash</p></td></tr></tbody></table></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_bajo.js.html">class/bajo.js</a>, <a href="class_bajo.js.html#line160">line 160</a></li></ul></dd></div></dl><h3 class="name has-anchor" id="ObjectFormatType">ObjectFormatType</h3><div class="description"><p>Object returned by getUnitFormat</p></div><div class="member-item-container flex"><strong>Type:</strong><ul><li><span class="param-type">Object</span></li></ul></div><b class="subsection-title">Properties</b><div class="allow-overflow"><table class="props"><thead><tr><th>Name</th><th>Type</th><th class="last">Description</th></tr></thead><tbody><tr><td class="name"><code>unitSys</code></td><td class="type"><span class="param-type">string</span></td><td class="description last"><p>Unit system</p></td></tr><tr><td class="name"><code>format</code></td><td class="type"><span class="param-type">Object</span></td><td class="description last"><p>Format object</p></td></tr></tbody></table></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_bajo.js.html">class/bajo.js</a>, <a href="class_bajo.js.html#line388">line 388</a></li></ul></dd></div></dl></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 Framework</a><div class="mobile-nav-links"><div class="navbar-item"><a id="" href="https://bajo.app" target="">Bajo.app</a></div><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><div class="mobile-sidebar-items-c"><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-class_helper_bajo.html">class/helper/bajo</a></div><div class="sidebar-section-children"><a href="module-class_helper_plugin.html">class/helper/plugin</a></div><div class="sidebar-section-children"><a href="module-lib_create-method.html">lib/create-method</a></div><div class="sidebar-section-children"><a href="module-lib_formats.html">lib/formats</a></div><div class="sidebar-section-children"><a href="module-lib_log-levels.html">lib/log-levels</a></div><div class="sidebar-section-children"><a href="module-lib_resolve-path.html">lib/resolve-path</a></div><div class="sidebar-section-children"><a href="module-lib_shim.html">lib/shim</a></div></div><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="BasePlugin.html">BasePlugin</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><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-tutorials"><div>Tutorials</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="tutorial-contribution.html">Contribution</a></div><div class="sidebar-section-children"><a href="tutorial-ecosystem.html">Ecosystem</a></div><div class="sidebar-section-children"><a href="tutorial-getting-started.html">Getting Started</a></div><div class="sidebar-section-children"><a href="tutorial-plugin-dev.html">Plugin Development</a></div><div class="sidebar-section-children"><a href="tutorial-user-guide.html">User Guide</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#NsPathType">NsPathType</a></div><div class="sidebar-section-children"><a href="global.html#ObjectFormatType">ObjectFormatType</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>
|
package/docs/index.html
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
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>Bajo Framework</title><!--[if lt IE 9]>
|
|
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 Framework</a><div class="sidebar-items-container"><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-class_helper_bajo.html">class/helper/bajo</a></div><div class="sidebar-section-children"><a href="module-class_helper_plugin.html">class/helper/plugin</a></div><div class="sidebar-section-children"><a href="module-lib_create-method.html">lib/create-method</a></div><div class="sidebar-section-children"><a href="module-lib_formats.html">lib/formats</a></div><div class="sidebar-section-children"><a href="module-lib_log-levels.html">lib/log-levels</a></div><div class="sidebar-section-children"><a href="module-lib_resolve-path.html">lib/resolve-path</a></div><div class="sidebar-section-children"><a href="module-lib_shim.html">lib/shim</a></div></div><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="BasePlugin.html">BasePlugin</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><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-tutorials"><div>Tutorials</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="tutorial-contribution.html">Contribution</a></div><div class="sidebar-section-children"><a href="tutorial-ecosystem.html">Ecosystem</a></div><div class="sidebar-section-children"><a href="tutorial-getting-started.html">Getting Started</a></div><div class="sidebar-section-children"><a href="tutorial-plugin-dev.html">Plugin Development</a></div><div class="sidebar-section-children"><a href="tutorial-user-guide.html">User Guide</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#NsPathType">NsPathType</a></div><div class="sidebar-section-children"><a href="global.html#ObjectFormatType">ObjectFormatType</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://bajo.app" target="">Bajo.app</a></div><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><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"></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 Framework</a><div class="mobile-nav-links"><div class="navbar-item"><a id="" href="https://bajo.app" target="">Bajo.app</a></div><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><div class="mobile-sidebar-items-c"><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-class_helper_bajo.html">class/helper/bajo</a></div><div class="sidebar-section-children"><a href="module-class_helper_plugin.html">class/helper/plugin</a></div><div class="sidebar-section-children"><a href="module-lib_create-method.html">lib/create-method</a></div><div class="sidebar-section-children"><a href="module-lib_formats.html">lib/formats</a></div><div class="sidebar-section-children"><a href="module-lib_log-levels.html">lib/log-levels</a></div><div class="sidebar-section-children"><a href="module-lib_resolve-path.html">lib/resolve-path</a></div><div class="sidebar-section-children"><a href="module-lib_shim.html">lib/shim</a></div></div><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="BasePlugin.html">BasePlugin</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><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-tutorials"><div>Tutorials</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="tutorial-contribution.html">Contribution</a></div><div class="sidebar-section-children"><a href="tutorial-ecosystem.html">Ecosystem</a></div><div class="sidebar-section-children"><a href="tutorial-getting-started.html">Getting Started</a></div><div class="sidebar-section-children"><a href="tutorial-plugin-dev.html">Plugin Development</a></div><div class="sidebar-section-children"><a href="tutorial-user-guide.html">User Guide</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#NsPathType">NsPathType</a></div><div class="sidebar-section-children"><a href="global.html#ObjectFormatType">ObjectFormatType</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>
|
|
@@ -0,0 +1,42 @@
|
|
|
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/create-method.js</title><!--[if lt IE 9]>
|
|
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 Framework</a><div class="sidebar-items-container"><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-class_helper_bajo.html">class/helper/bajo</a></div><div class="sidebar-section-children"><a href="module-class_helper_plugin.html">class/helper/plugin</a></div><div class="sidebar-section-children"><a href="module-lib_create-method.html">lib/create-method</a></div><div class="sidebar-section-children"><a href="module-lib_formats.html">lib/formats</a></div><div class="sidebar-section-children"><a href="module-lib_log-levels.html">lib/log-levels</a></div><div class="sidebar-section-children"><a href="module-lib_resolve-path.html">lib/resolve-path</a></div><div class="sidebar-section-children"><a href="module-lib_shim.html">lib/shim</a></div></div><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="BasePlugin.html">BasePlugin</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><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-tutorials"><div>Tutorials</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="tutorial-contribution.html">Contribution</a></div><div class="sidebar-section-children"><a href="tutorial-ecosystem.html">Ecosystem</a></div><div class="sidebar-section-children"><a href="tutorial-getting-started.html">Getting Started</a></div><div class="sidebar-section-children"><a href="tutorial-plugin-dev.html">Plugin Development</a></div><div class="sidebar-section-children"><a href="tutorial-user-guide.html">User Guide</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#NsPathType">NsPathType</a></div><div class="sidebar-section-children"><a href="global.html#ObjectFormatType">ObjectFormatType</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://bajo.app" target="">Bajo.app</a></div><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><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_create-method.js</h1></header><article><pre class="prettyprint source lang-js"><code>import fastGlob from 'fast-glob'
|
|
4
|
+
import path from 'path'
|
|
5
|
+
import lodash from 'lodash'
|
|
6
|
+
import resolvePath from './resolve-path.js'
|
|
7
|
+
|
|
8
|
+
const { camelCase, isFunction } = lodash
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* This function scan directory for ```.js``` and ```.json``` files, read its content, and
|
|
16
|
+
* turn it to become a class method by attach it to its scope (its class instance) dynamically.
|
|
17
|
+
*
|
|
18
|
+
* File path is camel-cased and become the method name. File that starts with underscore (eg: ```_my-file.js```)
|
|
19
|
+
* is ignored; usefull to use such file as your shared library.
|
|
20
|
+
*
|
|
21
|
+
* @async
|
|
22
|
+
* @param {string} dir - Directory to scan
|
|
23
|
+
* @returns {number} Number of files found
|
|
24
|
+
*/
|
|
25
|
+
async function createMethod (dir) {
|
|
26
|
+
dir = resolvePath(dir)
|
|
27
|
+
const files = await fastGlob([`!${dir}/**/_*.{js,json}`, `${dir}/**/*.{js,json}`])
|
|
28
|
+
for (const f of files) {
|
|
29
|
+
const ext = path.extname(f)
|
|
30
|
+
const base = f.replace(dir, '').slice(0, -ext.length)
|
|
31
|
+
const name = camelCase(base)
|
|
32
|
+
let mod
|
|
33
|
+
if (ext === '.json') mod = this.app.bajo.readJson(f)
|
|
34
|
+
else mod = await this.app.bajo.importModule(f)
|
|
35
|
+
if (isFunction(mod)) mod = mod.bind(this)
|
|
36
|
+
this[name] = mod
|
|
37
|
+
}
|
|
38
|
+
return files.length
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export default createMethod
|
|
42
|
+
</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 Framework</a><div class="mobile-nav-links"><div class="navbar-item"><a id="" href="https://bajo.app" target="">Bajo.app</a></div><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><div class="mobile-sidebar-items-c"><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-class_helper_bajo.html">class/helper/bajo</a></div><div class="sidebar-section-children"><a href="module-class_helper_plugin.html">class/helper/plugin</a></div><div class="sidebar-section-children"><a href="module-lib_create-method.html">lib/create-method</a></div><div class="sidebar-section-children"><a href="module-lib_formats.html">lib/formats</a></div><div class="sidebar-section-children"><a href="module-lib_log-levels.html">lib/log-levels</a></div><div class="sidebar-section-children"><a href="module-lib_resolve-path.html">lib/resolve-path</a></div><div class="sidebar-section-children"><a href="module-lib_shim.html">lib/shim</a></div></div><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="BasePlugin.html">BasePlugin</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><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-tutorials"><div>Tutorials</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="tutorial-contribution.html">Contribution</a></div><div class="sidebar-section-children"><a href="tutorial-ecosystem.html">Ecosystem</a></div><div class="sidebar-section-children"><a href="tutorial-getting-started.html">Getting Started</a></div><div class="sidebar-section-children"><a href="tutorial-plugin-dev.html">Plugin Development</a></div><div class="sidebar-section-children"><a href="tutorial-user-guide.html">User Guide</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#NsPathType">NsPathType</a></div><div class="sidebar-section-children"><a href="global.html#ObjectFormatType">ObjectFormatType</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>
|
|
@@ -0,0 +1,68 @@
|
|
|
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/formats.js</title><!--[if lt IE 9]>
|
|
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 Framework</a><div class="sidebar-items-container"><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-class_helper_bajo.html">class/helper/bajo</a></div><div class="sidebar-section-children"><a href="module-class_helper_plugin.html">class/helper/plugin</a></div><div class="sidebar-section-children"><a href="module-lib_create-method.html">lib/create-method</a></div><div class="sidebar-section-children"><a href="module-lib_formats.html">lib/formats</a></div><div class="sidebar-section-children"><a href="module-lib_log-levels.html">lib/log-levels</a></div><div class="sidebar-section-children"><a href="module-lib_resolve-path.html">lib/resolve-path</a></div><div class="sidebar-section-children"><a href="module-lib_shim.html">lib/shim</a></div></div><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="BasePlugin.html">BasePlugin</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><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-tutorials"><div>Tutorials</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="tutorial-contribution.html">Contribution</a></div><div class="sidebar-section-children"><a href="tutorial-ecosystem.html">Ecosystem</a></div><div class="sidebar-section-children"><a href="tutorial-getting-started.html">Getting Started</a></div><div class="sidebar-section-children"><a href="tutorial-plugin-dev.html">Plugin Development</a></div><div class="sidebar-section-children"><a href="tutorial-user-guide.html">User Guide</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#NsPathType">NsPathType</a></div><div class="sidebar-section-children"><a href="global.html#ObjectFormatType">ObjectFormatType</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://bajo.app" target="">Bajo.app</a></div><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><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_formats.js</h1></header><article><pre class="prettyprint source lang-js"><code>/**
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {Object} DataType
|
|
9
|
+
* @type {Array}
|
|
10
|
+
* @property {string} 0 - string
|
|
11
|
+
* @property {string} 1 - float
|
|
12
|
+
* @property {string} 2 - double
|
|
13
|
+
* @property {string} 3 - integer
|
|
14
|
+
* @property {string} 4 - smallint
|
|
15
|
+
* @property {string} 5 - date
|
|
16
|
+
* @property {string} 6 - time
|
|
17
|
+
* @property {string} 7 - datetime
|
|
18
|
+
* @property {string} 8 - array
|
|
19
|
+
* @property {string} 9 - object
|
|
20
|
+
* @property {string} 10 - auto
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @typedef {Object} FormatType
|
|
25
|
+
* @type {Array}
|
|
26
|
+
* @property {string} 0 - speed
|
|
27
|
+
* @property {string} 1 - distance
|
|
28
|
+
* @property {string} 3 - area
|
|
29
|
+
* @property {string} 4 - degree
|
|
30
|
+
*/
|
|
31
|
+
export const types = ['speed', 'distance', 'area', 'degree']
|
|
32
|
+
|
|
33
|
+
export const formats = {
|
|
34
|
+
metric: {
|
|
35
|
+
speedFn: (val) => val,
|
|
36
|
+
speedUnit: 'kmh',
|
|
37
|
+
distanceFn: (val) => val,
|
|
38
|
+
distanceUnit: 'km',
|
|
39
|
+
areaFn: (val) => val,
|
|
40
|
+
areaUnit: 'km²',
|
|
41
|
+
degreeFn: (val) => val,
|
|
42
|
+
degreeUnit: '°',
|
|
43
|
+
degreeUnitSep: ''
|
|
44
|
+
},
|
|
45
|
+
imperial: {
|
|
46
|
+
speedFn: (val) => val / 1.609,
|
|
47
|
+
speedUnit: 'mih',
|
|
48
|
+
distanceFn: (val) => val / 1.609,
|
|
49
|
+
distanceUnit: 'mi',
|
|
50
|
+
areaFn: (val) => val / 2.59,
|
|
51
|
+
areaUnit: 'mi²',
|
|
52
|
+
degreeFn: (val) => val,
|
|
53
|
+
degreeUnit: '°',
|
|
54
|
+
degreeUnitSep: ''
|
|
55
|
+
},
|
|
56
|
+
nautical: {
|
|
57
|
+
speedFn: (val) => val / 1.852,
|
|
58
|
+
speedUnit: 'knot',
|
|
59
|
+
distanceFn: (val) => val / 1.852,
|
|
60
|
+
distanceUnit: 'nm',
|
|
61
|
+
areaFn: (val) => val / 2.92,
|
|
62
|
+
areaUnit: 'nm²',
|
|
63
|
+
degreeFn: (val) => val,
|
|
64
|
+
degreeUnit: '°',
|
|
65
|
+
degreeUnitSep: ''
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
</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 Framework</a><div class="mobile-nav-links"><div class="navbar-item"><a id="" href="https://bajo.app" target="">Bajo.app</a></div><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><div class="mobile-sidebar-items-c"><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-class_helper_bajo.html">class/helper/bajo</a></div><div class="sidebar-section-children"><a href="module-class_helper_plugin.html">class/helper/plugin</a></div><div class="sidebar-section-children"><a href="module-lib_create-method.html">lib/create-method</a></div><div class="sidebar-section-children"><a href="module-lib_formats.html">lib/formats</a></div><div class="sidebar-section-children"><a href="module-lib_log-levels.html">lib/log-levels</a></div><div class="sidebar-section-children"><a href="module-lib_resolve-path.html">lib/resolve-path</a></div><div class="sidebar-section-children"><a href="module-lib_shim.html">lib/shim</a></div></div><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="BasePlugin.html">BasePlugin</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><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-tutorials"><div>Tutorials</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="tutorial-contribution.html">Contribution</a></div><div class="sidebar-section-children"><a href="tutorial-ecosystem.html">Ecosystem</a></div><div class="sidebar-section-children"><a href="tutorial-getting-started.html">Getting Started</a></div><div class="sidebar-section-children"><a href="tutorial-plugin-dev.html">Plugin Development</a></div><div class="sidebar-section-children"><a href="tutorial-user-guide.html">User Guide</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#NsPathType">NsPathType</a></div><div class="sidebar-section-children"><a href="global.html#ObjectFormatType">ObjectFormatType</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>
|