Skip to content

Repository files navigation

Simple Config Library

npm package

Build statusDependency StatusKnown VulnerabilitiesGitter

This is a simple config library for use in NodeJS. Get started with:

npm install --save better-config

Usage

varconfig=require('better-config');

Here are the ways to set the config - For a big project you probably want to set the defaults, then set a config.json file (if they have one). If there is no file, the set call does nothing.

// Plain vanilla object settingconfig.message='hello world';// Set using the set functionconfig.set({message: 'this is the default value'});// Set using a json fileconfig.set('./package.json');// Set using a js fileconfig.set('./defaults.js');// Set using a functionconfig.set(function(){return{sum: 1+1}});

You can simply access the config like you would any other object:

// Plain vanilla object getconsole.log(config.message)// Get by functionconsole.log(config.get('some.deep.array[0].property'))

Contributions welcome!

Credits

This library was initially made by the awesome team of engineers at Diamond.

If you haven't already, make sure you install Diamond!

About

Better config

Resources

Stars

2 stars

Watchers

4 watching

Forks

Releases

Packages

Used by

Contributors

Languages