当前位置: 首页>>代码示例>>TypeScript>>正文


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

本文整理汇总了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;未经允许,请勿转载。