本文整理汇总了TypeScript中numeral.default方法的典型用法代码示例。如果您正苦于以下问题:TypeScript numeral.default方法的具体用法?TypeScript numeral.default怎么用?TypeScript numeral.default使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类numeral
的用法示例。
在下文中一共展示了numeral.default方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getPositionValue
export function getPositionValue(id: string, positionsData: any[]) {
const index = _.findIndex(positionsData, (pos: any) => pos.symbol === id)
if (index >= 0) {
return numeral(positionsData[index].baseTradedAmount).format('0,0')
}
return ''
}
示例2: convert
function convert (strVal: string): number {
if (strVal.length > 0 && (!strVal.includes(',') || containsAThousandSeparator(strVal))) {
return numeral(strVal).value()
} else {
return undefined
}
}
示例3: number
export function number(nm: any, fm: string = '0,0[.]00'): string {
let ret = nm === null || isNaN(nm) ? '' : numeral(nm).format(fm);
if (fm.indexOf('{') === 0) {
let minlen = fm.length - 2;
if (ret.length < minlen) {
ret = Array(minlen - ret.length + 1).join('0') + ret;
}
}
return ret;
}
示例4: return
return (value) => {
let num = numeral(value);
// Return with the input if it is not a number
if (!num.value() || num.value().toString() !== value.toString()) {
return value;
}
let abbr = num.format('0.0a');
if (abbr.match(/\d\.0[a-z]?$/) || abbr.length > 5) {
// Drop the .0 as we want to save the space
abbr = num.format('0a');
}
return abbr.toUpperCase();
};
示例5: buildNotification
function buildNotification(trade, error) {
if (error) {
return { message: error, hasError: true, notificationType: NotificationType.Text }
}
return {
notificationType: NotificationType.Trade,
hasError: false,
direction: trade.direction === Direction.Sell ? 'Sold' : 'Bought',
notional: numeral(trade.notional).format('0,000,000[.]00'),
status: trade.status,
dealtCurrency: trade.currencyPair.base,
termsCurrency: trade.currencyPair.terms,
spotRate: trade.spotRate,
formattedValueDate: `SP. ${timeFormat('%b %e')(trade.valueDate)}`,
tradeId: trade.tradeId,
}
}
示例6: numeral
.map(job => {
//http://stackoverflow.com/a/10073761
const formattedNumber: string = numeral(job.number).value() < 99999 ? `0000${job.number}`.slice(-5) : job.number.toString(),
prefix = job.job_type === JobType.SERVICE_CALL ? 'S' : 'P',
startMoment = moment(job.startDate),
endMoment = moment(job.endDate),
start = job.startDate && startMoment.isValid() ? startMoment.format('YYYY-MM-DD') : '',
end = job.endDate && endMoment.isValid() ? endMoment.format('YYYY-MM-DD') : '';
return [
`${prefix}-${formattedNumber}`,
job.name,
job.customer.name,
job.status,
job.foreman,
job.description,
job.notes,
start,
end
];
});
示例7: formatterFromData
export function formatterFromData(values: number[], format: string): Formatter {
var match = format.match(/^(\S*)( ?)([ab])$/);
if (match) {
var numberFormat = match[1];
var space = match[2];
var formatType = match[3];
var middle = getMiddleNumber(values);
var formatMiddle = numeral(middle).format('0 ' + formatType);
var unit = formatMiddle.split(' ')[1] || '';
var scale = scales[formatType][unit];
var append = unit ? space + unit : '';
return (n: number) => {
if (isNaN(n) || !isFinite(n)) return '-';
return numeral(n / scale).format(numberFormat) + append;
};
} else {
return (n: number) => {
if (isNaN(n) || !isFinite(n)) return '-';
return numeral(n).format(format);
};
}
}
示例8: numeral
toView(value) {
numeral.language('galacticbasic', {
delimiters: {
thousands: ' ',
decimal: '.'
},
abbreviations: {
thousand: 'k',
million: 'm',
billion: 'b',
trillion: 't'
},
ordinal: function (number) {
return number === 1 ? 'st' : 'th';
},
currency: {
symbol: ""
}
});
// switch between languages
numeral.language('galacticbasic');
return numeral(value).format('$ 0.0 a');
}
示例9: formatMoney
static formatMoney (value: number): string {
return numeral(value).format(NUMBER_FORMAT)
}
示例10: numeral
return (n: number) => {
if (isNaN(n) || !isFinite(n)) return '-';
return numeral(n).format(format);
};