当前位置: 首页>>代码示例>>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;未经允许,请勿转载。