Comments (4)
@bobrenjc93 In my opinion that is the expected behavior, because we Recursively Object.assign():
deep_assign({a: [1]}, {a: []})
// should be similar to
{a: deep_assign([1], [])}
// which have to be the same as
{a: Object.assign([1], [])}
(If Object {a: Array[1]}
means {a: [1]}
)
This is consistent to the current undefined
behavior.
from deep-assign.
I completely understand the recursive nature of this function. The question is what should be the base case. In my opinion, I think it only makes to recurse further if the value is a true object and not an array. In the event the value is not an object, the recursion should halt and behave the same way you'd expect a non recursive Object.assign for that particular value.
Perhaps it would be good to have the context under which this module was developed. I'm currently trying to use this module for a redux application and the behavior I described above was what I would expect in a recursive Object.assign module.
from deep-assign.
I think it only makes to recurse further if the value is a true object and not an array.
True Object is the crux of the matter: e.g Javascript also considers functions to be objects, and there seems no generally accepted definition for True Objects.
npm and bower contain myriad packages for merging/extending/… objects – most of them without a precise semantic. If you agree with me that Plain Objects are the one and only True Objects, schnittstabil/merge-options may meet your requirements.
As Object.assign
does not distinguish Objects
and Arrays
I see no justification to do so in deep-assign
.
from deep-assign.
Ah okay makes sense. merge-options is exactly what I need, I'll go use that. Thanks!
from deep-assign.
Related Issues (20)
- Check "support symbols as targets" fails on ava 0.5.0 HOT 1
- Option to not throw TypeError for null or undefined targets HOT 11
- Simplify HOT 1
- Deep assigning objects with different property types HOT 1
- Does not work with sealed objects HOT 2
- What is the difference deep assigning with JSON.parse? HOT 1
- Assigning an array shorter than previous one results in merged array HOT 2
- deep assign and functions HOT 2
- property with null value in source object not overwriting to same property in target object HOT 6
- Source object get manipulated HOT 3
- it mutates *some* of the sources HOT 5
- Why should this module not be used? HOT 3
- regular expressions are being ignored HOT 2
- Can you add a param(value) which is equal undefined during assigning HOT 1
- Set not being overwritten HOT 3
- Deep-copying arrays HOT 17
- Incorrectly assign object with function as value HOT 2
- Regression in 2.0.0 HOT 11
- test fails: support symbols as targets HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from deep-assign.