Skip to content
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

Bug on line 40: handling of string argument #7

Closed
vsumitra opened this issue May 31, 2019 · 5 comments
Closed

Bug on line 40: handling of string argument #7

vsumitra opened this issue May 31, 2019 · 5 comments
Assignees
Labels
bug Something isn't working Fixed v1.1.4

Comments

@vsumitra
Copy link

I believe you meant to serialized s not t in that case, otherwise your cache key will always be "string", please check.

@anywhichway anywhichway self-assigned this May 31, 2019
@anywhichway anywhichway added bug Something isn't working Fixed v1.1.4 labels May 31, 2019
@anywhichway
Copy link
Owner

@vsumitra Ouch! Thanks. Fixed. Must have crept in during last round of optimization. Added a unit test to prevent that happening again.

@vsumitra
Copy link
Author

Hi I think this was the intent, there isn't any reason to strigify a string type. plus there not way to utilized p.

var key = t === "number" || t === "boolean" || t === "string" || t === "undefined" ? a : !p ? JSON.stringify(a) : p(a);

@anywhichway
Copy link
Owner

@vsumitra It is absolutely the case there is reason to stringify a string type. Many memoizers actually make a semantic error and treat the memoization of "1" and 1 the same. It is ironic there was a bug in nano-memozie that made an even worse error. See this article: https://codeburst.io/a-key-to-keys-when-javascript-keys-dont-match-ab44c81adc87

@tokland
Copy link

tokland commented Jun 28, 2019

Does it make sense to deprecate affected versions?

https://docs.npmjs.com/deprecating-and-undeprecating-packages-or-package-versions

@anywhichway
Copy link
Owner

@tokland Thank you. Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Fixed v1.1.4
Projects
None yet
Development

No branches or pull requests

3 participants