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


TypeScript tempy.file函數代碼示例

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


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

示例1: test

test('upload progress - file stream', withServer, async (t, server, got) => {
	server.post('/', uploadEndpoint);

	const path = tempy.file();
	fs.writeFileSync(path, file);

	const events = [];

	await got.post({body: fs.createReadStream(path)})
		.on('uploadProgress', event => events.push(event));

	checkEvents(t, events, file.length);
});
開發者ID:sindresorhus,項目名稱:got,代碼行數:13,代碼來源:progress.ts

示例2: async

export const withSocketServer = async (t, run) => {
	const socketPath = tempy.file({extension: 'socket'});

	const server = http.createServer((request, response) => {
		server.emit(request.url, request, response);
	}) as any;

	server.socketPath = socketPath;

	await util.promisify(server.listen.bind(server))(socketPath);

	try {
		await run(t, server);
	} finally {
		await util.promisify(server.close.bind(server))();
	}
};
開發者ID:sindresorhus,項目名稱:got,代碼行數:17,代碼來源:with-server.ts

示例3: directoryAsync

import { directoryAsync, directory, file, root } from 'tempy';

//

directoryAsync().then((tempDir1: string) => tempDir1 === '/tmp/123456789');

const tempDir2: string = directory();

const tempFile: string = file();
const pngFile: string = file({extension: 'png'});

const tmpRoot: string = root;
開發者ID:AbraaoAlves,項目名稱:DefinitelyTyped,代碼行數:12,代碼來源:tempy-tests.ts

示例4: Observable

	['non-domElements', {
		is: value => !m.domElement(value),
		fixtures: [
			document.createTextNode('data'),
			document.createProcessingInstruction('xml-stylesheet', 'href="mycss.css" type="text/css"'),
			document.createComment('This is a comment'),
			document,
			document.implementation.createDocumentType('svg:svg', '-//W3C//DTD SVG 1.1//EN', 'https://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'),
			document.createDocumentFragment()
		]
	}],
	['nodeStream', {
		is: m.nodeStream,
		fixtures: [
			fs.createReadStream('readme.md'),
			fs.createWriteStream(tempy.file()),
			new net.Socket(),
			new Stream.Duplex(),
			new Stream.PassThrough(),
			new Stream.Readable(),
			new Stream.Transform(),
			new Stream.Stream(),
			new Stream.Writable()
		]
	}],
	['observable', {
		is: m.observable,
		fixtures: [
			new Observable(),
			new Subject(),
			new ZenObservable(() => {})	// tslint:disable-line:no-empty
開發者ID:iwe7,項目名稱:is,代碼行數:31,代碼來源:test.ts

示例5: directory

import { directory, file, root } from "tempy";

//

const tempDir2: string = directory();

const tempFile: string = file();
const pngFile: string = file({ extension: "png" });

const fileWithName: string = file({ name: "afile.txt" });

const tmpRoot: string = root;
開發者ID:Jeremy-F,項目名稱:DefinitelyTyped,代碼行數:12,代碼來源:tempy-tests.ts


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