rtfeldman / seamless-immutable

Immutable data structures for JavaScript which are backwards-compatible with normal JS Arrays and Objects.
BSD 3-Clause "New" or "Revised" License
5.36k stars 194 forks source link

api question/suggestion for Immutable.from() #222

Open raould opened 7 years ago

raould commented 7 years ago

Premature optimization suggestion, the idea being to avoid merge() calls if possible. See the Clojure transients stuff I think off the top of my head for similar thoughts on using mutation for efficiency inside an otherwise immutable world.

(1) basic

Immutable.from({foo:1},{bar:2}); // returns {foo:1,bar:2}.
Immutable.from({foo:1},{foo:2}); // returns {foo:2}.

(2) more bonus, pesudocode:

Immtuable.from({foo:1,bar:2},(e)=>{e.foo=()=>42}); // returns {foo:42,bar:2}.