first post

This commit is contained in:
2012-05-25 09:03:56 -04:00
commit 6a753904b7
609 changed files with 252648 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
var code = arguments[0], args = arguments[1], done = arguments[2];
var wrap = function() {
return eval(code);
};
try {
args.push(done);
return wrap.apply(this, args);
} catch (err) {
throw err;
}

View File

@@ -0,0 +1,9 @@
var code = arguments[0], args = arguments[1];
var wrap = function() {
return eval(code);
};
try {
return wrap.apply(this, args);
} catch (err) {
throw err;
}

View File

@@ -0,0 +1,32 @@
// run in the browser
//parse arguments
var condExpr = arguments[0], timeout = arguments[1],
poll = arguments[2], cb = arguments[3];
// recursive implementation
waitForConditionImpl = function(conditionExpr, limit, poll, cb) {
// timeout check
if (Date.now() < limit) {
// condition check
res = eval(conditionExpr);
if (res == true ) {
// condition ok
return cb(res);
} else {
// wait for poll and try again
setTimeout(function() {
waitForConditionImpl(conditionExpr, limit, poll, cb);
}, poll);
}
} else {
// try one last time
res = eval(conditionExpr);
return cb(res);
}
};
// calling impl
limit = Date.now() + timeout;
waitForConditionImpl(condExpr, limit, poll, cb);