當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript delay.default函數代碼示例

本文整理匯總了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);
});
開發者ID:sindresorhus,項目名稱:got,代碼行數:18,代碼來源:timeout.ts

示例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))
 });
開發者ID:open-cta,項目名稱:wss-api,代碼行數:10,代碼來源:app.ts

示例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);
});
開發者ID:sindresorhus,項目名稱:got,代碼行數:17,代碼來源:timeout.ts

示例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();
});
開發者ID:sindresorhus,項目名稱:got,代碼行數:20,代碼來源:cookies.ts

示例5: delay

				async options => {
					await delay(100);
					options.headers.foo = 'bar';
				}
開發者ID:sindresorhus,項目名稱:got,代碼行數:4,代碼來源:hooks.ts

示例6: delay

 .catch((e: Error) => {
   spinner.fail(e.message)
   return delay(1000).then(() => randomEbayResult())
 })
開發者ID:crooked-ventures,項目名稱:literally.deals,代碼行數:4,代碼來源:random-ebay-result.ts

示例7: delay

 it('counts the time', async function() {
   const counter = new StatsCounter()
   await delay(1)
   expect(counter.duration()).to.match(/\d+.s/)
 })
開發者ID:Originate,項目名稱:tutorial-runner,代碼行數:5,代碼來源:stats-counter-test.ts


注:本文中的delay.default函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。