JSFiddle - React, Tailwind, and code Playground

JavaScript

var start = Date.now();

var eventLoop = {
    setTimeout: function (callback, time) {
        var event = {
            time: Date.now() + time,
            callback: callback    
        };
        this.stack.push(event);
    },
    run: function () {
        
        this.running = true;
        while (this.running) {
            for (var i = 0, len = this.stack.length; i < len; i++) {
                var ev = this.stack[i];
                var date = Date.now();
                if (ev.time <= date) {
                    ev.callback();
                    this.stack.splice(i, 1);
                    i--;
                    len--;
                }
            }
        }
    },
    stack: [],
    die: function () {
        this.running = false;
    }
};

eventLoop.setTimeout(function () {
    console.log(Date.now() - start);
    var start2 = Date.now();
    eventLoop.setTimeout(function () {
        console.log(Date.now() - start2);
        eventLoop.die();    
    }, 20);
}, 10);

eventLoop.run();