本文整理汇总了TypeScript中delay.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
test('socket timeout is canceled on error', withServer, async (t, server, got) => {
server.get('/', defaultHandler);
const message = 'oh, snap!';
const promise = got({
timeout: {socket: 100},
retry: 0
}).on('request', request => {
request.emit('error', new Error(message));
request.abort();
});
await t.throwsAsync(promise, {message});
// Wait a bit more to check if there are any unhandled errors
await delay(100);
});
示例2: delay
_.each(arr, async function(newData, i, arr) {
if (i > 0) {
let previousIndex = i - 1
let previousData = arr[previousIndex]
let d = (newData.prdt - previousData.prdt) * 1000
dly = dly + d
await delay(dly)
}
ws.send(JSON.stringify(newData))
});
示例3: delay
test('no more timeouts after an error', async t => {
await t.throwsAsync(got(`http://${Date.now()}.dev`, {
retry: 1,
timeout: {
lookup: 1,
connect: 1,
secureConnect: 1,
socket: 1,
response: 1,
send: 1,
request: 1
}
}), {instanceOf: got.GotError}); // Don't check the message, because it may throw ENOTFOUND before the timeout.
// Wait a bit more to check if there are any unhandled errors
await delay(100);
});
示例4: delay
test('no unhandled errors', async t => {
const server = net.createServer(connection => {
connection.end('blah');
}).listen(0);
const message = 'snap!';
const options = {
cookieJar: {
setCookie: () => {},
getCookieString: (_, __, cb) => cb(new Error(message))
}
};
await t.throwsAsync(got(`http://127.0.0.1:${(server.address() as AddressInfo).port}`, options), {message});
await delay(500);
t.pass();
server.close();
});
示例5: delay
async options => {
await delay(100);
options.headers.foo = 'bar';
}
示例6: delay
.catch((e: Error) => {
spinner.fail(e.message)
return delay(1000).then(() => randomEbayResult())
})
示例7: delay
it('counts the time', async function() {
const counter = new StatsCounter()
await delay(1)
expect(counter.duration()).to.match(/\d+.s/)
})