Last 12 weeks · 0 commits
4 of 6 standards met
Fixes #53 This PR adds support for as a more readable alternative to for disabling result caching while still deduplicating concurrent in-flight requests. Problem Previously, to enable in-flight deduplication without persistent caching, users had to write: The syntax is not self-documenting and requires comments to clarify its behavior. Solution This PR implements as discussed in the issue comments: This is much more readable and self-explanatory - it clearly indicates that results are only memoized while the promise is pending (in-flight), but not after resolution. Implementation Details The type now accepts in addition to and cache storage objects Internally, is normalized to for processing, maintaining all existing behavior Both and behave identically - they disable persistent caching but still deduplicate concurrent requests The change is fully backward compatible - existing code using continues to work unchanged Changes Updated TypeScript types to accept as a cache option Added normalization logic to treat the same as Added comprehensive tests for the new option Updated documentation in README All tests pass (27/27) ✅ Original prompt This section details on the original issue you should resolve* Export "in-flight only memoizer" Follows https://github.com/sindresorhus/p-memoize/issues/20#issuecomment-1174567013 I don't know what this means: I have to document it every time: The module can export a more readable helper instead: Note: the types of should exclude Some tags could also be added to package.json create ## Comments on the Issue (you are @copilot in this section) @sindresorhus I would prefer to fix main signature. Maybe a new option instead of setting to ? The problem with exporting a separate method is that we have to explain it doesn't have a setting and also need to add yet another method for a decorator version. @Richienb Any thoughts on this? @fregante 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 @fregante I think is clear enough. "Pending" alone doesn't give enough information and still requires a comment @sindresorhus Let's go with . Fixes sindresorhus/p-memoize#53 ✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
Repository: sindresorhus/p-memoize. Description: Memoize promise-returning & async functions Stars: 449, Forks: 32. Primary language: TypeScript. Languages: TypeScript (100%). License: MIT. Latest release: v8.0.0 (1y ago). Open PRs: 1, open issues: 2. Last activity: 1mo ago. Community health: 85%. Top contributors: sindresorhus, Richienb, fregante, BendingBender, krystofwoldrich, fungiboletus, henhal, jdiamond, jeffal, pdesantis and others.