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


TypeScript sprintf-js.sprintf函數代碼示例

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


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

示例1: uploadFile

export async function uploadFile(file: File, requestConfig: AxiosRequestConfig = {}) {
    let allowedExtensions = getMeta("upload.allowedExtensions", []) as string[];
    allowedExtensions = allowedExtensions.map((ext: string) => ext.toLowerCase());
    const maxSize = getMeta("upload.maxSize", 0);
    const filePieces = file.name.split(".");
    const extension = filePieces[filePieces.length - 1] || "";

    if (file.size > maxSize) {
        const humanSize = humanFileSize(maxSize);
        const stringTotal: string = humanSize.amount + humanSize.unitAbbr;
        const message = sprintf(t("The uploaded file was too big (max %s)."), stringTotal);
        throw new Error(message);
    } else if (!allowedExtensions.includes(extension.toLowerCase())) {
        const attachmentsString = allowedExtensions.join(", ");
        const message = sprintf(
            t(
                "The uploaded file did not have an allowed extension. \nOnly the following extensions are allowed. \n%s.",
            ),
            attachmentsString,
        );
        throw new Error(message);
    }

    const data = new FormData();
    data.append("file", file, file.name);

    const result = await apiv2.post("/media", data, requestConfig);
    return result.data;
}
開發者ID:vanilla,項目名稱:vanilla,代碼行數:29,代碼來源:apiv2.ts

示例2: stringTime

export function stringTime (input) {
  let min = Math.floor(input / (1000 * 60));
  let sec = Math.floor((input - min * 60 * 1000) / 1000);
  let msec = input % 1000;

  if(msec) {
    if(min > 9) {
      return sprintf('%02d:%02d.%03d', min, sec, msec);
    } else {
      return sprintf('%01d:%02d.%03d', min, sec, msec);
    }
  }
  return sprintf('%02d:%02d', min, sec);
}
開發者ID:tomvlk,項目名稱:ManiaJS,代碼行數:14,代碼來源:Times.ts

示例3: dependencies

        fs.readFile(filename, (err, settingsBuffer: Buffer) => {

            var info = JSON.parse(settingsBuffer + ''),
                dependencyCount,
                devDependencyCount;

            if (err) {
                this.services.log.warn('package.json not present');

            } else {
                dependencyCount = info.dependencies ? Object.keys(info.dependencies).length : 0;
                devDependencyCount = info.devDependencies ? Object.keys(info.devDependencies).length : 0;

                if (dependencyCount > 0 || devDependencyCount > 0) {
                    this.services.log.startSection(sprintf('Installing %d npm dependencies (%d dev)', dependencyCount, devDependencyCount));
                } else {
                    this.services.log.startSection('Installing npm dependencies');
                    this.services.log.warn('package.json contains neither dependencies nor devDependencies');
                }
            }

            this.services.shell.exec('npm install').then(() => {
                this.services.log.closeSection('Node packages installed');
                deferred.resolve(true);
            }).fail(function (error) {
                deferred.reject(error);
            });

        });
開發者ID:reasn,項目名稱:mouflon,代碼行數:29,代碼來源:NodeTask.ts

示例4: sprintf

    Object.keys(buildConfig[dirsKey][workingKey]).forEach((key) => {

        // determine the filename for the zip
        let zipFilename = sprintf("%s-%s%s-%s-%s.zip",
            buildConfig[packageKey][nameKey], options.version, flag, branch, key);
        let zipFilepath = pathJoin(buildConfig[dirsKey][outputKey], zipFilename);

        // zip up the files
        zip(buildConfig[dirsKey][workingKey][key], zipFilepath, (err) => {
            if (err) {
                console.log("##vso[task.logissue type=error]Packaging Failed: %s", err);
            } else {
                console.log("Packaging Successful: %s", zipFilename);

                // set a variable as the path to the zip_file, this can then be used in subsequent
                // tasks to add the zip to the artefacts
                console.log("##vso[task.setvariable variable=%s]%s", options.outputvar, zipFilepath);

                // remove the createUIdefinition file from the working dir as this will be uploaded to
                // blob storage and the API key should not be visible
                let uiDefinitionFile = pathJoin(buildConfig[dirsKey][workingKey][key], "createUiDefinition.json");
                if (existsSync(uiDefinitionFile)) {
                    console.log("Removing UI definition file: ", uiDefinitionFile);
                    unlinkSync(uiDefinitionFile);
                }
            }
        });
    });
開發者ID:chef-partners,項目名稱:arm-chef-nodes,代碼行數:28,代碼來源:build.ts

示例5: execute

    execute(): Q.Promise<boolean> {
        var deferred = Q.defer<boolean>(),
            filename = sprintf('%s/%s/bower.json', this.services.config.paths.getTemp(), this.services.config.projectName);

        fs.readFile(filename, (err, settingsBuffer: Buffer) => {

            var info = JSON.parse(settingsBuffer + '');

            if (err) {
                this.services.log.warn('bower.json not present');
            } else {
                this.services.log.startSection(sprintf('Installing %d bower dependencies', Object.keys(info.dependencies).length));
            }

            this.services.shell.exec('bower install').then(
                ()=> {
                    this.services.log.closeSection('Bower packages installed');
                    deferred.resolve(true);
                },
                (error) => {
                    deferred.reject(error);
                });
        });

        return deferred.promise;
    }
開發者ID:reasn,項目名稱:mouflon,代碼行數:26,代碼來源:BowerTask.ts

示例6: execute

    execute() {
        var d = Q.defer(),
            filename = sprintf('%s/%s/composer.json', this.services.config.paths.getTemp(), this.services.config.projectName);

        fs.readFile(filename, (err, settingsBuffer: Buffer) => {

            var info = JSON.parse(settingsBuffer + '');

            if (err) {
                this.services.log.startSection('Installing composer dependencies');
                this.services.log.warn('composer.json not present');
            } else {
                this.services.log.startSection(sprintf('Installing %d composer dependencies', Object.keys(info.require).length));
            }

            this.services.shell.exec(this.services.config.globalConfig.composer.command + ' install --optimize-autoloader').then((stdout) => {
                this.services.log.closeSection('Composer dependencies installed');
                d.resolve(true);
            }).fail(function (error) {
                d.reject(error);
            });
        });
        return d.promise;

    }
開發者ID:reasn,項目名稱:mouflon,代碼行數:25,代碼來源:ComposerTask.ts

示例7: Date

 () => {
     var end = (new Date()).getTime();
     this.serviceContainer.log.closeSection(sprintf(
         'It took %ss to deploy "%s" to "%s". :)' + "\n\n",
         (0.001 * (end - start)).toFixed(3),
         config.projectName,
         config.stageName
     ));
 },
開發者ID:reasn,項目名稱:mouflon,代碼行數:9,代碼來源:Mouflon.ts

示例8: sprintf

 articles.forEach((item) => {
     var url = sprintf(config['rss']['urlfmt'], { 'id': item['id'] });
     feed.item({
         'title': item['title'],
         'description': item['summary'],
         'url': url, 'guid': url,
         'author': item['username'],
         'date': item['post_date']
     });
 });
開發者ID:secondwtq,項目名稱:expressus,代碼行數:10,代碼來源:feed.ts

示例9: function

fp.discover().forEach(function (entry)
        {
            console.log(sprintf("%8d %-8s %-8s %-32s", entry.handle, entry.driver_type,  entry.driver, entry.driver_detail));

            if (verbose)
            {
                var reader = promise.promisifyAll(fp.get_reader(entry.handle));
                console.log(sprintf("\t Enroll stages: %d", reader.enroll_stages));
                console.log(sprintf("\t Supports imaging: %s", reader.supports_imaging));
                console.log(sprintf("\t Supports identification: %s", reader.supports_identification));
                console.log(sprintf("\t Image height: %d", reader.img_height));
                console.log(sprintf("\t Image width: %d", reader.img_width));
                reader.start_enrollAsync().then(
                    function (result)
                    {
                        console.log(result);
                    }
                    )
                    .catch(
                        function (err)
                        {
                            console.log("ERR");
                            console.log(err);
                        }
                    )

                    console.log("DONE");
            }
        });
開發者ID:no2chem,項目名稱:node-libfprint,代碼行數:29,代碼來源:fprint_enroll.ts

示例10: constructor

    constructor(currentItem: any) {

        super(currentItem);

        this.searchPageUrl = ko.observable("");
        this.allDocumentsLabel = ko.observable(sprintf.sprintf(i18n.t("allDocumentsLabel"), _spPageContextInfo.webTitle.toLowerCase()));

        ko.bindingHandlers.getDocumentsSearchUrl = {

            init: () => {

                this.searchPageUrl(_spPageContextInfo.siteAbsoluteUrl + "/Pages/" + i18n.t("documentsSearchPageUrl"));
            },
        };
    }
開發者ID:kaminagi107,項目名稱:PnP,代碼行數:15,代碼來源:documentitem.viewmodel.ts


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