l = 0;
var lastVal = 0;
var callbacks = [];
var twiddle = document.createTextNode("");
function runAsync(callback, waitTime) {
if (waitTime > 0) {
return ~setTimeout(callback, waitTime);
} else {
twiddle.textContent = currVal++;
callbacks.push(callback);
return currVal - 1;
}
}
function cancelAsync(handle) {
if (handle < 0) {
clearTimeout(~handle);
} else {
var idx = handle - lastVal;
if (idx >= 0) {
if (!callbacks[idx]) {
throw "invalid async handle: " + handle;
}
callbacks[idx] = null;
}
}
}
function atEn