https://github.com/apsdehal/configry
Configry is a config manager library for Javascript.
https://github.com/apsdehal/configry
Last synced: 4 months ago
JSON representation
Configry is a config manager library for Javascript.
- Host: GitHub
- URL: https://github.com/apsdehal/configry
- Owner: apsdehal
- Created: 2014-02-10T16:58:33.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2015-09-22T08:15:21.000Z (over 10 years ago)
- Last Synced: 2025-01-31T08:02:37.551Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 312 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Configry [](https://travis-ci.org/apsdehal/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](https://github.com/captn3m0/Configurator)
## Install
```
$ npm install --save configry
```
or
Download source from `build/Configry.js` and include `Configry.js` in your html
``
## Usage
Create a config object. The constructor takes two parameters :
1. default: Object holding default configuration values
2. 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:
1. Key Name
2. Value
3. 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.
## Tests
Run `grunt default` command to run tests on karma using phantomjs and jasmine. This task will also run the browserify task. For specific only test task run `grunt karma:unit`
#Licence
Licenced under MIT Licence. Feel free to fork/use.
Configry is build for [SDSLabs Muzi](https://sdslabs.co.in/muzi), a music player application for the IIT-Roorkee Campus.