scrivito
Version:
Scrivito is a professional, yet easy to use SaaS Enterprise Content Management Service, built for digital agencies and medium to large businesses. It is completely maintenance-free, cost-effective, and has unprecedented performance and security.
27 lines (22 loc) • 844 B
text/typescript
function noop() {}
let trackTimeoutId: (id: number) => void = noop;
function setTimeoutAndTrackId(handler: Function, timeout?: number): number {
// eslint-disable-next-line no-restricted-globals -- This module is allowed to use setTimeout
const timeoutId = setTimeout(handler, timeout);
trackTimeoutId(timeoutId);
return timeoutId;
}
function setIntervalAndTrackId(handler: Function, timeout?: number): number {
// eslint-disable-next-line no-restricted-globals -- This module is allowed to use setInterval
const timeoutId = setInterval(handler, timeout);
trackTimeoutId(timeoutId);
return timeoutId;
}
export {
setTimeoutAndTrackId as setTimeout,
setIntervalAndTrackId as setInterval,
};
/** For test purposes only */
export function setTimeoutIdTracker(callback: (id: number) => void) {
trackTimeoutId = callback;
}