Closed hughfdjackson closed 11 years ago
This is possibly the role of a supporting library - either as an extension of these methods, or a stand-alone:
var deep = require('immutable-deep')
var updatedUser = deep.assoc(user, 'settings.hideEmailAddress', false)
My patch
function supports deep by default ( https://github.com/Raynos/immutable-hash#hashpatchpath-value ). So does get
( https://github.com/Raynos/immutable-hash#hashgetkey )
It's very pretty - but what do you do when you want to store keys with . in them? escape?
I guess you could, but I feel like it puts 'gotchas' into the landscape.
@hughfdjackson I can trivially make all apis support get("foo.bar")
and get(["foo", "bar"])
I think it'd be fairly easy to implement for immutable too - the question is, should it be implemented that way for something that's aiming to be the bread-and-butter immutable object implementation?
Sometimes I think that 'uncomplex' is the best for those types of implementations - to prevent 'wut' moments, and give the impression of solidity.
For the first draft, going to move this into a util library. Once in, removal from a library is verboten after 1.0.0.
Proposed extensions: