easy-configuration
Advanced tools
Comparing version 1.4.1 to 1.4.2
// Generated by CoffeeScript 1.6.3 | ||
(function() { | ||
var EasyConfiguration, Extension, Helpers; | ||
var EasyConfiguration, Extension, Helpers, merge; | ||
merge = require('recursive-merge'); | ||
Extension = require('./Extension'); | ||
@@ -127,3 +129,3 @@ | ||
EasyConfiguration.prototype.merge = function(left, right) { | ||
return Helpers.merge(left, right); | ||
return merge(left, right); | ||
}; | ||
@@ -130,0 +132,0 @@ |
// Generated by CoffeeScript 1.6.3 | ||
(function() { | ||
var Helpers; | ||
var Helpers, merge; | ||
merge = require('recursive-merge'); | ||
Helpers = (function() { | ||
function Helpers() {} | ||
Helpers.merge = function(left, right) { | ||
var i, name, type, value, _i, _len; | ||
type = Object.prototype.toString; | ||
if (type.call(left) !== type.call(right)) { | ||
throw new Error('Can not merge two different objects.'); | ||
} | ||
switch (type.call(left)) { | ||
case '[object Array]': | ||
for (i = _i = 0, _len = right.length; _i < _len; i = ++_i) { | ||
value = right[i]; | ||
if (left.indexOf(value) === -1) { | ||
left.push(value); | ||
} else if (type.call(value) === '[object Array]' || type.call(value) === '[object Object]') { | ||
left[i] = this.merge(left[i], value); | ||
} | ||
} | ||
break; | ||
case '[object Object]': | ||
for (name in right) { | ||
value = right[name]; | ||
if (typeof left[name] === 'undefined') { | ||
left[name] = value; | ||
} else if (type.call(value) === '[object Array]' || type.call(value) === '[object Object]') { | ||
left[name] = this.merge(left[name], value); | ||
} | ||
} | ||
} | ||
return left; | ||
}; | ||
Helpers.dirName = function(path) { | ||
@@ -74,3 +46,3 @@ var num; | ||
if (type === '[object Object]') { | ||
result = this.merge(result, this.stringifyParameters(value, name)); | ||
result = merge(result, this.stringifyParameters(value, name)); | ||
} else { | ||
@@ -77,0 +49,0 @@ result[name] = value; |
{ | ||
"name": "easy-configuration", | ||
"description": "Simply extensible loader for json config files", | ||
"version": "1.4.1", | ||
"version": "1.4.2", | ||
"author": { | ||
@@ -26,2 +26,5 @@ "name": "David Kudera", | ||
"main": "./lib/EasyConfiguration.js", | ||
"dependencies": { | ||
"recursive-merge": "latest" | ||
}, | ||
"devDependencies": { | ||
@@ -28,0 +31,0 @@ "should": "1.2.2" |
@@ -132,3 +132,3 @@ # Easy Configuration | ||
EasyConfiguration class has got one other useful method and it is merge. | ||
EasyConfiguration class has got one other useful method and it is merge (using [recursive-merge](https://npmjs.org/package/recursive-merge) package). | ||
@@ -182,2 +182,5 @@ ``` | ||
* 1.4.2 | ||
+ Merging uses [recursive-merge](https://npmjs.org/package/recursive-merge) package | ||
* 1.4.1 | ||
@@ -184,0 +187,0 @@ + Written rest of this changelog |
@@ -8,33 +8,2 @@ (function () { | ||
describe('#merge()', function() { | ||
it('should merge two objects', function() { | ||
Helpers.merge({ | ||
one: { | ||
two: 'two', | ||
three: 'three' | ||
}, | ||
two: 'two' | ||
}, { | ||
one: { | ||
another: 'another' | ||
} | ||
}).should.eql({ | ||
one: { | ||
two: 'two', | ||
three: 'three', | ||
another: 'another' | ||
}, | ||
two: 'two' | ||
}) | ||
}); | ||
it('should merge two arrays', function() { | ||
Helpers.merge([1, 2, 3], [4, 'a', 5]).should.eql([1, 2, 3, 4, 'a', 5]); | ||
}); | ||
it('should throw error if parameters are not the same type', function() { | ||
(function() { Helpers.merge([], {}); }).should.throw(); | ||
}); | ||
}); | ||
describe('#dirName()', function() { | ||
@@ -41,0 +10,0 @@ it('should return name of file\'s directory', function() { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
238
25556
1
445
+ Addedrecursive-merge@latest
+ Addedrecursive-merge@1.2.1(transitive)