function time() {
    return new Date().valueOf();
}

function Yielder() {
    this.startTime = time();
    this.shouldYield = function(continueFunction){
        if (time() <= this.startTime + 100)
            return false;
        
        info("yielding to UI thread");
        this.startTime = time();
        this.nextAction = setTimeout(continueFunction, 0);
        return true;
    };
    this.cancel = function(){
        if (this.nextAction)
            clearTimeout(this.nextAction);
    };
}


function politeEach(array, f, callback, yielder) {
    yielder = yielder || new Yielder();
    var index = 0;
    function iterate() {
        while(index < array.length) {
            f(index, array[index]);
            index++;
            if (yielder.shouldYield(iterate))
                return;
        }
        if (callback) callback();
    }
    iterate();
}

function politeMap(array, f, callback, yielder) {
    yielder = yielder || new Yielder();
    var result = [];
    politeEach(array, function(index, value) {
        result[index] = f(index,value);
    }, function() {callback(result);}, yielder);
}
@@ -498,17 +498,16 @@
   %7D;%0A%7D%0A%0A
-%0A
 function
@@ -524,32 +524,34 @@
 h(array, f, 
-callback
+onComplete
 , yielder) %7B
@@ -826,26 +826,30 @@
 if (
-callback) callback
+onComplete) onComplete
 ();%0A
@@ -901,24 +901,26 @@
 ray, f, 
-callback
+onComplete
 , yielde
@@ -1095,16 +1095,18 @@
 () %7B
-callback
+onComplete
 (res

Improve parameter names