mirror of https://github.com/svaarala/duktape.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
649 B
27 lines
649 B
// Bluebird requires an async scheduler. Provide a very fake setTimeout()
|
|
// to allow simple testing.
|
|
|
|
var fakeEventLoop;
|
|
var window;
|
|
|
|
(function () {
|
|
var timers = [];
|
|
|
|
window = Function('return this')(); // window <- global object
|
|
|
|
window.setTimeout = function (fn, timeout) {
|
|
timers.push(fn);
|
|
};
|
|
|
|
window.clearTimeout = function () {};
|
|
|
|
fakeEventLoop = function () {
|
|
print('fake eventloop, run timers');
|
|
while (timers.length > 0) {
|
|
var fn = timers.shift();
|
|
print('run timer');
|
|
fn();
|
|
}
|
|
print('fake eventloop exiting, no more timers');
|
|
};
|
|
})();
|
|
|