GitShow/sindresorhus/p-memoize
sindresorhus

p-memoize

Memoize promise-returning & async functions

by sindresorhus
Star on GitHubForknpm

TypeScript

449 stars32 forks14 contributorsActive · 1mo agoSince 2016v8.0.0MIT

Meet the team

See all 14 on GitHub →
sindresorhus
sindresorhus34 contributions
Richienb
Richienb5 contributions
fregante
fregante3 contributions
BendingBender
BendingBender2 contributions
krystofwoldrich
krystofwoldrich2 contributions
fungiboletus
fungiboletus1 contribution
henhal
henhal1 contribution
jdiamond
jdiamond1 contribution

Languages

View on GitHub →
TypeScript100%

Commit activity

Last 12 weeks · 0 commits

Full graph →

Community health

4 of 6 standards met

Community profile →
85
✓README✓License✓Contributing✓Code of Conduct○Issue Template○PR Template

Recent PRs & issues

Active · 1 in progress · Last activity 1mo ago
See all on GitHub →
Copilot
Add support for `cache: 'while-pending'` optionOpenPR

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.

Copilot · 1mo ago
fregante
Export "in-flight only memoizer"OpenIssue

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

fregante · 10mo ago

Recent fixes

View closed PRs →
sindresorhus
Add `shouldCache` optionMergedPR

Fixes #57

sindresorhus · 1y ago
fregante
`cache` type only takes `unknown` as keyClosedIssue

I'm trying to write a local filesystem cache: Every cache method is failing with:

fregante · 1y ago
fregante
Ensure `pMemoizeDecorator` works with TypeScript 5.0ClosedIssue

Changes are coming: https://devblogs.microsoft.com/typescript/announcing-typescript-5-0-beta/#decorators The docs should also be updated.

fregante · 1y ago
Structured data for AI agents

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.

·@ofershap

Replace github.com with gitshow.dev