in lib/src/rate_limit.dart [201:222]
Stream<T> audit(Duration duration) {
Timer? timer;
var shouldClose = false;
T recentData;
return transformByHandlers(onData: (data, sink) {
recentData = data;
timer ??= Timer(duration, () {
sink.add(recentData);
timer = null;
if (shouldClose) {
sink.close();
}
});
}, onDone: (sink) {
if (timer != null) {
shouldClose = true;
} else {
sink.close();
}
});
}