本文整理汇总了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;
示例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) {
示例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;
示例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);
}
示例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));
}
}
示例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"));
}
示例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);
}
示例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();
});
示例9:
const uniqueValues = _.uniq(values.map(v=>numeral(v).format(format)));
示例10: numeral
formatNumber: number => numeral(number).format('0,0'),