torrent/image-only.js
/**
   * Executes a task for the given number times with a specified interval.
   * Delay for the first execution can be specified with `startAfter` parameters.
   * Default value of `startAfter` is 0. Scheduling of the task stops if the task
   * function returns a **truthy** value.
   *
   * @param {function} taskFn task to execute
   * @param {number} times number of times task should be executed
   * @param {number} interval interval in millis between two subsequent task execution
   * @param {number} startAfter delay in millis before first execution
   */
Executes a task for the given number times with a specified interval.
Delay for the first execution can be specified with `startAfter` parameters.
Default value of `startAfter` is 0. Scheduling of the task stops if the task
function returns a **truthy** value.

@param {function} taskFn task to execute
@param {number} times number of times task should be executed
@param {number} interval interval in millis between two subsequent task execution
@param {number} startAfter delay in millis before first execution
Executes a task for the given number times with a specified interval . Delay for the first execution can be specified with ` startAfter ` parameters . Default value of ` startAfter ` is 0 . Scheduling of the task stops if the task function returns a ** truthy ** value . @param { function } taskFn task to execute @param { number } times number of times task should be executed @param { number } interval interval in millis between two subsequent task execution @param { number } startAfter delay in millis before first execution
function retry(taskFn, times, interval, startAfter) {
        const idfCompletedTries = "image_only_completed_tries";
        sessionStorage.setItem(idfCompletedTries, 0);
        function start() {
            const completedTries = +sessionStorage.getItem(idfCompletedTries);
            if (completedTries >= times) {
                sessionStorage.removeItem(idfCompletedTries);
                return;
            }
            sessionStorage.setItem(idfCompletedTries, completedTries + 1);
            if (!taskFn()) {
                setTimeout(start, interval);
            }
        }
        setTimeout(start, startAfter);
    }
function retry ( taskFn , times , interval , startAfter ) { const idfCompletedTries = "image_only_completed_tries" ; sessionStorage . setItem ( idfCompletedTries , 0 ) ; function start ( ) { const completedTries = + sessionStorage . getItem ( idfCompletedTries ) ; if ( completedTries >= times ) { sessionStorage . removeItem ( idfCompletedTries ) ; return ; } sessionStorage . setItem ( idfCompletedTries , completedTries + 1 ) ; if ( ! taskFn ( ) ) { setTimeout ( start , interval ) ; } } setTimeout ( start , startAfter ) ; }
Executes a task for the given number times with a specified interval.
Executes a task for the given number times with a specified interval .