-
Notifications
You must be signed in to change notification settings - Fork 75
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
Deep put
#151
Comments
Quick reply for now. I recently fixed a bug with put. I think the example you provided should work as expected with the latest version of 101. Try it out and see if the problem remains: 'npm i --save 101@latest' Lmk,
|
Thanks for the quick reply! <3 Yea, I'm using the latest version. It doesn't seem to be fixed 😕 (Demo). For clarification, the end result (to the object mentioned previously) should be: console.log(user.mother.mother.daughters[0], updated.mother.mother.daughters[0]);
// { name: 'Immaculate Borromeo' }
// { name: 'Immaculate Borromeo', age: 5, height: 6, width: 6 } Moreover, I didn't find any test case about this scenario. Let me know where I can help :) |
I see what you are saying now. Sorry, looked at that too quick on my phone. var keypather = require('keypather')()
var put = require('101/put')
var update = keypather.flatten({
age: 5,
height: 6,
width: 6
}, '.', 'mother.mother.daughters.0')
put(user, update) |
Yea. But to simplify even more, I was wondering if we could achieve the ff: var update = require('101/update');
var updated = update(user, 'mother.mother.daughters.0', {
age: 5,
height: 6,
width: 6
}); Similar to |
Could we extend '101/assign'? |
Assign current only supports a depth of 1 |
And doesn't support keypaths |
I think we could do that, but I think it could complicate |
The plan for assign is to possibly deprecate it in v2.0.0. Actually to get this in before then how about '101/extend'. I am traveling this week, but happy to take a PR. Typed using my thumbs..
|
Oh, how about we name it |
👍 Typed using my thumbs..
|
Currently
put
[immutably] only sets the value to the object path. I was wondering if it would be possible to merge the new object to the current.Sample Data
Current
Suggestion:
Maybe we could have a new method (named
update
) instead of updating the functionality ofput
?Let me know if I missed out anything. Thanks!
The text was updated successfully, but these errors were encountered: