lark-config

lark config module

Usage no npm install needed!

<script type="module">
  import larkConfig from 'https://cdn.skypack.dev/lark-config';
</script>

README

lark-config

NPM version build status Test coverage

This is a tool to load configs from files

How to install

$ npm install --save lark-config

How to use

const config = new Config();
await config.load('configs');

This will load all files (.js, .json, .yaml, .yml, .node) in directory 'configs'.

Then you can easily get/check/remove a config by path:

config.get("path.to.file.foo.bar");       // nearly same as require('path/to/file').foo.bar
config.has("path.to.file.foo.bar");
config.delete("path.to.file.foo.bar");
config.set("path.to.file.foo.bar", "new-value");

If you want to switch the config by environment, use the second param as tag:

await config.load('configs', '@online');

It will use config named as foo@online rather than foo if exists