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

TypeScript util.format函数代码示例

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

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



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

示例1: getDockerConfig

 public getDockerConfig(): string {
     var authenticationToken = new Buffer(this.username+":"+this.password).toString('base64')
     console.log("##vso[task.setvariable variable=CONTAINER_AUTHENTICATIONTOKEN;issecret=true;]" + authenticationToken);
     var auths = util.format('{"auths": { "%s": {"auth": "%s", "email": "%s" } }, "HttpHeaders":{"X-Meta-Source-Client":"%s"} }', this.registry, authenticationToken,this.email, this.xMetaSourceClient);
     return auths;
 }
开发者ID:bleissem,项目名称:vsts-tasks,代码行数:6,代码来源:registryauthenticationtoken.ts


示例2: warn

 warn(firstArg: any, ...rest: Array<any>) {
   this._log('warn', format(firstArg, ...rest));
 }
开发者ID:facebook,项目名称:jest,代码行数:3,代码来源:BufferedConsole.ts


示例3: executePythonTool

var workingDirectory = tl.getInput('wd', true);
var serviceEndpointId = tl.getInput('serviceEndpoint', true);
var wheel: boolean = tl.getBoolInput('wheel');
var homedir = os.homedir();
var pypircFilePath = path.join(homedir, ".pypirc");
var pythonToolPath = tl.which('python', true);
var error = '';

//Generic service endpoint
var pythonServer = tl.getEndpointUrl(serviceEndpointId, false);
var username = tl.getEndpointAuthorizationParameter(serviceEndpointId, 'username', false);
var password = tl.getEndpointAuthorizationParameter(serviceEndpointId, 'password', false);

//Create .pypirc file
var text = util.format("[distutils] \nindex-servers =\n    pypi \n[pypi] \nrepository=%s \nusername=%s \npassword=%s", pythonServer, username, password);
tl.writeFile(pypircFilePath, text, 'utf8');

