JSFiddle - React, Tailwind, and code Playground

by Darby Rathbone

JavaScript

var intervalhaltat = (function () {
    return (function (cb, c, ms) {
        var count = 0;
        var halter = new Object({
            cb: cb,
            c: c,
            ms: ms,

            recall: function () {
                if (count >= c) {
                    window.clearTimeout(interval);
                    //this.count = 0;

                }
                cb(count++);
                interval = window.setTimeout(this.recall, ms);

            }()
        });

    })();
})();

intervalhaltat(function (c) {
    document.body.appendChild(document.createTextNode(c));
}, 10, 10);

intervalhaltat(function (c) {
    document.body.appendChild(document.createTextNode(c));
}, 100, 10);