當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。