The usecase is to throttle touchmove events in the dom. As of now we have to schedule it via mutate and then clear it when the next one comes. This can't be done easily and one needs to write a wrapper sort of like this —
function mutateLatest () {
let id = null
return function (task) {
if(id) fastdom.clear(id)
id = fastdom.mutate(task)
}
}
The second problem is that it should be performing poorer because of the time complexity of n to remove an element from the queue.