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


TypeScript numeral.default函数代码示例

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


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

示例1: normalizeGraphNumber

            default:
                return number;
        }
    },
    normalizeGraphNumber(number) {
        switch (number) {
            case "NaN":
            case "Infinity":
            case "-Infinity":
                return 0;
            default:
                return number;
        }
    },
    formatNumber(number) {
        try {
            return numeral(NumberUtils.normalizeNumber(number)).format('0,0.[00]');
        } catch(e) {
            return number;
        }
    },
    formatPercentage(percentage) {
        try {
            return numeral(NumberUtils.normalizeNumber(percentage)).format("0.00%");
        } catch (e) {
            return percentage;
        }
    },
};

export = NumberUtils;
开发者ID:rubao,项目名称:graylog2-web-interface,代码行数:31,代码来源:NumberUtils.ts

示例2: parseLine


//.........这里部分代码省略.........
								err.name = name;
								err.team = team;
								err.steamID = steamID;
								err.amount = amount;
								console.trace(err);
								return;
							}
							Collections.Wagers.insert({
								"player": {
									"id": steamID,
									"name": name,
									"team": team // Will be lowecase
								},
								"amount": amount,
								"decided": false,
								"won": null,
								"time": {
									"timestamp": time.valueOf(),
									"string": time.toString()
								}
							}, {w:1}, function(err: Error) {
								if (err) {
									console.trace(err);
									sendMessage("Sorry, an error occurred");
									return;
								}
								var printTeam: string = (team === "red") ? "Red" : "Blu";
								sendMessage(name + " has wagered " + amount + " DOGE on a win for the " + printTeam + " team!");
							});
						});
					});
				});
				break;
			default:
				sendMessage("I couldn't understand your command");
		}
	}
	var roundWinParsed: any[] = roundWinRegEx.exec(line);
	if (roundWinParsed) {
		var winningTeam = roundWinParsed[1].toLowerCase(); // "red" or "blue"
		async.parallel([
			function(callback) {
				dogecoin.getBalance("WagersRed", callback);
			},
			function(callback) {
				dogecoin.getBalance("WagersBlu", callback);
			}
		], function(err, balances: number[]) {
			var redWagerPool: number = balances[0];
			var bluWagerPool: number = balances[1];
			
			var wagerStream = Collections.Wagers.find({"decided": false}).stream();
			wagerStream.on("data", function(wager): void {
				var won: boolean = (wager.player.team === winningTeam);
				var teamWagerPool = (wager.player.team === "red") ? redWagerPool : bluWagerPool;
				if (won) {
					// Won their bet
					var winnings: number = (wager.amount / teamWagerPool) * (redWagerPool + bluWagerPool);
					var tipComment = {
						"sender": "TF2 Wager",
						"recipient": wager.player.name,
						"refund": false,
						"USD": winnings * prices["DOGE/USD"]
					};
					dogecoin.move("WagersRed", wager.player.id, winnings, 1, stringifyAndEscape(tipComment), function(err: any, success: boolean) {
						if (err) {
开发者ID:hilmysyarif,项目名称:GamersSteamTipBot,代码行数:67,代码来源:tf2logparser.ts

示例3: require

/// <reference path="../../declarations/node/node.d.ts" />

'use strict';

var numeral = require('numeral');

var NumberUtils = {
    normalizeNumber(number) {
        switch (number) {
            case "NaN":
                return NaN;
            case "Infinity":
                return Number.MAX_VALUE;
            case "-Infinity":
                return Number.MIN_VALUE;
            default:
                return number;
        }
    },
    formatNumber(number) {
        try {
            return numeral(NumberUtils.normalizeNumber(number)).format('0,0.[00]');
        } catch(e) {
            return number;
        }
    }
};

export = NumberUtils;
开发者ID:Etienne-Carriere,项目名称:graylog2-web-interface,代码行数:29,代码来源:NumberUtils.ts

示例4: function

        function (err, results) {
            if (err) return callback(err);
            results.freePer = Number(results.available / (results.used + results.available) * 100);
            results.usedPer = Number(results.used / (results.used + results.available) * 100);
            results.total = numeral(results.used + results.available).format('0.00 b');
            results.used = numeral(results.used).format('0.00 b');
            results.available = numeral(results.available).format('0.00 b');
            results.drive = drive;

            callback(null, results);
        }
开发者ID:duffman,项目名称:commander-putte,代码行数:11,代码来源:disk-information.ts

示例5: tickFormatNumeral

export function tickFormatNumeral(val:number, values:number[], transform?:(t:number)=>number) {
    // transform is, e.g., log
    if (transform) {
        val = transform(val);
        values = values.map(transform);
    }
    if (val >= 1000) {
        return numeral(val).format(getUniqueFormatThousands(values));
    } else {
        return numeral(val).format(getUniqueFormatLessThanThousands(values));
    }
}
开发者ID:agarwalrounak,项目名称:cbioportal-frontend,代码行数:12,代码来源:TickUtils.ts

示例6: priceCommand

function priceCommand(chatterID: string, message: string, group: boolean = true) {
	var toSend: string = (group) ? GamersTipGroupID : chatterID;
	var priceMessage: string[] = [
		"Exchange rates as of " + new Date(prices.LastUpdated).toString() + ":",
		"BTC/USD: $" + prices["BTC/USD"].toFixed(2) + " (Coinbase)",
		"GMC/BTC: " + prices["GMC/BTC"].toFixed(8) + " BTC (https://comkort.com/market/trade/gmc_btc)",
		"GMC/USD: $" + prices["GMC/USD"].toFixed(8),
		"1 GMC = 1 GMC"
	];
	if (message.split(" ")[1]) {
		var amount: number = numeral().unformat(message.split(" ")[1]);
		var amountUSD: number = amount * prices["GMC/USD"];
		priceMessage.push(amount + " Gamerscoins = " + numeral(amountUSD).format("$0,0.00"));
	}
	bot.sendMessage(toSend, priceMessage.join("\n"));
}
开发者ID:hilmysyarif,项目名称:GamersSteamTipBot,代码行数:16,代码来源:bot.ts

示例7: numeralFormatting

export function numeralFormatting(tickValue: number): string {
  let format = "0.[00]a";
  if (tickValue === 0) {
    return "0";
  } else if (tickValue > 100000000000000 || tickValue < 0.00001) {
    format = "0.[000]e+0";
  } else if (tickValue < 1) {
    format = "0.[0000]a";
  }
  return numeral(tickValue).format(format);
}
开发者ID:nteract,项目名称:nteract,代码行数:11,代码来源:utilities.ts

示例8: numeral

 server.listen(portNumber, () => {
     var endTime = Date.now();
     var elapsedTime = (endTime - startTime)/1000;
     var t = numeral(elapsedTime).format('0.00');
     console.log('\n');
     console.log(colors.bgGreen(colors.white('                                                         ')));
     console.log(colors.bgGreen(colors.white('           Startup completead in ' + t + ' seconds.           ')));
     console.log(colors.bgGreen(colors.white('                                                         ')));
     console.log('\n');
     console.log("Your application is in "+colors.green(server.get('env'))+" mode on port "+colors.green(portNumber));
     if (onReadyCallback) onReadyCallback();
 });
开发者ID:portalTS,项目名称:portalTS,代码行数:12,代码来源:app.ts

示例9:

 const uniqueValues = _.uniq(values.map(v=>numeral(v).format(format)));
开发者ID:agarwalrounak,项目名称:cbioportal-frontend,代码行数:1,代码来源:TickUtils.ts

示例10: numeral

 formatNumber: number => numeral(number).format('0,0'),
开发者ID:guardian,项目名称:video-dashboard,代码行数:1,代码来源:app.ts


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