From aebc7af3424d7fb9e28002f524dc000a7cf284b3 Mon Sep 17 00:00:00 2001 From: Philippe Hausler Date: Fri, 18 Feb 2022 00:07:55 -0800 Subject: [PATCH] instant math for throttle --- Sources/AsyncAlgorithms/AsyncThrottleSequence.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/AsyncAlgorithms/AsyncThrottleSequence.swift b/Sources/AsyncAlgorithms/AsyncThrottleSequence.swift index 34cbc88..cec6ca8 100644 --- a/Sources/AsyncAlgorithms/AsyncThrottleSequence.swift +++ b/Sources/AsyncAlgorithms/AsyncThrottleSequence.swift @@ -77,7 +77,7 @@ extension AsyncThrottleSequence: AsyncSequence { return nil } let reduction = await reducing(reduced, element) - if clock.now - start >= interval { + if start.duration(to: clock.now) >= interval { return reduction } else { reduced = reduction