本文整理汇总了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);
});
示例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))();
}
};
示例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;
示例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
示例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;