Files
appco_dist/.output/server/chunks/build/raf-ruCY1ktO.mjs
T
2025-07-23 16:57:31 +03:30

34 lines
780 B
JavaScript

let raf = (callback) => setTimeout(callback, 16);
let caf = (num) => clearTimeout(num);
let rafUUID = 0;
const rafIds = /* @__PURE__ */ new Map();
function cleanup(id) {
rafIds.delete(id);
}
function wrapperRaf(callback) {
let times = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 1;
rafUUID += 1;
const id = rafUUID;
function callRef(leftTimes) {
if (leftTimes === 0) {
cleanup(id);
callback();
} else {
const realId = raf(() => {
callRef(leftTimes - 1);
});
rafIds.set(id, realId);
}
}
callRef(times);
return id;
}
wrapperRaf.cancel = (id) => {
const realId = rafIds.get(id);
cleanup(realId);
return caf(realId);
};
export { wrapperRaf as w };
//# sourceMappingURL=raf-ruCY1ktO.mjs.map