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

Can it work with functions as arguments? #5

Open
bugeats opened this issue Dec 20, 2019 · 1 comment
Open

Can it work with functions as arguments? #5

bugeats opened this issue Dec 20, 2019 · 1 comment

Comments

@bugeats
Copy link

bugeats commented Dec 20, 2019

Neat project. It doesn't seem to cache if a named function is used as a argument to the memoized function. Is this possible with WeakMap/Map?

@kevincennis
Copy link
Member

It should work for named functions.

function caller( fn ) {
  return fn();
}

function rand() {
  return Math.random();
}

const mem = memoize( caller );

mem( rand ) === mem( rand ); // true

Can you post an example of what you're trying that doesn't seem to work?

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

2 participants