import AsyncAlgorithms
let randomNumbers = AsyncTimerSequence(interval: .seconds(1), clock: .suspending).compactMap { _ in (1000..<9999).randomElement() }
for await value in randomNumbers {
print(value)
}
RunLoop.main.run()
That should be isomorphic to what you are doing btw; except that it wouldn't need to buffer values.