• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript tmp.tmpNameSync函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中tmp.tmpNameSync函数的典型用法代码示例。如果您正苦于以下问题:TypeScript tmpNameSync函数的具体用法?TypeScript tmpNameSync怎么用?TypeScript tmpNameSync使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了tmpNameSync函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: train

  async train(intents: Array<TrainSet>, modelId: string) {
    const dataFn = tmp.tmpNameSync()
    await this._writeTrainingSet(intents, dataFn)

    const modelFn = tmp.tmpNameSync()
    const modelPath = `${modelFn}.bin`

    // TODO: Add parameters Grid Search logic here
    this.fastTextWrapper = new FastTextWrapper(modelPath)

    this.fastTextWrapper.train(dataFn, { method: 'supervised' })
    this.currentModelId = modelId

    return modelPath
  }
开发者ID:seffalabdelaziz,项目名称:botpress,代码行数:15,代码来源:ft_classifier.ts


示例2: downloadPackage

export function downloadPackage(type: PackageType, metadata: PackageMetadata): Promise<string> {
    let { version, dist: { platform, format, url } } = metadata;

    let packageBaseName = `${type}-${version}-${platform}`
    let packageName = `${packageBaseName}.${format}`;
    let metadataFileName = `${packageBaseName}.json`;

    let packagePath = Path.join(config.downloadsPath, packageName);
    let metadataFilePath = Path.join(config.downloadsPath, metadataFileName);

    if (FS.existsSync(packagePath) && FS.existsSync(metadataFilePath)) {
        return Promise.resolve(packagePath);
    }

    let tmpPackagePath = Tmp.tmpNameSync();

    return Promise
        .resolve(fetch(url))
        .then(res => {
            let resStream = res.body;
            let writeStream = FS.createWriteStream(tmpPackagePath);

            resStream.pipe(writeStream);

            return Promise.for(writeStream, 'close', [resStream]);
        })
        .then(() => {
            FS.copySync(tmpPackagePath, packagePath);

            let metadataJSON = JSON.stringify(metadata, undefined, 4);
            FS.writeFileSync(metadataFilePath, metadataJSON);

            return packagePath;
        });
}
开发者ID:vilic,项目名称:rvm,代码行数:35,代码来源:index.ts


示例3: initializeModel

 protected static async initializeModel() {
   const tmpFn = tmp.tmpNameSync({ postfix: '.ftz' })
   const modelBuff = readFileSync(PRETRAINED_LID_176)
   writeFileSync(tmpFn, modelBuff)
   const ft = new FastTextLanguageId.toolkit.FastText.Model()
   await ft.loadFromFile(tmpFn)
   FastTextLanguageId.model = ft
 }
开发者ID:alexsandrocruz,项目名称:botpress,代码行数:8,代码来源:ft_lid.ts


示例4: function

        busboy.on('file', function(fieldName: string, stream: ReadableStream, filename: string, encoding: string, mimeType: string) {

            //save tmp files
            const tmpDir = (options.uploadDir ? options.uploadDir : os.tmpDir());
            const tmpPath = tmp.tmpNameSync({template: tmpDir + '/upload-XXXXXXXXXXXXXXXXXXX'});
            stream.pipe(fs.createWriteStream(tmpPath));

            stream.on('end', function() {
                //push file data
                formData[fieldName] = {
                    fileName: filename,
                    mimeType: mimeType,
                    tmpPath: tmpPath
                };
            });

            stream.on('limit', function() {
                hasError = 'filesSizeLimit';
            });
        });
开发者ID:sqram,项目名称:koa-async-body,代码行数:20,代码来源:index.ts


示例5: Promise

        return new Promise((resolve, reject) => {
            var args = prefixArgs != null ? prefixArgs : '';
            var revisionString: string = isNaN(revision) ? '' : `#${revision}`;

            var ext = Path.extname(localFilePath);
            var tmp = require("tmp");
            var tmpFilePath = tmp.tmpNameSync({ postfix: ext });

            var requirePipe = true;
            if (command == "print") {
                if(localFilePath == null) {
                    reject("P4 Print command require a file path");
                }

                // special case to directly output in the file
                args += ' -q -o "' + tmpFilePath + '"';
                requirePipe = false;
            }

            if (localFilePath != null) {
                args += ' "' + expansePath(localFilePath) + revisionString + '"'
            }

            if (requirePipe) {
                // forward all output to the file
                args += ' > "' + tmpFilePath + '"';
            }

            PerforceService.execute("print", (err, strdout, stderr) => {
                if(err){
                    reject(err);
                } else if (stderr) {
                    reject(stderr);
                } else {
                    resolve(tmpFilePath);
                }
            }, args);
        });
开发者ID:hoovercj,项目名称:vscode-perforce,代码行数:38,代码来源:Utils.ts


