Skip to content

feat: add throttle function and @throttle decorator #72

Description

@tabkram

Goal

Add a throttle() function and @throttle() method decorator for sync and async functions.

constfetchProfile=throttle(async(userId: string)=>api.getProfile(userId),{limit: 3,interval: 1_000});

Scope

  • Configurable limit and interval
  • leading / trailing behavior
  • Preserve this, arguments, return type and errors
  • Per-instance state for decorated instance methods
  • AbortSignal, cancel(), and queue-size visibility
  • Unit tests and documentation

Trace integration

Record delayed, executed, cancelled, and rejected calls in the engine trace.

Acceptance criteria

  • Supports synchronous and Promise-returning functions
  • Concurrent callers retain their original arguments and receive the correct outcome
  • Decorator state is isolated per class instance
  • Public API is exported from the package entry point

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions