store-settings
v1.2.1
Published
A standalone class for express style application settings
Downloads
11
Readme
Express Compatible Settings Store
A stand-alone implementation of the settings portion of express. The class that is exported can be mixed into or extended from in your application.
Usage
$ npm install --save store-settings
var Settings = require('store-settings');
// Create a store
var store = new Settings();
// Set values on the store
store.set('foo', 'bar');
// Get a value
store.get('foo'); // 'bar'
// Boolean values
store.enable('yep');
store.enabled('yep'); // true
store.disabled('yep'); // false
store.disable('yep');
store.disabled('yep'); // true
store.enabled('yep'); // false
// Setter methods
var store2 = new Settings({
setters: {
foo: function (val) {
this.set('foobar', 'foo' + val);
}
}
});
store2.set('foo', 'bar');
store.get('foobar'); // 'foobar'
// Extending from
class Foo extends Settings {
foo () {
return this.get('foo');
}
}
var foo = new Foo();
foo.set('foo', 'bar');
foo.foo(); // 'bar'