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

TypeScript lodash.isNumber函数代码示例

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

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



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

示例1: histogramToHeatmap

/**
 * Convert histogram represented by the list of series to heatmap object.
 * @param seriesList List of time series
 */
function histogramToHeatmap(seriesList) {
  const heatmap = {};

  for (let i = 0; i < seriesList.length; i++) {
    const series = seriesList[i];
    const bound = i;
    if (isNaN(bound)) {
      return heatmap;
    }

    for (const point of series.datapoints) {
      const count = point[VALUE_INDEX];
      const time = point[TIME_INDEX];

      if (!_.isNumber(count)) {
        continue;
      }

      let bucket = heatmap[time];
      if (!bucket) {
        bucket = heatmap[time] = { x: time, buckets: {} };
      }

      bucket.buckets[bound] = {
        y: bound,
        count: count,
        bounds: {
          top: null,
          bottom: bound,
        },
        values: [],
        points: [],
      };
    }
  }

  return heatmap;
}
开发者ID:grafana,项目名称:grafana,代码行数:42,代码来源:heatmap_data_converter.ts


示例2: getRate

  getRate(opts, cb) {
    $.shouldBeFunction(cb);

    opts = opts || {};

    const now = Date.now();
    const coin = opts.coin || 'btc';
//    const provider = opts.provider || this.defaultProvider;
    const ts = _.isNumber(opts.ts) || _.isArray(opts.ts) ? opts.ts : now;

    async.map(
      [].concat(ts),
      (ts, cb) => {
        this.storage.fetchFiatRate(coin, opts.code, ts, (
          err,
          rate
        ) => {
          if (err) return cb(err);
          if (
            rate &&
            ts - rate.ts > Defaults.FIAT_RATE_MAX_LOOK_BACK_TIME * 60 * 1000
          )
            rate = null;

          return cb(null, {
            ts: +ts,
            rate: rate ? rate.value : undefined,
            fetchedOn: rate ? rate.ts : undefined
          });
        });
      },
      (err, res: any) => {
        if (err) return cb(err);
        if (!_.isArray(ts)) res = res[0];
        return cb(null, res);
      }
    );
  }
开发者ID:bitpay,项目名称:bitcore,代码行数:38,代码来源:fiatrateservice.ts


示例3: drawHook

      function drawHook(plot) {
        // Update legend values
        var yaxis = plot.getYAxes();
        for (var i = 0; i < data.length; i++) {
          var series = data[i];
          var axis = yaxis[series.yaxis - 1];
          var formater = kbn.valueFormats[panel.yaxes[series.yaxis - 1].format];

          // decimal override
          if (_.isNumber(panel.decimals)) {
            series.updateLegendValues(formater, panel.decimals, null);
          } else {
            // auto decimals
            // legend and tooltip gets one more decimal precision
            // than graph legend ticks
            var tickDecimals = (axis.tickDecimals || -1) + 1;
            series.updateLegendValues(formater, tickDecimals, axis.scaledDecimals + 2);
          }

          if (!rootScope.$$phase) { scope.$digest(); }
        }

        // add left axis labels
        if (panel.yaxes[0].label && panel.yaxes[0].show) {
          var yaxisLabel = $("<div class='axisLabel left-yaxis-label flot-temp-elem'></div>")
          .text(panel.yaxes[0].label)
          .appendTo(elem);
        }

        // add right axis labels
        if (panel.yaxes[1].label && panel.yaxes[1].show) {
          var rightLabel = $("<div class='axisLabel right-yaxis-label flot-temp-elem'></div>")
          .text(panel.yaxes[1].label)
          .appendTo(elem);
        }

        thresholdManager.draw(plot);
      }
开发者ID:casaria,项目名称:grafana-trillium-src-fork,代码行数:38,代码来源:graph.ts


示例4: function

Webhooks.prototype.listNotifications = function(params, callback) {
  params = params || {};
  common.validateParams(params, [], [], callback);

  const query: any = {};
  if (params.prevId) {
    if (!_.isString(params.prevId)) {
      throw new Error('invalid prevId argument, expecting string');
    }
    query.prevId = params.prevId;
  }
  if (params.limit) {
    if (!_.isNumber(params.limit)) {
      throw new Error('invalid limit argument, expecting number');
    }
    query.limit = params.limit;
  }

  return this.bitgo.get(this.baseCoin.url('/webhooks/notifications'))
  .query(query)
  .result()
  .nodeify(callback);
};
开发者ID:BitGo,项目名称:BitGoJS,代码行数:23,代码来源:webhooks.ts


示例5:

 makeRoomTypes.forEach((makeRoomType) => {
   const items = store.buckets[makeRoomType];
   if (items.length > 0 && items.length >= store.capacityForItem(items[0])) {
     // We'll move the lowest-value item to the vault.
     const itemToMove = _.minBy(items.filter((i) => !i.equipped && !i.notransfer), (i) => {
       let value = {
         Common: 0,
         Uncommon: 1,
         Rare: 2,
         Legendary: 3,
         Exotic: 4
       }[i.tier];
       // And low-stat
       if (i.primStat) {
         value += i.primStat.value / 1000;
       }
       return value;
     });
     if (!_.isNumber(itemToMove)) {
       itemsToMove.push(itemToMove!);
     }
   }
 });
开发者ID:w1cked,项目名称:DIM,代码行数:23,代码来源:farming.service.ts


