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

TypeScript sprintf-js.sprintf函数代码示例

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

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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript sprintf-js.vsprintf函数代码示例发布时间:2022-05-25
下一篇:
TypeScript spring-flo.Shapes.Factory类代码示例发布时间: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