Skip to content

Commit

Permalink
Fixed sindresorhus#6 (reuses object in deep assignment)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kreozot committed Nov 17, 2015
1 parent 8ef8a6a commit 8a52558
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';
var isObj = require('is-obj');
var isPlainObj = require('is-plain-obj');
var hasOwnProperty = Object.prototype.hasOwnProperty;
var propIsEnumerable = Object.prototype.propertyIsEnumerable;

Expand All @@ -24,7 +25,7 @@ function assignKey(to, from, key) {
}
}

if (!hasOwnProperty.call(to, key) || !isObj(val)) {
if ((!hasOwnProperty.call(to, key) && !isPlainObj(val)) || !isObj(val)) {
to[key] = val;
} else {
to[key] = assign(Object(to[key]), from[key]);
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"properties"
],
"dependencies": {
"is-obj": "^1.0.0"
"is-obj": "^1.0.0",
"is-plain-obj": "^1.1.0"
},
"devDependencies": {
"ava": "*",
Expand Down

0 comments on commit 8a52558

Please sign in to comment.