tahamajs's picture
download
raw
573 Bytes
// @flow strict
/**
* Throttle the given function to run at most every `period` milliseconds.
* @private
*/
export default function throttle(fn: () => void, time: number): () => ?TimeoutID {
let pending = false;
let timerId: ?TimeoutID = null;
const later = () => {
timerId = null;
if (pending) {
fn();
timerId = setTimeout(later, time);
pending = false;
}
};
return () => {
pending = true;
if (!timerId) {
later();
}
return timerId;
};
}

Xet Storage Details

Size:
573 Bytes
·
Xet hash:
b7ecf7389ec1e8c23c2e72d1473ebc8a6640977802d6865315d1b4c2b756e71c

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.