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


TypeScript p-event.default函數代碼示例

本文整理匯總了TypeScript中p-event.default函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript default函數的具體用法?TypeScript default怎麽用?TypeScript default使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了default函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: test

test('redirect response contains old url', withServer, async (t, server, got) => {
	server.get('/', defaultHandler);
	server.get('/redirect', redirectHandler);

	const {requestUrl} = await pEvent(got.stream('redirect'), 'response');
	t.is(requestUrl, `${server.url}/redirect`);
});
開發者ID:sindresorhus,項目名稱:got,代碼行數:7,代碼來源:stream.ts

示例2: async

test('returns streams when using stream option', withServer, async (t, server, got) => {
	server.get('/stream', (_request, response) => {
		response.end('ok');
	});

	const data = await pEvent(got('stream', {stream: true}), 'data');
	t.is(data.toString(), 'ok');
});
開發者ID:sindresorhus,項目名稱:got,代碼行數:8,代碼來源:arguments.ts

示例3: pEvent

		server.all('/abort', async (request, response) => {
			emitter.emit('connection');
			request.once('aborted', resolve);
			response.once('finish', reject.bind(null, new Error('Request finished instead of aborting.')));

			await pEvent(request, 'end');
			response.end();
		});
開發者ID:sindresorhus,項目名稱:got,代碼行數:8,代碼來源:cancel.ts

示例4: async

test('has error event', withServer, async (t, server, got) => {
	server.get('/', errorHandler);

	const stream = got.stream('');
	await t.throwsAsync(pEvent(stream, 'response'), {
		instanceOf: got.HTTPError,
		message: 'Response code 404 (Not Found)'
	});
});
開發者ID:sindresorhus,項目名稱:got,代碼行數:9,代碼來源:stream.ts

示例5: getStream

test('`isFromCache` stream property is false after the `response` event', withServer, async (t, server, got) => {
	server.get('/', cacheEndpoint);

	const cache = new Map();
	const stream = got.stream({cache});

	const response = await pEvent(stream, 'response') as Response;
	t.is(response.isFromCache, false);
	t.is(stream.isFromCache, false);

	await getStream(stream);
});
開發者ID:sindresorhus,項目名稱:got,代碼行數:12,代碼來源:cache.ts

示例6: async

test('doesn\'t retry on streams', withServer, async (t, server, got) => {
	server.get('/', () => {});

	const stream = got.stream({
		timeout: 1,
		retry: {
			retries: () => {
				t.fail('Retries on streams');
			}
		}
	});
	await t.throwsAsync(pEvent(stream, 'response'));
});
開發者ID:sindresorhus,項目名稱:got,代碼行數:13,代碼來源:retry.ts


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