-
-
Notifications
You must be signed in to change notification settings - Fork 37
fix: deep assign should ignore inseparable object #7
Conversation
also fix failed test: support |
Thank you @coderhaoxin, but that's not how Object.assign works, e.g: // this PR:
> deepAssign({regexp: /reg/}, {regexp: 'string'});
{regexp: 'string'}
// but:
> Object.assign(/reg/, 'string')
{ /reg/ '0': 's', '1': 't', '2': 'r', '3': 'i', '4': 'n', '5': 'g' } |
@@ -137,7 +165,7 @@ test('support `Object.create(null)` objects', t => { | |||
test('support `Object.create(null)` targets', t => { | |||
var obj = Object.create(null); | |||
obj.foo = true; | |||
t.same(fn(obj, {bar: false}), {foo: true, bar: false}); | |||
t.same(fn({}, obj, {bar: false}), {foo: true, bar: false}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing is wrong with this test. The first deep-assign argument is the target and this test asserts, that the following does not throw an Error:
deep-assign(Object.create(null), …)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@coderhaoxin Thank you for mentioning that. You were right, this test had to be repaired (e252fa2).
@schnittstabil Oh, I miss something. Thx |
@schnittstabil I mean, is it reasonable that deepAssign({regexp: /reg/}, {regexp: 'string'}); should equal to Object.assign(/reg/, 'string') for the property |
The project description of deep-assign says:
@coderhaoxin Therefore I would say yes, in my opinion it is the canonical way. But I must admit that the behavior is not very obvious, which is shown by #3, #4, #6. I am open to new interpretations of recursive and assign, but |
@coderhaoxin merge-options might be of interest to you. |
No description provided.