mixin-deep
Advanced tools
Comparing version 1.1.1 to 1.1.2
44
index.js
'use strict'; | ||
var isObject = require('is-plain-object'); | ||
var forOwn = require('for-own'); | ||
var lazy = require('lazy-cache')(require); | ||
lazy('is-extendable', 'isExtendable'); | ||
lazy('for-in', 'forIn'); | ||
function mixinDeep(o, objects) { | ||
if (!isObject(o)) return {}; | ||
if (!isObject(objects)) return o; | ||
// don't slice args for v8 optimizations | ||
var len = arguments.length - 1; | ||
for (var i = 0; i < len; i++) { | ||
var obj = arguments[i + 1]; | ||
function mixinDeep(target, objects) { | ||
var len = arguments.length, i = 0; | ||
while (++i < len) { | ||
var obj = arguments[i]; | ||
if (isObject(obj)) { | ||
forOwn(obj, copy, o); | ||
lazy.forIn(obj, copy, target); | ||
} | ||
} | ||
return o; | ||
return target; | ||
} | ||
/** | ||
* copy properties from the source object to the | ||
* Copy properties from the source object to the | ||
* target object. | ||
* | ||
* @param {*} `value` | ||
* @param {*} `val` | ||
* @param {String} `key` | ||
*/ | ||
function copy(value, key) { | ||
function copy(val, key) { | ||
var obj = this[key]; | ||
if (isObject(value) && isObject(obj)) { | ||
mixinDeep(obj, value); | ||
if (isObject(val) && isObject(obj)) { | ||
mixinDeep(obj, val); | ||
} else { | ||
this[key] = value; | ||
this[key] = val; | ||
} | ||
@@ -39,2 +36,13 @@ } | ||
/** | ||
* Returns true if `val` is an object or function. | ||
* | ||
* @param {any} val | ||
* @return {Boolean} | ||
*/ | ||
function isObject(val) { | ||
return lazy.isExtendable(val) && !Array.isArray(val); | ||
} | ||
/** | ||
* Expose `mixinDeep` | ||
@@ -41,0 +49,0 @@ */ |
{ | ||
"name": "mixin-deep", | ||
"description": "Deeply mix the properties of objects into the first object. Like merge-deep, but doesn't clone.", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"homepage": "https://github.com/jonschlinkert/mixin-deep", | ||
@@ -23,8 +23,9 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)", | ||
"dependencies": { | ||
"for-own": "^0.1.3", | ||
"is-plain-object": "^2.0.0" | ||
"for-in": "^0.1.4", | ||
"is-extendable": "^0.1.1", | ||
"lazy-cache": "^0.2.3" | ||
}, | ||
"devDependencies": { | ||
"mocha": "^2.2.4", | ||
"should": "^6.0.1" | ||
"mocha": "*", | ||
"should": "*" | ||
}, | ||
@@ -43,3 +44,13 @@ "keywords": [ | ||
"values" | ||
] | ||
], | ||
"verbiage": { | ||
"related": { | ||
"list": [ | ||
"mixin-object", | ||
"merge-deep", | ||
"extend-shallow", | ||
"defaults-deep" | ||
] | ||
} | ||
} | ||
} |
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
4875
42
3
+ Addedfor-in@^0.1.4
+ Addedis-extendable@^0.1.1
+ Addedlazy-cache@^0.2.3
+ Addedfor-in@0.1.8(transitive)
+ Addedis-extendable@0.1.1(transitive)
+ Addedlazy-cache@0.2.7(transitive)
- Removedfor-own@^0.1.3
- Removedis-plain-object@^2.0.0
- Removedfor-in@1.0.2(transitive)
- Removedfor-own@0.1.5(transitive)
- Removedis-plain-object@2.0.4(transitive)
- Removedisobject@3.0.1(transitive)