Comparing version 2.2.3 to 2.2.4
@@ -5,3 +5,3 @@ { | ||
"homepage": "https://homer0.github.io/wootils/", | ||
"version": "2.2.3", | ||
"version": "2.2.4", | ||
"repository": "homer0/wootils", | ||
@@ -12,3 +12,3 @@ "author": "Leonardo Apiwan (@homer0) <me@homer0.com>", | ||
"jimple": "1.5.0", | ||
"fs-extra": "7.0.1", | ||
"fs-extra": "8.0.1", | ||
"colors": "1.3.3", | ||
@@ -21,9 +21,10 @@ "urijs": "1.19.1", | ||
"eslint-config-airbnb-base": "13.1.0", | ||
"eslint-plugin-import": "2.17.1", | ||
"eslint-plugin-node": "8.0.1", | ||
"eslint-plugin-import": "2.17.2", | ||
"eslint-plugin-node": "9.0.1", | ||
"jest-ex": "6.0.1", | ||
"jest-cli": "24.7.1", | ||
"jest-cli": "24.8.0", | ||
"jasmine-expect": "4.0.1", | ||
"@babel/preset-env": "7.4.3", | ||
"@babel/core": "7.4.3", | ||
"@babel/preset-env": "7.4.4", | ||
"@babel/core": "7.4.4", | ||
"@babel/plugin-transform-runtime": "7.4.4", | ||
"esdoc": "1.1.0", | ||
@@ -30,0 +31,0 @@ "esdoc-standard-plugin": "1.0.0", |
@@ -14,3 +14,4 @@ const extend = require('extend'); | ||
/** | ||
* This method makes a deep merge of a list of objects into a new one. | ||
* This method makes a deep merge of a list of objects into a new one. The method also supports | ||
* arrays. | ||
* @example | ||
@@ -21,2 +22,7 @@ * const objA = { a: 'first' }; | ||
* // Will output { a: 'first', b: 'second' } | ||
* @example | ||
* const arrA = [{ a: 'first' }]; | ||
* const arrB = [{ b: 'second' }]; | ||
* console.log(ObjectUtils.merge(objA, objB)); | ||
* // Will output [{ a: 'first', b: 'second' }] | ||
* @param {...{Object}} targets The objects to merge. | ||
@@ -26,3 +32,5 @@ * @return {Object} | ||
static merge(...targets) { | ||
return extend(true, {}, ...targets); | ||
const [firstTarget] = targets; | ||
const base = Array.isArray(firstTarget) ? [] : {}; | ||
return extend(true, base, ...targets); | ||
} | ||
@@ -29,0 +37,0 @@ /** |
@@ -27,2 +27,17 @@ jest.unmock('/shared/objectUtils'); | ||
it('should merge two objects from arrays', () => { | ||
// Given | ||
const name = 'Rosario'; | ||
const nickname = 'Charito'; | ||
const arrA = [{ name }]; | ||
const arrB = [{ nickname }]; | ||
let result = null; | ||
// When | ||
result = ObjectUtils.merge(arrA, arrB); | ||
arrA.push('value'); | ||
arrB.push('value'); | ||
// Then | ||
expect(result).toEqual([{ name, nickname }]); | ||
}); | ||
it('should make a copy of an object', () => { | ||
@@ -29,0 +44,0 @@ // Given |
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
550745
6933
15
+ Addedfs-extra@8.0.1(transitive)
- Removedfs-extra@7.0.1(transitive)
Updatedfs-extra@8.0.1