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


TypeScript lodash.toString函数代码示例

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


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

示例1: csvEscape

export function csvEscape(value: any): string {
    const valueStr = toString(value)
    if (includes(valueStr, ","))
        return `"${value.replace(/\"/g, "\"\"")}"`
    else
        return value
}
开发者ID:OurWorldInData,项目名称:owid-grapher,代码行数:7,代码来源:Util.ts

示例2: if

    _.forEach(funcDef.params, rawParam => {
      const param = {
        name: rawParam.name,
        type: 'string',
        optional: !rawParam.required,
        multiple: !!rawParam.multiple,
        options: undefined,
      };

      if (rawParam.default !== undefined) {
        func.defaultParams.push(_.toString(rawParam.default));
      } else if (rawParam.suggestions) {
        func.defaultParams.push(_.toString(rawParam.suggestions[0]));
      } else {
        func.defaultParams.push('');
      }

      if (rawParam.type === 'boolean') {
        param.type = 'boolean';
        param.options = ['true', 'false'];
      } else if (rawParam.type === 'integer') {
        param.type = 'int';
      } else if (rawParam.type === 'float') {
        param.type = 'float';
      } else if (rawParam.type === 'node') {
        param.type = 'node';
        param.options = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'];
      } else if (rawParam.type === 'nodeOrTag') {
        param.type = 'node_or_tag';
        param.options = ['name', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'];
      } else if (rawParam.type === 'intOrInterval') {
        param.type = 'int_or_interval';
      } else if (rawParam.type === 'seriesList') {
        param.type = 'value_or_series';
      }

      if (rawParam.options) {
        param.options = _.map(rawParam.options, _.toString);
      } else if (rawParam.suggestions) {
        param.options = _.map(rawParam.suggestions, _.toString);
      }

      func.params.push(param);
    });
开发者ID:gzq0616,项目名称:grafana,代码行数:44,代码来源:gfunc.ts

示例3: indent

 static indent(unitIndent: number, numIndent: number, argSource: any, noIndentFirstLine: boolean = false): string {
   let result: string = "";
   let source: string = _.isString(argSource) ? argSource : _.toString(argSource);
   let lines: string[] = source.split(/\n/g);
   if (lines[lines.length - 1] == "") lines.pop();
   lines.forEach((line: string, index: number) => {
     let newLine: string = (index < lines.length - 1) ? "\n" : "";
     if (line && (index > 0 || !noIndentFirstLine))
       result += _.repeat(" ", unitIndent * numIndent) + line + newLine;
     else
       result += line + newLine;
   });
   return result;
 }
开发者ID:nashika,项目名称:spreadsheet-code-generator,代码行数:14,代码来源:source-utils.ts

示例4: getCloneName

 private getCloneName(bootEnvironment: BootEnvironment): string {
     let commonPrefix = bootEnvironment.id + '-copy-',
         usedNames = _.filter((this.bootEnvironments.keySeq().toJS() as string[]), name => _.startsWith(commonPrefix)),
         lastUsedIndex = !usedNames.length ?
         0 :
         _.last(
             _.sortBy(
                 _.map(
                     usedNames,
                     name => _.toNumber(name.substring(commonPrefix.length))
                 )
             )
         );
     return commonPrefix + _.toString(lastUsedIndex + 1);
 }
开发者ID:mactanxin,项目名称:gui,代码行数:15,代码来源:boot-pool-repository.ts

示例5: source

 static source(argSource: any): string {
   let result: string = "";
   let source: string = _.isString(argSource) ? argSource : _.toString(argSource);
   let lines: Array<string> = source.toString().split(/\n/g);
   if (lines[0] == "") lines.shift();
   if (lines[lines.length - 1] == "") lines.pop();
   lines.forEach((line: string) => {
     if (line.match(/###DeleteLine###/)) return;
     if (line.match(/###NoNewLine###/)) {
       line = line.replace(/###NoNewLine###/, "");
       result = result.replace(/\n$/m, "");
     }
     result += line + "\n";
   });
   return result;
 }
开发者ID:nashika,项目名称:spreadsheet-code-generator,代码行数:16,代码来源:source-utils.ts

示例6: return

    return (value: any) => {
      const { mappings, thresholds, theme } = options;
      let color;

      let text = _.toString(value);
      let numeric = toNumber(value);

      let shouldFormat = true;
      if (mappings && mappings.length > 0) {
        const mappedValue = getMappedValue(mappings, value);

        if (mappedValue) {
          text = mappedValue.text;
          const v = toNumber(text);

          if (!isNaN(v)) {
            numeric = v;
          }

          shouldFormat = false;
        }
      }

      if (field.dateFormat) {
        const date = toMoment(value, numeric, field.dateFormat);
        if (date.isValid()) {
          text = date.format(field.dateFormat);
          shouldFormat = false;
        }
      }

      if (!isNaN(numeric)) {
        if (shouldFormat && !_.isBoolean(value)) {
          const { decimals, scaledDecimals } = getDecimalsForValue(value, field.decimals);
          text = formatFunc(numeric, decimals, scaledDecimals, options.isUtc);
        }
        if (thresholds && thresholds.length) {
          color = getColorFromThreshold(numeric, thresholds, theme);
        }
      }

      if (!text) {
        text = options.noValue ? options.noValue : '';
      }
      return { text, numeric, color };
    };
开发者ID:grafana,项目名称:grafana,代码行数:46,代码来源:displayValue.ts

示例7: function

 function(value, index) {
   var paramType;
   if (index < this.def.params.length) {
     paramType = this.def.params[index].type;
   } else if (_.get(_.last(this.def.params), 'multiple')) {
     paramType = _.get(_.last(this.def.params), 'type');
   }
   if (paramType === 'value_or_series') {
     return value;
   }
   if (paramType === 'boolean' && _.includes(['true', 'false'], value)) {
     return value;
   }
   if (_.includes(['int', 'float', 'int_or_interval', 'node_or_tag', 'node'], paramType) && _.isFinite(+value)) {
     return _.toString(+value);
   }
   return "'" + value + "'";
 }.bind(this)
开发者ID:GPegel,项目名称:grafana,代码行数:18,代码来源:gfunc.ts

示例8: if

    const parameters = _.map(this.params, (value, index) => {
      let paramType;

      if (index < this.def.params.length) {
        paramType = this.def.params[index].type;
      } else if (_.get(_.last(this.def.params), 'multiple')) {
        paramType = _.get(_.last(this.def.params), 'type');
      }

      // param types that should never be quoted
      if (_.includes(['value_or_series', 'boolean', 'int', 'float', 'node'], paramType)) {
        return value;
      }

      const valueInterpolated = _.isString(value) ? replaceVariables(value) : value;

      // param types that might be quoted
      // To quote variables correctly we need to interpolate it to check if it contains a numeric or string value
      if (_.includes(['int_or_interval', 'node_or_tag'], paramType) && _.isFinite(+valueInterpolated)) {
        return _.toString(value);
      }

      return "'" + value + "'";
    });
开发者ID:grafana,项目名称:grafana,代码行数:24,代码来源:gfunc.ts

示例9:

 .map(index => ({
   key: _.toString(index),
   active: _.eq(index, this.pageIndex),
   handler: () => this.setPageIndex(index),
 })
开发者ID:zhenwenc,项目名称:rc-box,代码行数:5,代码来源:PaginationPlugin.ts


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