Skip to content

NStal/node-easysettings

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-easysettings

simple module to manage setting file/storage file for simple program

install

npm install easysettings

example

Suppose it's test.js

var EasySettings = require("../lib/easysettings.js").EasySettings;
var es = new EasySettings();
//default config save path is ./filename.conf.json
//filename is obtained from process.arvs[1] without extname
//in this case which is "test"
//or you can just set it
var es = new EasySettings("/etc/myconfig.json");

//default is useful when your script running at the first time
es.setDefalt({name:"settings"});
//if first-time running,default settings will be used 
//if not set,{} will be used
var settings = es.load();
console.log(settings);
//return value of EasySettings.load is the reference of the settings json object from easy settings
//which means you can directly modify it and save the EasySettings like below
settings.conf = "conf";
es.save();
//load again will just replace the reference
//so you should get it again
settings = es.load();
console.log(settings);
//print {name:"settings",conf:"conf"}

About

simple module to manage setting file/storage file for simple program

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published