(async () => {
    //PyPI upload
    try{
        tl.cd(workingDirectory);
        await executePythonTool("-m pip install twine --user");
        await executePythonTool("setup.py sdist");
        if(wheel){
            await executePythonTool("-m pip install wheel --user");
            await executePythonTool("setup.py bdist_wheel --universal");
        }
        await executePythonTool("-m twine upload dist/*");
    }
    catch(err){
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:30,代码来源:publisher.ts


示例4: onRunComplete

  onRunComplete(contexts: Set<Context>, result: AggregatedResult): void {
    const success =
      result.numFailedTests === 0 && result.numRuntimeErrorTestSuites === 0;

    const firstContext = contexts.values().next();

    const hasteFS =
      firstContext && firstContext.value && firstContext.value.hasteFS;

    let packageName;
    if (hasteFS != null) {
      // assuming root package.json is the first one
      const [filePath] = hasteFS.matchFiles('package.json');

      packageName =
        filePath != null
          ? hasteFS.getModuleName(filePath)
          : this._globalConfig.rootDir;
    } else {
      packageName = this._globalConfig.rootDir;
    }

    packageName = packageName != null ? `${packageName} - ` : '';

    const notifyMode = this._globalConfig.notifyMode;
    const statusChanged =
      this._context.previousSuccess !== success || this._context.firstRun;
    const testsHaveRun = result.numTotalTests !== 0;

    if (
      testsHaveRun &&
      success &&
      (notifyMode === 'always' ||
        notifyMode === 'success' ||
        notifyMode === 'success-change' ||
        (notifyMode === 'change' && statusChanged) ||
        (notifyMode === 'failure-change' && statusChanged))
    ) {
      const title = util.format('%s%d%% Passed', packageName, 100);
      const message = util.format(
        (isDarwin ? '\u2705 ' : '') + '%d tests passed',
        result.numPassedTests,
      );

      notifier.notify({icon, message, title});
    } else if (
      testsHaveRun &&
      !success &&
      (notifyMode === 'always' ||
        notifyMode === 'failure' ||
        notifyMode === 'failure-change' ||
        (notifyMode === 'change' && statusChanged) ||
        (notifyMode === 'success-change' && statusChanged))
    ) {
      const failed = result.numFailedTests / result.numTotalTests;

      const title = util.format(
        '%s%d%% Failed',
        packageName,
        Math.ceil(Number.isNaN(failed) ? 0 : failed * 100),
      );
      const message = util.format(
        (isDarwin ? '\u26D4\uFE0F ' : '') + '%d of %d tests failed',
        result.numFailedTests,
        result.numTotalTests,
      );

      const watchMode = this._globalConfig.watch || this._globalConfig.watchAll;
      const restartAnswer = 'Run again';
      const quitAnswer = 'Exit tests';

      if (!watchMode) {
        notifier.notify({
          icon,
          message,
          title,
        });
      } else {
        notifier.notify(
          {
            actions: [restartAnswer, quitAnswer],
            closeLabel: 'Close',
            icon,
            message,
            title,
          },
          (err, _, metadata) => {
            if (err || !metadata) {
              return;
            }
            if (metadata.activationValue === quitAnswer) {
              exit(0);
              return;
            }
            if (metadata.activationValue === restartAnswer) {
              this._startRun(this._globalConfig);
            }
          },
        );
      }
//.........这里部分代码省略.........
开发者ID:facebook,项目名称:jest,代码行数:101,代码来源:notify_reporter.ts


示例5: print_stat

 function print_stat() {
     t2 = Date.now();
     const str = util.format("R= %d W= %d T=%d t= %d",
       client.bytesRead, client.bytesWritten, client.transactionsPerformed, (t2 - t1));
     console.log(chalk.yellow.bold(str));
 }
开发者ID:node-opcua,项目名称:node-opcua,代码行数:6,代码来源:simple_client.ts


示例6: TOO_COMPLEX

export function TOO_COMPLEX() {
    let fmt = `Method table is too complex. Try reducing the number of predicates or their degree of overlap.`;
    return error(format(fmt));
}
开发者ID:yortus,项目名称:multimethods,代码行数:4,代码来源:fatal-error.ts


示例7: DUPLICATE_PREDICATE

export function DUPLICATE_PREDICATE(normalised: string, predicates: string) {
    let fmt = `The predicate '%s' is duplicated across multiple methods: %s. To resolve this, use a method chain.`;
    return error(format(fmt, normalised, predicates));
}
开发者ID:yortus,项目名称:multimethods,代码行数:4,代码来源:fatal-error.ts


示例8: INVALID_ARITY_OPTION

export function INVALID_ARITY_OPTION(value: any) {
    let fmt = `Expected a positive integer or undefined value for options.arity, but found %j.`;
    return error(format(fmt, value));
}
开发者ID:yortus,项目名称:multimethods,代码行数:4,代码来源:fatal-error.ts


示例9: INVALID_NAME_OPTION

export function INVALID_NAME_OPTION(value: any) {
    let fmt = `Expected a valid identifier or undefined value for options.name, but found %j.`;
    return error(format(fmt, value));
}
开发者ID:yortus,项目名称:multimethods,代码行数:4,代码来源:fatal-error.ts


示例10: constructor

	constructor(private $dynamicHelpService: IDynamicHelpService,
		private $injector: IInjector) {
		// Injector's dynamicCallRegex doesn't have 'g' option, which we need here.
		// Use ( ) in order to use $1 to get whole expression later
		this.dynamicCallRegex = new RegExp(util.format("(%s)", this.$injector.dynamicCallRegex.source), "g");
	}
开发者ID:telerik,项目名称:mobile-cli-lib,代码行数:6,代码来源:micro-templating-service.ts


示例11: test

test('works', async (t) => {
    const url = format('http://unix:%s:%s', socketPath, '/');
    t.is((await got(url)).body, 'ok');
});
开发者ID:cyounkins,项目名称:typed-got,代码行数:4,代码来源:unix-socket.ts


示例12: delete

 delete(id, callback) {
   var path = format('/v1.0/inbox/messages/%s', id);
 
   this.client.requesthandler.request('DELETE', path, null, null, 200, callback);
 };
开发者ID:Codesleuth,项目名称:esendex-node,代码行数:5,代码来源:inbox.ts


示例13: update

 update(options: InboxUpdateOptions, callback: (err: any) => void) {
   var path = format('/v1.0/inbox/messages/%s', options.id);
   var query = { action: options.read ? 'read' : 'unread' };
 
   this.client.requesthandler.request('PUT', path, query, null, 200, callback);
 }
开发者ID:Codesleuth,项目名称:esendex-node,代码行数:6,代码来源:inbox.ts


示例14: CliImport

export default function CliImport() {
    let err;
    let program = require('commander');
    let colors = require('colors');
    let pkg = require('../package.json');
    let util = require('util');

    program.version(pkg.version)
        .option('-c, --collection <collection>', 'The Power BI workspace collection')
        .option('-w, --workspace <workspaceId>', 'The Power BI workspace')
        .option('-k, --accessKey <accessKey>', 'The Power BI workspace collection access key')
        .option('-n, --displayName <displayName>', 'The dataset display name')
        .option('-f, --file <file>', 'The PBIX file to upload')
        .option('-o, --overwrite [overwrite]', 'Whether to overwrite a dataset with the same name.  Default is false')
        .option('-b --baseUri [baseUri]', 'The base uri to connect to');

    program.on('--help', function () {
        console.log('  Examples:');
        console.log('');
        console.log('    $ powerbi import -c <collection> -k <accessKey> -w <workspace> -f <file>');
    });

    program.parse(process.argv);
    let settings = config.merge(program);

    if (process.argv.length === 2) {
        program.help();
    } else {
        try {
            let options: powerbi.ImportFileOptions = {};
            let token = powerbi.PowerBIToken.createDevToken(settings.collection, settings.workspace);
            let credentials = new msrest.TokenCredentials(token.generate(settings.accessKey), 'AppToken');
            let client = new powerbi.PowerBIClient(credentials, settings.baseUri, null);

            if (!_.isUndefined(settings.overwrite) && settings.overwrite) {
                options.nameConflict = 'Overwrite';
            }

            options.datasetDisplayName = settings.displayName;

            if (!fs.existsSync(settings.file)) {
                throw new Error(util.format('File "%s" not found', settings.file));
            }

            cli.print('Importing %s to workspace: %s', settings.file, settings.workspace);

            client.imports.uploadFile(settings.collection, settings.workspace, settings.file, options, (err, result, request, response) => {
                if (err) {
                    return cli.error(err);
                }

                let importResult: powerbi.ImportModel = result;

                cli.print('File uploaded successfully');
                cli.print('Import ID: %s', importResult.id);

                checkImportState(client, importResult, (importStateErr, importStateResult) => {
                    if (importStateErr) {
                        return cli.print(importStateErr);
                    }

                    cli.print('Import succeeded');
                });
            });
        } catch (err) {
            cli.error(err);
        }
    }

    /**
     * Checks the import state of the requested import id
     */
    function checkImportState(client: powerbi.PowerBIClient, importResult: powerbi.ImportModel, callback) {
        client.imports.getImportById(settings.collection, settings.workspace, importResult.id, (err, result) => {
            importResult = result;
            cli.print('Checking import state: %s', importResult.importState);

            if (importResult.importState === 'Succeeded' || importResult.importState === 'Failed') {
                callback(null, importResult);
            } else {
                setTimeout(() => {
                    checkImportState(client, importResult, callback);
                }, 500);
            }
        });
    }
}
开发者ID:llenroc,项目名称:PowerBI-Cli,代码行数:87,代码来源:cli-import.ts


示例15: PREDICATE_SYNTAX

export function PREDICATE_SYNTAX(message: string) {
    let fmt = `Predicate syntax error: %s`;
    return error(format(fmt, message));
}
开发者ID:yortus,项目名称:multimethods,代码行数:4,代码来源:fatal-error.ts


示例16: INVALID_STRICT_OPTION

export function INVALID_STRICT_OPTION(value: any) {
    let fmt = `Expected a boolean or undefined value for options.strict, but found %j.`;
    return error(format(fmt, value));
}
开发者ID:yortus,项目名称:multimethods,代码行数:4,代码来源:fatal-error.ts


示例17: STRICT_VALIDATION

export function STRICT_VALIDATION(problems: string[]) {
    let fmt = `Strict validation failed. The following problems were found: %s`;
    return error(format(fmt, '\n' + problems.map((p, i) => `${i + 1}. ${p}`).join('\n')));
}
开发者ID:yortus,项目名称:multimethods,代码行数:4,代码来源:fatal-error.ts


示例18: INVALID_TO_DISCRIMINANT_OPTION

export function INVALID_TO_DISCRIMINANT_OPTION() {
    let fmt = `Expected a function or undefined value for options.toDiscriminant.`;
    return error(format(fmt));
}
开发者ID:yortus,项目名称:multimethods,代码行数:4,代码来源:fatal-error.ts


示例19: UNHANDLED

export function UNHANDLED(discriminant: string) {
    let fmt = `Multimethod dispatch failure: call was unhandled for the given arguments (discriminant = '%s').`;
    return error(format(fmt, discriminant), UNHANDLED_DISPATCH);
}
开发者ID:yortus,项目名称:multimethods,代码行数:4,代码来源:fatal-error.ts


示例20: INVALID_UNREACHABLE_OPTION

export function INVALID_UNREACHABLE_OPTION() {
    let fmt = `Expected a function or undefined value for options.unreachable.`;
    return error(format(fmt));
}
开发者ID:yortus,项目名称:multimethods,代码行数:4,代码来源:fatal-error.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript util.inherits函数代码示例发布时间:2022-05-25
下一篇:
TypeScript util.deprecate函数代码示例发布时间: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