Comparing version 1.1.0 to 1.2.0
# Change History | ||
## 1.2.0 (2014-05-27) | ||
* Added default implicit sets when getting a config key. | ||
## 1.1.0 (2014-05-20) | ||
@@ -4,0 +8,0 @@ |
@@ -21,10 +21,15 @@ module.exports = ConfigStore; | ||
/** | ||
* Get a value from the store. | ||
* @param {string} key | ||
* @param {any} defaultValue Will write this value to the store if there is | ||
* none already there. | ||
* @return {any} | ||
*/ | ||
ConfigStore.prototype.get = function(key) | ||
ConfigStore.prototype.get = function(key, defaultValue) | ||
{ | ||
var _ref = this._resolve(key); | ||
if (_ref.root === undefined) | ||
if (_ref.root === undefined && defaultValue === undefined) | ||
return undefined; | ||
else if (defaultValue !== undefined) | ||
_ref.root[_ref.key] = defaultValue; | ||
return _ref.root[_ref.key]; | ||
@@ -34,2 +39,3 @@ }; | ||
/** | ||
* Set a value in the store. | ||
* @param {string} key | ||
@@ -36,0 +42,0 @@ * @param {any} value |
{ | ||
"name": "billy", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "A minimal application harness that stays out of your way and out of your code.", | ||
@@ -5,0 +5,0 @@ "author": { |
@@ -47,1 +47,8 @@ var test = require('tape'); | ||
}); | ||
test('default values', function(t) { | ||
t.plan(2); | ||
var config = new ConfigStore().getStore(); | ||
t.strictEqual(config('a.b.c', 1), 1, 'implicit set and return'); | ||
t.strictEqual(config('a.b.c'), 1, 'actually set'); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20554
403