![]() |
5 years ago | |
---|---|---|
dist | 5 years ago | |
example | 5 years ago | |
.gitignore | 5 years ago | |
.npmignore | 5 years ago | |
.snyk | 5 years ago | |
README.md | 5 years ago | |
lofig.js | 5 years ago | |
package-lock.json | 5 years ago | |
package.json | 5 years ago | |
webpack.config.js | 5 years ago |
npmjs.com/package/config for client side JavaScript
npm install lofig --save --production
You can also use https://unpkg.com/lofig@latest/dist/lofig.min.js.
import 'lofig' from 'lofig'; // not necessary if using CDN Link
// change config folder
lofig.folder = 'config/default.json';
// check if property exists
await lofig.has('secret');
// OR
lofig.has('secret').then(res => {
if (res) console.log("secret is defined!");
})
// return property
await lofig.get('secret');
// OR
lofig.get('secret').then(secret => {
if (secret) console.log("secret:", secret);
})
See example folder for more details.