settings-lib
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -0,37 +1,41 @@ | ||
# v0.1.4 / 2015-11-11 | ||
* Fixed issue where type coercion would not work properly on deeply nested configuration | ||
# v0.1.3 / 2015-06-25 | ||
* Updating async module dependency | ||
* Updated async module dependency | ||
# v0.1.2 / 2015-05-28 | ||
* Adjusting command line and environment maps to attempt to coerce config override values based on the type found in the default settings | ||
* Adjusted command line and environment maps to attempt to coerce config override values based on the type found in the default settings | ||
# v0.1.1 / 2015-03-19 | ||
* Increasing verbosity of error when unable to parse JSON config | ||
* Increased verbosity of error when unable to parse JSON config | ||
# v0.1.0 / 2015-03-18 | ||
* Building support for Node v0.12 | ||
* Added support for Node v0.12 | ||
# 0.0.5 / 2014-11-24 | ||
# v0.0.5 / 2014-11-24 | ||
* Adjusting for changes in how jscoverage works | ||
* Adjusted for changes in how jscoverage works | ||
# 0.0.4 / 2014-11-24 | ||
# v0.0.4 / 2014-11-24 | ||
* Updating dependencies | ||
* Updated dependencies | ||
# 0.0.3 / 2014-11-24 | ||
# v0.0.3 / 2014-11-24 | ||
* Fixing incorrect information in the readme.md | ||
* Fixed incorrect information in the readme.md | ||
# 0.0.2 / 2014-02-25 | ||
# v0.0.2 / 2014-02-25 | ||
* Adding support for Travis CI builds | ||
* Added support for Travis CI builds | ||
* Increased unit test coverage | ||
* Updated dependency for Async | ||
# 0.0.1 / 2013-11-26 | ||
# v0.0.1 / 2013-11-26 | ||
* Initial release of library |
@@ -18,12 +18,13 @@ var | ||
function buildDefaultTypesMap (source, keyParts) { | ||
function buildDefaultTypesMap (source, parentPath) { | ||
'use strict'; | ||
keyParts = keyParts || []; | ||
var keyPath; | ||
Object.keys(source).forEach(function (key) { | ||
keyParts.push(key); | ||
keyPath = parentPath ? [parentPath, key].join('.') : key; | ||
// array coercion | ||
if (Object.prototype.toString.call(source[key]) === '[object Array]') { | ||
defaultTypesMap[keyParts.join('.')] = function (value) { | ||
defaultTypesMap[keyPath] = function (value) { | ||
if (Array.isArray(value)) { | ||
@@ -36,21 +37,23 @@ return value; | ||
}; | ||
keyParts.pop(); | ||
return; | ||
} | ||
// date coercion | ||
if (Object.prototype.toString.call(source[key]) === '[object Date]') { | ||
defaultTypesMap[keyParts.join('.')] = function (value) { | ||
defaultTypesMap[keyPath] = function (value) { | ||
return new Date(value); | ||
}; | ||
keyParts.pop(); | ||
return; | ||
} | ||
if (typeof source[key] === 'object' && source[key] !== null) { | ||
return buildDefaultTypesMap(source[key], keyParts); | ||
// object coercion | ||
if (typeof source[key] === 'object' && | ||
/^\[object\sObject\]$/.test(source[key].toString()) && | ||
source[key] !== null) { | ||
return buildDefaultTypesMap(source[key], keyPath); | ||
} | ||
defaultTypesMap[keyParts.join('.')] = function (value) { | ||
defaultTypesMap[keyPath] = function (value) { | ||
switch (typeof source[key]) { | ||
@@ -66,4 +69,2 @@ case 'boolean': | ||
keyParts.pop(); | ||
return; | ||
@@ -70,0 +71,0 @@ }); |
@@ -5,3 +5,3 @@ { | ||
"main": "./lib/settings.js", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"author": "Joshua Thomas (http://github.com/brozeph)", | ||
@@ -8,0 +8,0 @@ "engines": { |
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
32833
812