@thi.ng/transducers-async
Version:
Async versions of various highly composable transducers, reducers and iterators
16 lines (15 loc) • 412 B
JavaScript
import { now, timeDiff } from "@thi.ng/timestamp";
import { iterator1 } from "./iterator.js";
import { throttle } from "./throttle.js";
function throttleTime(delay, src) {
return src ? iterator1(throttleTime(delay), src) : throttle(() => {
let prev = 0;
return () => {
const t = now();
return timeDiff(prev, t) >= delay ? (prev = t, true) : false;
};
});
}
export {
throttleTime
};