fuzetsu / mergerino

immutable merge util for state management
MIT License
71 stars 6 forks source link

when copying source object also copy prototype #7

Open fuzetsu opened 5 years ago

fuzetsu commented 5 years ago

fixes #6

fuzetsu commented 5 years ago

Should we use new source.constructor() instead? Current implementation will not execute constructor when copying, meaning we could miss side effects in the constructor or if the returned object is overridden. What is more correct?

EDIT:

If the returned object is overridden then the prototype would most likely be lost or different (but not necessarily) so that might not be an important factor.

Side effects aren't particularly desirable in this context I feel, so also maybe not a factor.