SOURCE

class Log{
    constructor() {
        this.isWait = '';
        this.waitQu = [];
    }

    log = (value) => {
        if (this.isWait) {
            this.waitQu.push({
                type: 'log',
                value
            });
        } else {
            console.log(value);
        }
        return this;
    }

    executor = () => {
        if (this.waitQu.length) {
            const item = this.waitQu.shift();
            if (item.type==='log') {
                console.log(item.value);
                this.executor()
            } else if (item.type === 'wait') {
                this.isWait = true;
                window.setTimeout(() => {
                    this.isWait = false;
                    this.executor();
                }, item.value * 1000);
            }
        }
    }

    wait = (value) => {
        this.waitQu.push({
            type: 'wait',
            value
        });
        if (!this.isWait) {
            this.executor();
        }
        return this;
    }
}

new Log().log(2).log(5).wait(3).log(7).log(3).wait(5).log(2);
console 命令行工具 X clear

                    
>
console