fn throttle
Keeps the first element of every interval of d, drops the rest.
Example:
use std.stream { throttle }
fn nums() -> stream<i32> {
for i in 1..=3 { yield i }
}
fn main() io, time {
var out: List<i32> = []
// all three arrive within the interval: only the first passes
for await x in nums() |> throttle(1h) {
out.push(x)
}
print("{out}")
}Вывод
[1]
pub(api) fn throttle<T, E>(s: stream<T, E>, d: Duration) -> stream<T, E> timeСложность. O(1) per element.
С версии. 1.0.0-beta
Параметры
Возвращает
stream<T, E>
Эффекты
time
Определено в: std/stream/stream.oxl:451