SOURCE

function request(urls, limit) {

    return new Promise((reslove) => {
        let result = [];
        let current = limit;
        let getResultNum = 0;
        function getResult(url, i) {
            get(url).then((res) => {
                result[i] = res;
                getResultNum++;
                if(getResultNum === urls.length){
                    reslove(result);
                } else if(current <  urls.length){
                    getResult(urls[current], current);
                    current++;
                }
            });
        }
        for (let i = 0; i < limit; i++) {
            getResult(urls[i],i);
        }
    })
}

function get(url) {
    return new Promise((reslove) => {
        reslove()
    }).then(() => {
       return url;
    });
}

request([1,2,3,4,5,6,7,8], 2).then((res) => {
    console.log(11, res);
})
console 命令行工具 X clear

                    
>
console