示例6: async

    return async (dispatch: (action: any) => void, getState: () => GertyState, bundle: Bundle) => {

        const state = getState();

        const pid = _.isNumber(globalProcessIdOrPid)
            ? globalProcessIdOrPid
            : state.configuration.processStates[globalProcessIdOrPid].pid;

        const processManager = bundle.container
            .get<ProcessManager>(gertyDomainSymbols.ProcessManager);

        await processManager.stop(pid);

        const processHistoryState = JSON.parse(localStorage.getItem("gerty:process-history")) as ProcessHistoryState || {};

        const updatedProcessHistoryState = _.pickBy(processHistoryState,
            (processHistories: ProcessHistory[], historicGlobalProcessId: GlobalProcessId) =>
                !_.flatMap(processHistories, (processHistory) => processHistory.pid)
                    .includes(pid)
        );

        localStorage.setItem("gerty:process-history", JSON.stringify(updatedProcessHistoryState));
    };
开发者ID:atrauzzi,项目名称:Gerty,代码行数:23,代码来源:StopProcessViaPid.ts


示例7: elasticHistogramToHeatmap

function elasticHistogramToHeatmap(seriesList) {
  let heatmap = {};

  for (let series of seriesList) {
    let bound = Number(series.alias);
    if (isNaN(bound)) {
      return heatmap;
    }

    for (let point of series.datapoints) {
      let count = point[VALUE_INDEX];
      let time = point[TIME_INDEX];

      if (!_.isNumber(count)) {
        continue;
      }

      let bucket = heatmap[time];
      if (!bucket) {
        bucket = heatmap[time] = {x: time, buckets: {}};
      }

      bucket.buckets[bound] = {
        y: bound,
        count: count,
        bounds: {
          top: null,
          bottom: bound
        },
        values: [],
        points: []
      };
    }
  }

  return heatmap;
}
开发者ID:khaled-ansary,项目名称:grafana,代码行数:37,代码来源:heatmap_data_converter.ts


示例8: getDecimalsForValue

  getDecimalsForValue(value) : any {
    if (_.isNumber(this.panel.decimals)) {
      return { decimals: this.panel.decimals, scaledDecimals: null };
    }

    var delta = value / 2;
    var dec = -Math.floor(Math.log(delta) / Math.LN10);

    var magn = Math.pow(10, -dec);
    var norm = delta / magn; // norm is between 1.0 and 10.0
    var size;

    if (norm < 1.5) {
      size = 1;
    } else if (norm < 3) {
      size = 2;
      // special case for 2.5, requires an extra decimal
      if (norm > 2.25) {
        size = 2.5;
        ++dec;
      }
    } else if (norm < 7.5) {
      size = 5;
    } else {
      size = 10;
    }

    size *= magn;

    // reduce starting decimals if not needed
    if (Math.floor(value) === value) { dec = 0; }

    return {
      decimals: Math.max(0, dec),
      scaledDecimals: Math.max(0, dec) - Math.floor(Math.log(size) / Math.LN10) + 2
    };
  }
开发者ID:YuhangGe,项目名称:grafana,代码行数:37,代码来源:piechart_ctrl.ts


示例9: tickQuestion

export function tickQuestion(req: Request, res: Response) {
	let gameName: string = req.params.gameName;
	let currentState: QuestionState = Number(req.params.currentState);

	if (!_.isNumber(currentState) || _.isNaN(currentState)) {
		return res.status(400).json({ code: 'NOT_LEGAL_STATE', message: `${req.params.currentState} is not legal state` });
	}

	getGameReference(gameName).then((game: IGame) => {
		if (currentState === QuestionState.End || currentState === QuestionState.Pending) {
			return res.status(400).json({ code: 'CAN_NOT_TICK_QUESTION', message: `Question is not the active question in the game.` });
		}

		let question: IQuestion = _.find(game.questions, q => q.state === currentState);

		if (!question) {
			return res.status(208).json({ code: 'ALREADY_REPORTED', message: `Question already have been ticked from status ${currentState}` });
		}

		let tickPromise;
		if (question.state === QuestionState.ScoreBoard) {
			tickPromise = advanceToNextQuestion(game);
		} else {
			let questionId = getCurrentQuestionId(game.questions);
			tickPromise = setQuestionState(gameName, questionId, currentState + 1)
		}

		tickPromise
			.then(result => {
				return res.status(200).json(result);
			})
			.catch(err => {
				winston.error('Error while tickQuestion', { path: 'tickQuestion', data: { error: err } })
				return res.status(500).json(err);
			});
	});
}
开发者ID:radotzki,项目名称:bullshit-server,代码行数:37,代码来源:tickQuestion.ts


示例10: function

            _.each(keys, function (key) {
                var i = 0;
                var isExcluded = false;

                if (undefined !== excludes) {
                    if (true !== isExcluded && undefined !== excludes.prefixes) {
                        for (i = 0; i < excludes.prefixes.length; i++) {
                            if (startsWith(key, excludes.prefixes[i])) {
                                isExcluded = true;
                                break;
                            }
                        }
                    }
                    if (true !== isExcluded && undefined !== excludes.suffixes) {
                        for (i = 0; i < excludes.suffixes.length; i++) {
                            if (endsWith(key, excludes.suffixes[i])) {
                                isExcluded = true;
                                break;
                            }
                        }
                    }

                    if (true !== isExcluded && undefined !== excludes.fields) {
                        if (-1 !== _.indexOf(excludes.fields, key, true)) {
                            isExcluded = true;
                        }
                    }
                }

                // We don't want to convert values that are just raw numbers (unless it was in an array)
                if (true !== isExcluded && !_.isNumber(item[key])) {
                    var value = item[key];
                    item[key] = lowercaser(value);
                    item[key + '__RAW'] = value;
                }
            });
开发者ID:richie5um,项目名称:hapiTemplate,代码行数:36,代码来源:index.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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