configry
v1.1.3
Published
Javascript configuration library to handle an application's configuration. Stores config to localstorage.
Downloads
2
Maintainers
Readme
Configry
Configry is a config manager library for Javascript. It uses localStorage to store persistent configurations in the browser. Use it woth your favorite tool like browserify or get a precompiled bundle from bower.
Configry is CommonJS version for captn3m0's Configurator
Install
$ npm install --save configry
or
Download source from build/Configry.js
and include Configry.js
in your html
<script src="Configry.js"></script>
Usage
Create a config object. The constructor takes two parameters :
- default: Object holding default configuration values
- persistent: Array of key strings for persistent configuration.
var config= new Configry({sound:true,autoPlay:false,volume:60},['volume']);
//volume property will persist even after refreshes using localstorage.
//Set additional configuration options
config.set("shuffle",true,true);
API
.set takes three parameters:
- Key Name
- Value
- Persistent (true/false)
var shuffleState = config.get('shuffle');
//Will get the value of the config option.
Localstorage clearing
Since Configry stores the persistent config information in localstorage, you cannot clear localstorage using localStorage.clear any more. Instead use config.clearLS()
function to clear the localStorage. It will clear localstorage, and write the persistent config keys back into localStorage.
#Licence
Licenced under MIT Licence. Feel free to fork/use.
Configry is build for SDSLabs Muzi, a music player application for the IIT-Roorkee Campus.