Skip to content

xesam/config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Config

a simple json config loader.

usage

npm install @xesam/config

test data

{
  key_1: 'val_1',
  key_2: {
    key_2_1: {
      key_2_1_1: 'val_2_1_1'
    },
    key_2_2: 'val_2_2'
  }
}

load config

search path:

  1. absolute path
  2. working dir
  3. home dir
  4. source dir
const cfg = new Config('config.demo.json5');
const c = cfg.loadSync("key_2", "key_2_1"); 
console.log(c) //  {key_2_1_1: 'val_2_1_1'}

dump config

const cfg = new Config('config.demo.json5');
cfg.dump({ val: 200 }).then(() => {
    ...
});

About

a json5 config helper

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages