user-config
Easy user application configuration management
Usage
When requiring the library, user-config returns a function which is used to instantiate a config object that allows getting and setting of config values:
const createConfig = ; const config = ; // items in config are stored in objects and must be serialisableconfig;
Configuration changes should be saved after being changed:
const config = "my-app"; config;config;
Values can easily be retrieved from the store, including entire objects:
const config = "my-app"; console;
Templating
Outdated configurations can be updated using a templating system. By passing a template to the creation of the config store, old configurations can be merged with the template to ensure the presence of keys and structures:
const createConfig = ; const TEMPLATE = ip: "0.0.0.0" encryption: mode: "aes-gcm" const config = ;config; // "aes-gcm"
Browser usage
When being used in the context of a browser, user-config knows to use localStorage
instead of the filesystem. Storage switching is transparent.