mirror of
https://github.com/sstent/node.git
synced 2026-01-27 15:41:43 +00:00
first post
This commit is contained in:
10
Nodejs-Socketio-Mysql-Demo/node_modules/wd/lib/browser-scripts/safe-execute-async.js
generated
vendored
Normal file
10
Nodejs-Socketio-Mysql-Demo/node_modules/wd/lib/browser-scripts/safe-execute-async.js
generated
vendored
Normal 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;
|
||||
}
|
||||
9
Nodejs-Socketio-Mysql-Demo/node_modules/wd/lib/browser-scripts/safe-execute.js
generated
vendored
Normal file
9
Nodejs-Socketio-Mysql-Demo/node_modules/wd/lib/browser-scripts/safe-execute.js
generated
vendored
Normal 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;
|
||||
}
|
||||
32
Nodejs-Socketio-Mysql-Demo/node_modules/wd/lib/browser-scripts/wait-for-cond-in-browser.js
generated
vendored
Normal file
32
Nodejs-Socketio-Mysql-Demo/node_modules/wd/lib/browser-scripts/wait-for-cond-in-browser.js
generated
vendored
Normal 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);
|
||||
Reference in New Issue
Block a user