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.
34 lines
626 B
34 lines
626 B
"use strict"; |
|
|
|
var delay = require("../../delay"); |
|
|
|
module.exports = function (t, a) { |
|
if (typeof Promise !== "function") return null; |
|
return { |
|
Tick: function (d) { |
|
var isInvoked = false; |
|
t().then(function (result) { |
|
isInvoked = true; |
|
delay(function () { |
|
a(result, undefined); |
|
d(); |
|
})(); |
|
}, delay(d)); |
|
a(isInvoked, false); |
|
}, |
|
Timeout: function (d) { |
|
var isInvoked = false; |
|
t(100).then( |
|
delay(function (result) { |
|
isInvoked = true; |
|
a(result, undefined); |
|
d(); |
|
}), |
|
delay(d) |
|
); |
|
setTimeout(function () { |
|
a(isInvoked, false); |
|
}, 50); |
|
} |
|
}; |
|
};
|
|
|