Skip to content

Commit

Permalink
fix(Object.copy): do not upgrade primitives to objects
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed Oct 13, 2017
1 parent 58da5a4 commit dd4d88f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
4 changes: 1 addition & 3 deletions object/copy-deep.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,5 @@ var copyValue = function (value, ancestors, ancestorsCopy) {
};

module.exports = function (source) {
var obj = Object(ensureValue(source));
if (obj !== source) return obj;
return copyValue(obj, [], []);
return copyValue(ensureValue(source), [], []);
};
1 change: 1 addition & 0 deletions test/object/assign-deep.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ module.exports = function (t, a) {
var obj1 = { foo: { bar: 3, marko: true } }
, obj2 = { foo: { elo: 12, marko: false }, miszka: [23] };
a.deep(t({}, obj1, obj2), { foo: { bar: 3, marko: false, elo: 12 }, miszka: [23] });
a(t(true), true);
};
1 change: 1 addition & 0 deletions test/object/copy-deep.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ module.exports = function (t, a) {
a.not(o["jedenaście"], no["jedenaście"]);
a.not(o["jedenaście"][1], no["jedenaście"][1]);
a.not(o["jedenaście"][1][2], no["jedenaście"][1][2]);
a(t(true), true);
};

0 comments on commit dd4d88f

Please sign in to comment.