0no-co / wonka

🎩 A tiny but capable push & pull stream library for TypeScript and Flow
MIT License
709 stars 29 forks source link

`Wonka.throttle` example emits `0 5` instead of `0 6` #106

Closed idkjs closed 3 years ago

idkjs commented 3 years ago
> node src/Throttle.bs.js 
## throttle

`throttle` emits values of a source, but after each value it will omit all values for
the given amount of milliseconds. It enforces a time of silence after each value it
receives and skips values while the silence is still ongoing.

This is very similar to `debounce` but instead of waiting for leading time before a
value it waits for trailing time after a value.

> _Note:_ This operator is only available in JavaScript environments, and will be excluded
> when compiling natively.

```reason
Wonka.interval(10)
  |> Wonka.throttle((. _x) => 50)
  |> Wonka.take(2)
  |> Wonka.subscribe((. x) => print_int(x));
/* Outputs 0 6 to the console. */

05⏎ >

kitten commented 3 years ago

This is timing sensitive and the ode given in examples is just that; just an example