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.37k stars 195 forks source link

asMutable({deep:true}) doesn't work with date objects. #45

Closed jjulicher closed 8 years ago

jjulicher commented 9 years ago

var test = Immutable({mydate: new Date()}) test.asMutable({deep:true});

result:

Uncaught TypeError: obj.asMutable is not a function at asDeepMutable (http://localhost:8080/resource-bundles/bowerComponents.resource/seamless-immutable/seamless-immutable.js:215:20) at Object.asMutableObject (http://localhost:8080/resource-bundles/bowerComponents.resource/seamless-immutable/seamless-immutable.js:304:31) at Object.eval (eval at evaluate (unknown source), :1:6) at Object.InjectedScript._evaluateOn (:895:55) at Object.InjectedScript._evaluateAndWrap (:828:34) at Object.InjectedScript.evaluateOnCallFrame (:954:21)

scriptguru commented 9 years ago

Why would it work with date objects? I thought it was supposed to work only with data that can be serialized to JSON and deserialized from JSON natively.

Still it's possible to store date as a timestamp to workaround this.