本文整理匯總了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/)
})