ecmascript-immutable-data-structures
ecmascript-immutable-data-structures copied to clipboard
Ability to set multiple values at once
When you need to add multiple values, there is little sense in doing separate operations (and also creating intermediate objects) like:
const a = ImmutableMap([['x', 1], ['y', 2]]);
const b = a.set('z', 3).set('t', 4);
It would be nice to have .extend
method that would allow to do things like:
const a = ImmutableMap([['x', 1], ['y', 2]]);
const b = a.extend({z: 3, t: 4}); // or a.extend(#{z: 3, t: 4});
I believe this is something that can be handled by a merge
operation. extend
is surely confusing and hugely overloaded term.
@skrat merge
also doesn't exist at the moment. I don't care whether it will be called merge
, extend
or assign
, the functionality is what's interesting.
I believe ideas is that spread operator will handle that:
const b = #{ ...a, z: 3, t: 4};
@Gozala: That applies to Record
, not ImmutableMap
.