-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
_.replace does not get rich objects #117
Comments
Hmm. Your sandbox example didn't have code to demonstrate this. But i think i see the problem. It's that we avoid sending functions to JSON.stringify and the _.replace check happens in that expression. I'll try to get a fix up soon. |
Turns out, JSON.stringify appears to be the issue: Try this: Spoiler: it doesn't return '{"d":"Date!"}'. Not sure why... |
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify So it's because Date has a toJSON() method which supersedes the replacer function. Not sure there's any easy way to get the behavior you want, and honestly, i'm not sure i even should do that behavior. |
Sorry about that, somehow the sandbox got reset to default. Glad you noticed the issue in any case. I can workaround this problem, but I think the docs should be updated to reflect this. They specifically call out this case and it doesn't work. |
The docs have this lovely pitch for custom serialization
But its not true: if you create a function on
store._.replace
and serialize an object with a Date Key it will receive a Date value that has already been serialized to a string.Am I missing something, or has this regressed somehow?
Vanilla Sandbox Example
The text was updated successfully, but these errors were encountered: