Skip to content

Fix limitFunction queue clearing - #109

Merged
sindresorhus merged 1 commit into
sindresorhus:mainfrom
lprnmns:fix-limit-function-clear-queue
Aug 31, 2026
Merged

sindresorhus merged 1 commit into
sindresorhus:mainfrom
lprnmns:fix-limit-function-clear-queue

Conversation

@lprnmns

@lprnmns lprnmns commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Problem

limitFunction() accepts and documents rejectOnClear, but the returned function does not expose clearQueue(). Callers therefore cannot trigger the promised rejection behavior, and attempting to do so throws TypeError: limitedFunction.clearQueue is not a function.

Fix

Expose the internal limiter's existing clearQueue method on the returned limited function, reflect it in the TypeScript return type, and document the method. This reuses the established queue-clearing behavior without changing scheduling or call signatures.

Tests

  • npm exec ava -- --match='limitFunction exposes clearQueue' — passed (1 test)
  • npm exec tsd — passed
  • npm test — passed (23 AVA tests; one pre-existing XO TODO warning)
  • git diff --check — passed

Compatibility

This adds a non-enumerable method to functions returned by limitFunction(). Existing calls and concurrency behavior are unchanged; clearing delegates to the internal limiter's existing rejectOnClear semantics.

Related issue

No linked issue. Reproduced on main at df476048d023ff868cd45b35ee47f5fb0ca2b25a; live issue/PR and focused duplicate searches found no competing 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

Successfully merging this pull request may close these issues.

2 participants