• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript get-stream.default函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中get-stream.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了default函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: test

test('has redirect event', withServer, async (t, server, got) => {
	server.get('/', defaultHandler);
	server.get('/redirect', redirectHandler);

	const stream = got.stream('redirect');
	const {headers} = await pEvent(stream, 'redirect');
	t.is(headers.location, '/');

	await getStream(stream);
});
开发者ID:sindresorhus,项目名称:got,代码行数:10,代码来源:stream.ts


示例2: getStream

test('`isFromCache` stream property is true if the response was cached', withServer, async (t, server, got) => {
	server.get('/', cacheEndpoint);

	const cache = new Map();

	await getStream(got.stream({cache}));
	const stream = got.stream({cache});

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

	await getStream(stream);
});
开发者ID:sindresorhus,项目名称:got,代码行数:14,代码来源:cache.ts


示例3: async

let doOcpIndent = async (code: string, token: vscode.CancellationToken) => {
    let ocpIndentPath = configuration.get<string>('ocpIndentPath');
    let cp = child_process.spawn(ocpIndentPath, ['--numeric']);

    token.onCancellationRequested(() => {
        cp.disconnect();
    });

    cp.stdin.write(code);
    cp.stdin.end();

    let output = await getStream(cp.stdout);
    cp.unref();
    if (token.isCancellationRequested) return null;

    let newIndents = output.trim().split(/\n/g).map((n) => +n);
    let oldIndents = code.split(/\n/g).map((line) => /^\s*/.exec(line)[0]);

    let edits = [];
    newIndents.forEach((indent, line) => {
        let oldIndent = oldIndents[line];
        let newIndent = ' '.repeat(indent);
        if (oldIndent !== newIndent) {
            edits.push(vscode.TextEdit.replace(
                new vscode.Range(
                    new vscode.Position(line, 0),
                    new vscode.Position(line, oldIndent.length)
                ),
                newIndent)
            );
        }
    });

    return edits;
};
开发者ID:let-def,项目名称:vscode-ocaml,代码行数:35,代码来源:extension.ts


示例4: async

test('decompress content - stream', withServer, async (t, server, got) => {
	server.get('/', (_request, response) => {
		response.setHeader('Content-Encoding', 'gzip');
		response.end(gzipData);
	});

	t.is((await getStream(got.stream(''))), testContent);
});
开发者ID:sindresorhus,项目名称:got,代码行数:8,代码来源:gzip.ts


示例5: async

test('returns writeable stream', withServer, async (t, server, got) => {
	server.post('/', postHandler);

	const stream = got.stream.post('');
	const promise = getStream(stream);
	stream.end('wow');

	t.is(await promise, 'wow');
});
开发者ID:sindresorhus,项目名称:got,代码行数:9,代码来源:stream.ts


示例6: incomplete

test('throws on incomplete (canceled) response - stream', withServer, async (t, server, got) => {
	server.get('/', downloadHandler);

	const errorString = 'Foobar';

	const stream = got.stream('').on('response', () => {
		setTimeout(() => stream.destroy(new Error(errorString)), 500);
	});

	await t.throwsAsync(getStream(stream), errorString);
});
开发者ID:sindresorhus,项目名称:got,代码行数:11,代码来源:cancel.ts


示例7: async

test('rewrites /node_modules references, 1 dir nested', async (t) => {
  const filePath = '/demo/index.html';
  const beforeStream = new Readable();
  beforeStream.push('<script src="../node_modules/other-package/file.html">');
  beforeStream.push(null);
  beforeStream.setEncoding('utf8');

  const expected = '<script src="/other-package/file.html">';

  const actualStream = beforeStream.pipe(new HTMLRewriter({}, filePath));
  t.is(await getStream(actualStream), expected);
});
开发者ID:customelements,项目名称:v2,代码行数:12,代码来源:html-rewriter-test.ts



注:本文中的get-stream.default函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript getmac.getMac函数代码示例发布时间:2022-05-25
下一篇:
TypeScript get-port.default函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap