当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript tmp.tmpNameSync函数代码示例

本文整理汇总了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;未经允许,请勿转载。