當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。