Open
Conversation
Co-authored-by: fregante <1402241+fregante@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Export in-flight only memoizer helper function
Add support for Oct 16, 2025
cache: 'while-pending' option
fregante
approved these changes
Oct 16, 2025
fregante
left a comment
Collaborator
There was a problem hiding this comment.
@sindresorhus since false and while-pending are equivalent, should we deprecate and then remove "false"?
fregante
marked this pull request as ready for review
October 16, 2025 06:38
Owner
|
We can soft-deprecate it by removing it from the readme, but I don't see a strong urge to officially deprecate it for existing users yet. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #53
This PR adds support for
cache: 'while-pending'as a more readable alternative tocache: falsefor 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
cache: falsesyntax is not self-documenting and requires comments to clarify its behavior.Solution
This PR implements
cache: 'while-pending'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
Optionstype now acceptscache: 'while-pending'in addition tofalseand cache storage objects'while-pending'is normalized tofalsefor processing, maintaining all existing behaviorcache: falseandcache: 'while-pending'behave identically - they disable persistent caching but still deduplicate concurrent requestscache: falsecontinues to work unchangedChanges
'while-pending'as a cache option'while-pending'the same asfalseAll tests pass (27/27) ✅
Original prompt
Fixes #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.