Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript sleep settimeout

setTimeout(() => {  console.log("World!"); }, 2000);
Comment

how to pause settimeout in javascript

var Timer = function(callback, delay) {
    var timerId, start, remaining = delay;

    this.pause = function() {
        window.clearTimeout(timerId);
        timerId = null;
        remaining -= Date.now() - start;
    };

    this.resume = function() {
        if (timerId) {
            return;
        }

        start = Date.now();
        timerId = window.setTimeout(callback, remaining);
    };

    this.resume();
};

var timer = new Timer(function() {
    alert("Done!");
}, 1000);

timer.pause();
// Do some stuff...
timer.resume();
Comment

PREVIOUS NEXT
Code Example
Javascript :: flatpickr current date set to text field 
Javascript :: JavaScript (SMonkey 60.2.3) sample 
Javascript :: creating the find method javascript 
Javascript :: larevel blade data received in javascript 
Javascript :: how to convert string to reverse title case in javascript 
Javascript :: _.isString 
Javascript :: arjs marker+location 
Javascript :: react native android build location 
Javascript :: how dynamique pseudo element in react 
Javascript :: javascript Implicit Conversion to Number 
Javascript :: react props class based static proptypes 
Javascript :: javascript Add Symbol as an Object Key 
Javascript :: JavaScript WeakMap Methods 
Javascript :: javascript AutoCorrection in Date Object 
Javascript :: JavaScript Iterables 
Javascript :: find the missing number javascript 
Javascript :: nodejs: Basic: managing file: Read, Write, Create, Delete 
Javascript :: get data notifacation realtime use ajax good 
Javascript :: get html element coords with js 
Javascript :: phaser grid align 
Javascript :: phaser hide animation on complete 
Javascript :: unicons add all icons 
Javascript :: white when respons show code 
Javascript :: nodejs: redirect path to specific path 
Javascript :: check change from service variable angular 
Javascript :: graphql nested schema 
Javascript :: javascript break with while Loop 
Javascript :: how to comment in javascript 
Javascript :: vue sidebar 
Javascript :: convert a string to array 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =