Closed thcolin closed 6 years ago
To apply operations on root object like you do with assign
, you can write it with a .
as path parameter :
const { assign } = require('immutadot')
const current = {}
const next = assign(current, '.', { entities: {}, result: [] })
// { entities: {}, result: [] }
Thanks a lot, I should tried this ! You can close it if you want !
My bad it will create an empty named property with the value :
{
"": { entities: {}, result: [] }
}
We won't implement operations on root object because javascript already provides tools for that. In your example Object.assign({}, { entities: {}, result: [] })
is already immutable.
I close this issue, feel free to reopen it if you have more arguments.
No problems, thanks for your time !
Prerequisites
Description
I can't assign values on object root like I sometimes do in vanilla:
Only for bugs :bug:
Version : 1.0.0
Expected behavior
Be able to assign values on object root
Actual behavior
Throw
TypeError: path should not be empty
How to reproduce
See runkit
Only for feature requests :sparkles:
Don't know if it's possible or a good practice, but it would be nice to be able to assign values on object root
Example