Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Functions aren't getting overridden? #6

Open
rightaway opened this issue Feb 21, 2017 · 6 comments
Open

Functions aren't getting overridden? #6

rightaway opened this issue Feb 21, 2017 · 6 comments
Labels

Comments

@rightaway
Copy link

I have some function definitions specified in objects and would like them to get overridden when objects are being combined using assign-deep, but it seems to work for all object keys except those referring to function definitions.

a = {
  string: 'a'
  func: a => a,
}
b = {
  string: 'b'
  func: b => b,
}
c = assignDeep({}, a, b)

console.log(c.string) // prints 'b' as expected
console.log(c.func.toString()) // prints 'a => a', not as expected
@jonschlinkert
Copy link
Owner

Hmm, I agree that doesn't seem right. I'll take a look, thanks

@jonschlinkert
Copy link
Owner

I think this is the offending code, https://github.com/jonschlinkert/assign-deep/blob/master/index.js#L43. But I can't remember why it's done that way.

@rightaway
Copy link
Author

rightaway commented Feb 21, 2017

Yeah, it only seems to work when a doesn't have func but doesn't if both a and b have func. Can't think of any reason for it to operate that way. Do you think you would provide a fix for it, is it even a bug?

Btw if I use Object.assign it works as expected on the top level of the object (overwriting the function in the result object).

@jonschlinkert
Copy link
Owner

do you think you would provide a fix for it, is it even a bug?

I can't think of a reason that it should work the way it does, but I haven't had a chance to review the unit tests. I plan to push up a fix

@lihroff
Copy link

lihroff commented Feb 20, 2019

I have worked for it and it still WIP. If you like to see: https://github.com/Tommy-White/deeplyAssign
image

@lihroff
Copy link

lihroff commented Feb 21, 2019

@jonschlinkert
It has been basically completed so far。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants