You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
2015-03-18T03:17:29.895Z
/Users/matt/Playground/seamless-immutable/index.js:5
console.log(d.date.toISOString());
^
TypeError: undefined is not a function
at Object.<anonymous> (/Users/matt/Playground/seamless-immutable/index.js:5:20)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
The text was updated successfully, but these errors were encountered:
This is because currently seamless-immutable does not copy over prototypes, and as such always returns a vanilla Object.
Copying over prototypes is a bit of a double-edged sword. Something like .toISOString() should work as normal on an immutable object, so there's not much downside there. However, other methods might attempt to mutate the object and then fail silently (depending on whether Strict Mode is enabled). There's an element of "buyer beware" to copying prototypes.
That said, I suppose there's not much difference between deciding to use a prototype with mutating methods and just attempting to mutate an immutable object yourself, so on balance this seems like a reasonable change to make. At the very least, it ought to address the proximal issue of Date.toISOString becoming unavailable.
Example:
Console:
The text was updated successfully, but these errors were encountered: