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