-
Notifications
You must be signed in to change notification settings - Fork 108
Open
Description
同时下载的链接不超过 3 个的情况下,尽可能快地完成。
const urls = [
{
time: 1000,
href: 'link1',
},
{
time: 2000,
href: 'link2',
},
{
time: 3000,
href: 'link3',
},
{
time: 4000,
href: 'link4',
},
{
time: 3000,
href: 'link5',
},
{
time: 2000,
href: 'link6',
},
{
time: 1000,
href: 'link7',
},
{
time: 3000,
href: 'link8',
},
{
time: 1000,
href: 'link9',
},
{
time: 1000,
href: 'link10',
},
];
function loadImg(url) {
return new Promise((resolve, reject) => {
console.log('----' + url.href + 'start!');
setTimeout(() => {
console.log(url.href + 'ok!');
resolve();
}, url.time);
});
}
function limitLoad(list, callback, limit) {
// ...
}
limitLoad(urls, loadImg, 3);Metadata
Metadata
Assignees
Labels
No labels