本文整理汇总了TypeScript中timers.clearTimeout函数的典型用法代码示例。如果您正苦于以下问题:TypeScript clearTimeout函数的具体用法?TypeScript clearTimeout怎么用?TypeScript clearTimeout使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了clearTimeout函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: registerBridge
registerBridge("clearTimeout", (rt: Runtime, bridge: Bridge, id: ivm.Reference<NodeJS.Timer>) => {
try {
clearTimeout(id.deref())
} catch (e) {
// ignore
}
})
示例2: function
return function() {
let now = +new Date()
if (!previous) previous = now
if (now - previous > atleast) {
fn()
// 重置上一次开始时间为本次结束时间
previous = now
} else {
clearTimeout(timer)
timer = setTimeout(function() {
fn()
}, delay)
}
}
示例3: testPromisify
const immediateId = timers.setImmediate(() => { console.log("immediate"); });
timers.clearImmediate(immediateId);
}
{
const counter = 0;
const timeout = timers.setInterval(() => { console.log("interval"); }, 20);
timeout.unref();
timeout.ref();
timers.clearInterval(timeout);
}
{
const counter = 0;
const timeout = timers.setTimeout(() => { console.log("timeout"); }, 20);
timeout.unref();
timeout.ref();
timers.clearTimeout(timeout);
}
async function testPromisify() {
const setTimeout = util.promisify(timers.setTimeout);
let v: void = await setTimeout(100); // tslint:disable-line no-void-expression void-return
let s: string = await setTimeout(100, "");
const setImmediate = util.promisify(timers.setImmediate);
v = await setImmediate(); // tslint:disable-line no-void-expression
s = await setImmediate("");
}
}
/////////////////////////////////////////////////////////
/// Errors Tests : https://nodejs.org/api/errors.html ///
/////////////////////////////////////////////////////////
示例4: touch_document
export function touch_document(document: TextDocument)
{
if (touched_timer) timers.clearTimeout(touched_timer)
touched_documents.add(document)
touched_timer = timers.setTimeout(update_touched_documents, 1000)
}
示例5: setTimeout
const timer = setTimeout(() => {
iframeEl.removeEventListener("load", iframeCallback);
document.body.removeChild(iframeEl);
clearTimeout(timer);
}, 0);