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

Export "in-flight only memoizer" #53

Open
fregante opened this issue Feb 1, 2023 · 5 comments
Open

Export "in-flight only memoizer" #53

fregante opened this issue Feb 1, 2023 · 5 comments

Comments

@fregante
Copy link
Collaborator

fregante commented Feb 1, 2023

I don't know what this means:

pMemoize(fn, {cache: false})

I have to document it every time:

pMemoize(fn, {cache: false /* only while pending */})

The module can export a more readable helper instead:

export const pMemoizePending = (fn, opts) => pMemoize(fn, {...opts, cache: false})

Note: the types of opts should exclude cache

Some tags could also be added to package.json

@sindresorhus
Copy link
Owner

I would prefer to fix main signature. Maybe a new option instead of setting cache to false? The problem with exporting a separate method is that we have to explain it doesn't have a cache setting and also need to add yet another method for a decorator version.

@Richienb Any thoughts on this?

@fregante
Copy link
Collaborator Author

fregante commented Feb 6, 2023

I don't think that's a big ask. The documentation would look like

memInFlight(fn, options)

Like mem, but just while pending. The options are the same except you can't pass a custom cache.


Same for the decorator. I do agree it's not optimal but… in the code it still reads better than any option could, IMHO

@Richienb
Copy link
Contributor

Richienb commented Feb 7, 2023

Maybe a new option instead of setting cache to false?

cache: pending?

@fregante
Copy link
Collaborator Author

I think cache: 'while-pending' is clear enough. "Pending" alone doesn't give enough information and still requires a comment

@sindresorhus
Copy link
Owner

Let's go with cache: 'while-pending'.

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

No branches or pull requests

3 participants