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


TypeScript lodash.toNumber函數代碼示例

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


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

示例1: configureAxisOptions

      function configureAxisOptions(data, options) {
        var defaults = {
          position: 'left',
          show: panel.yaxes[0].show,
          index: 1,
          logBase: panel.yaxes[0].logBase || 1,
          min: panel.yaxes[0].min ? _.toNumber(panel.yaxes[0].min) : null,
          max: panel.yaxes[0].max ? _.toNumber(panel.yaxes[0].max) : null,
        };

        options.yaxes.push(defaults);

        if (_.find(data, {yaxis: 2})) {
          var secondY = _.clone(defaults);
          secondY.index = 2;
          secondY.show = panel.yaxes[1].show;
          secondY.logBase = panel.yaxes[1].logBase || 1;
          secondY.position = 'right';
          secondY.min = panel.yaxes[1].min ? _.toNumber(panel.yaxes[1].min) : null;
          secondY.max = panel.yaxes[1].max ? _.toNumber(panel.yaxes[1].max) : null;
          options.yaxes.push(secondY);

          applyLogScale(options.yaxes[1], data);
          configureAxisMode(options.yaxes[1], panel.percentage && panel.stack ? "percent" : panel.yaxes[1].format);
        }
        applyLogScale(options.yaxes[0], data);
        configureAxisMode(options.yaxes[0], panel.percentage && panel.stack ? "percent" : panel.yaxes[0].format);
      }
開發者ID:casaria,項目名稱:grafana-trillium-src-fork,代碼行數:28,代碼來源:graph.ts

示例2: tickFormatter

 function tickFormatter(valIndex) {
   let valueFormatted = tsBuckets[valIndex];
   if (!_.isNaN(_.toNumber(valueFormatted)) && valueFormatted !== '') {
     // Try to format numeric tick labels
     valueFormatted = tickValueFormatter(decimals)(_.toNumber(valueFormatted));
   }
   return valueFormatted;
 }
開發者ID:fangjianfeng,項目名稱:grafana,代碼行數:8,代碼來源:rendering.ts

示例3: parseNumber

  parseNumber(value: any) {
    if (value === null || typeof value === 'undefined') {
      return null;
    }

    return _.toNumber(value);
  }
開發者ID:CorpGlory,項目名稱:grafana,代碼行數:7,代碼來源:graph.ts

示例4: _getDuplicateFailure

 private _getDuplicateFailure(key: string, imports: ImportOrExportDeclaration[]) {
     const values = key.split('|');
     const kind = _.toNumber(key.split('|')[0]);
     const name = values[1];
     const message = `order imports: duplicate ${ts.SyntaxKind[kind].toLowerCase()} '${name}' found and should be consolidated`;
     return _.map(imports, x => this.createFailure(x.getStart(), x.getWidth(), message));
 }
開發者ID:OmniSharp,項目名稱:atom-languageclient,代碼行數:7,代碼來源:orderImportsRule.ts

示例5: toNumber

/** Will return any value as a number or NaN */
function toNumber(value: any): number {
  if (typeof value === 'number') {
    return value;
  }
  if (value === null || value === undefined || Array.isArray(value)) {
    return NaN; // lodash calls them 0
  }
  if (typeof value === 'boolean') {
    return value ? 1 : 0;
  }
  return _.toNumber(value);
}
開發者ID:grafana,項目名稱:grafana,代碼行數:13,代碼來源:displayValue.ts

示例6: parseInt

export const fromConwayNotation = (notation: string) => {
  const prefix = notation[0];
  const number = parseInt(notation.substring(1));
  if (platonicMapping.get(notation)) {
    return platonicMapping.get(notation);
  }
  if (archimedeanMapping.get(notation)) {
    return archimedeanMapping.get(notation);
  }
  if (prefix === 'J') {
    return johnsonSolids[_.toNumber(number) - 1];
  }
  if (prefix === 'P') {
    return `${polygonPrefixes.get(number)} prism`;
  }
  if (prefix === 'A') {
    return `${polygonPrefixes.get(number)} antiprism`;
  }
  return '';
};
開發者ID:tessenate,項目名稱:polyhedra-viewer,代碼行數:20,代碼來源:names.ts

示例7: autoCastValue

export function autoCastValue(value: any): any {
  if (_.isArray(value)) {
    return value.map(value => value.toString());
  }
  if (_.isString(value)) { // String
    return value;
  }
  if (_.isBoolean(value)) { // Boolean
    return Boolean(value);
  }
  if (_.isNumber(value)) {
    return _.toNumber(value);
  }
  if (Long.isLong(value)) {
    return (value as Long).toNumber();
  }
  if (_.isDate(value)) { // Date
    return new Date(value);
  }
  return value;
}
開發者ID:restorecommerce,項目名稱:chassis-srv,代碼行數:21,代碼來源:common.ts

示例8: restoreTask

 private restoreTask(taskId: number) {
     taskId = _.toNumber(taskId);
     if (this.taskStacks.has(taskId)) {
         let stack = _.clone(this.taskStacks.get(taskId)),
             section = stack[0].object,
             sectionId = section.id;
         let taskState = this.datastoreService.getState().get(Model.Task);
         if (taskState &&
             taskState.get((taskId as any)) &&
             taskState.get(taskId).get('error')) {
             _.last(stack).error = taskState.get(taskId).get('error').toJS();
         }
         if (this.currentStacks.has(sectionId)) {
             this.currentStacks.set(sectionId, stack);
         } else {
             this.sectionRouters.get(sectionId).restore(stack);
         }
         this.eventDispatcherService.dispatch('sectionRestored', stack);
         this.changeHash(_.last(stack).path);
     }
 }
開發者ID:pchaussalet,項目名稱:gui,代碼行數:21,代碼來源:routing-service.ts

示例9:

 name => _.toNumber(name.substring(commonPrefix.length))
開發者ID:mactanxin,項目名稱:gui,代碼行數:1,代碼來源:boot-pool-repository.ts

示例10: function

	savers[n] = function() { return _.toNumber($('#'+n).val()); };
開發者ID:UnlitStudio,項目名稱:PlazaPlus,代碼行數:1,代碼來源:options.ts


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