de5695339d
Before: Used recursive setTimeout calls via unpause, creating nested closures and multiple timer contexts. After: - Tracks a single timeoutId to manage timer lifecycle - Eliminates nested closure creation - Cleaner timer chain when calls are pending 2. batch (line 1204-1227) Before: Used throttle internally, inheriting its timer overhead. After: - Direct timer management without the throttle wrapper - Single timeoutId tracked explicitly - Maintains the same semantics (first item processed immediately, rest batched) 3. batcher (line 1235-1259) Before: - Created new timer every time queue went from empty to non-empty - Had unnecessary async in forEach and await r when r was already type U After: - Tracks timeoutId to prevent duplicate timer creation - Only creates timer when queue is truly empty - Removed unnecessary async/await in result handling - More efficient error handling (rejects all items at once if length mismatch) Performance Benefits: These changes should significantly reduce timer overhead by: - Fewer timer objects: Only one active timer per throttled/batched function instead of chains - Less garbage collection: Fewer closure allocations and intermediate objects - Better memory usage: Explicit timer ID tracking instead of implicit state in closures