示例6: loadModel

 loadModel(model: Buffer, modelId?: string) {
   this.currentModelId = modelId
   const tmpFn = tmp.tmpNameSync()
   writeFileSync(tmpFn, model)
   this.fastTextWrapper = new FastTextWrapper(tmpFn)
 }
开发者ID:seffalabdelaziz,项目名称:botpress,代码行数:6,代码来源:ft_classifier.ts


示例7: initializeModel

 protected static initializeModel() {
   const tmpFn = tmp.tmpNameSync()
   const modelBuff = readFileSync(PRETRAINED_LID_176)
   writeFileSync(tmpFn, modelBuff)
   this.model = new FastTextWrapper(tmpFn)
 }
开发者ID:seffalabdelaziz,项目名称:botpress,代码行数:6,代码来源:ft_lid.ts


示例8: createLabelImage

 /* @return Promise that resolves to the path of the QR code
 */
 createLabelImage(baleEvent: BalerEmptiedEvent): Promise<string> {
   let data =
       "Bale Type:    " + baleEvent.baleType.material +
     "\nBale Date:    " + baleEvent.baleDate.toLocaleDateString("en-US") + " " + baleEvent.baleDate.toLocaleTimeString("en-US") +
     "\nPartner ID:   " + baleEvent.customerID +
     "\nWorker:       " + baleEvent.worker.username +
     "\nEquipment ID: " + baleEvent.balerID +
     "\nBale ID:      " + baleEvent.baleID +
     "\nWeight:       " + baleEvent.weight
     ;
   let pngData = qr.imageSync("http://bjnbaler.com/" +
     "?material=" + encodeURIComponent(baleEvent.baleType.material) +
     "&weight=" + encodeURIComponent(baleEvent.weight.toString()) +
     "&worker=" + encodeURIComponent(baleEvent.worker.username.toString()) +
     "&baleID=" + encodeURIComponent(baleEvent.baleID.toString()) +
     "&balerID=" + encodeURIComponent(baleEvent.balerID.toString()) +
     "&customerID=" + encodeURIComponent(baleEvent.customerID.toString()) +
     "&date=" + encodeURIComponent(baleEvent.baleDate.toLocaleDateString("en-US") + " " + baleEvent.baleDate.toLocaleTimeString("en-US")),
     { type: 'png', ec_level: 'H' });
   let tmpName = tmp.tmpNameSync({template: "./tmp/qr-XXXXXX.png"});
   let writePromise = new Promise(function(resolve, reject) {
     fs.writeFile(tmpName, pngData, function(err) {
       if(err) {
         fs.unlink(tmpName);
         reject(err);
       }
       else {
         // writing QR Code image successful, now add label.
         exec("convert " +
              tmpName +
              " label:'" + data + "'" +
              " -gravity Center" +
              " +swap" +
              " -append" +
              " -gravity North" +
              " -geometry +0+2100" +
              " -resize 2100x2400" +
              " ./tmp/template.png" +
              " +swap" +
              " -composite" +
              " \\( +clone -crop 2100x2400+0+2000 -rotate -90 -resize 1200x -geometry +0+90 \\)" +
              " -composite" +
              " -rotate 90 " +
              tmpName,
              (err, stdout, stderr) => {
                if(err) {
                  fs.unlink(tmpName);
                  reject(err);
                }
                if(stderr) {
                  fs.unlink(tmpName);
                  reject(stderr);
                }
                if(!(err || stderr)) {
                  resolve(tmpName);
                }
         });
       }
     });
   });
   return writePromise;
 }
开发者ID:dconyers,项目名称:BalerDisplay,代码行数:64,代码来源:QRService.ts


示例9: tmpName

tmpName({ template: "/tmp/tmp-XXXXXX" }, (err, name) => {
    if (err) throw err;

    console.log("Created temporary filename: ", name);
});

setGracefulCleanup();

let tmpFile: FileResult = fileSync();
console.log("File name: ", tmpFile.name);
console.log("File descriptor: ", tmpFile.fd);
tmpFile.removeCallback();

let tmpDir: DirResult = dirSync();
console.log("Dir name: ", tmpDir.name);
tmpDir.removeCallback();

let name: string = tmpNameSync();
console.log("Created temporary filename: ", name);

tmpFile = fileSync({ mode: 644, prefix: "prefix-", postfix: ".txt" });
console.log("File name: ", tmpFile.name);
console.log("File descriptor: ", tmpFile.fd);

tmpDir = dirSync({ mode: 750, prefix: "myTmpDir_" });
console.log("Dir: ", tmpDir.name);

name = tmpNameSync({ template: "/tmp/tmp-XXXXXX" });
console.log("Created temporary filename: ", name);
开发者ID:TeamworkGuy2,项目名称:DefinitelyTyped,代码行数:29,代码来源:tmp-tests.ts



注:本文中的tmp.tmpNameSync函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript application._resetRootView函数代码示例发布时间:2022-05-25
下一篇:
TypeScript tmp.fileSync函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap