mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-09 03:46:16 -08:00
17 lines
349 B
JavaScript
17 lines
349 B
JavaScript
export function createRebuildQueue(build) {
|
|
let pending = false
|
|
let active
|
|
return () => {
|
|
pending = true
|
|
if (!active) {
|
|
active = Promise.resolve().then(async () => {
|
|
while (pending) {
|
|
pending = false
|
|
await build()
|
|
}
|
|
}).finally(() => { active = undefined })
|
|
}
|
|
return active
|
|
}
|
|
}
|