MCPcopy
hub / github.com/jabbany/CommentCoreLibrary / interval

Function interval

src/scripting/api/Utils/Utils.ts:121–138  ·  view source on GitHub ↗
(
    callback:Function,
    interval:number = 1000,
    repeatCount:number = 1)

Source from the content-addressed store, hash-verified

119 * @return {number} indicator of interval to allow cancelling
120 */
121 export function interval(
122 callback:Function,
123 interval:number = 1000,
124 repeatCount:number = 1):number{
125
126 if (repeatCount === 0) {
127 return Runtime.getTimer().setInterval(callback, interval);
128 }
129 var ivl = Runtime.getTimer().setInterval(function(){
130 repeatCount--;
131 if (repeatCount < 0) {
132 Runtime.getTimer().clearInterval(ivl);
133 } else {
134 callback();
135 }
136 }, interval);
137 return ivl;
138 }
139
140 /**
141 * Clears a scheduled timeout. If timeout id is not recognized no action

Callers

nothing calls this directly

Calls 2

setIntervalMethod · 0.80
clearIntervalMethod · 0.80

Tested by

no test coverage detected