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

Using mem with many-keys-map #52

Closed
papb opened this issue Feb 20, 2020 · 4 comments
Closed

Using mem with many-keys-map #52

papb opened this issue Feb 20, 2020 · 4 comments

Comments

@papb
Copy link
Contributor

papb commented Feb 20, 2020

Hello @fregante, I noticed that you are a maintainer of mem and also the owner of many-keys-map. Is there an easy way to create a memoized version of a function with multiple arguments by internally using your many-keys-map as a cache keeper? Thanks!

@fregante
Copy link
Collaborator

Yes, I think you need this:

mem(fn, {
  cache: new ManyKeysMap(),
  cacheKey: args => args
});

@papb
Copy link
Contributor Author

papb commented Feb 20, 2020

Thanks for the fast response, I will try it out later, and if I have trouble I will post here.

@papb papb closed this as completed Feb 20, 2020
@sindresorhus
Copy link
Owner

@fregante If it works, this would be a good tip for the readme.

@papb papb reopened this Feb 20, 2020
@fregante
Copy link
Collaborator

Done in #55

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants