本文整理汇总了TypeScript中numeral类的典型用法代码示例。如果您正苦于以下问题:TypeScript numeral类的具体用法?TypeScript numeral怎么用?TypeScript numeral使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了numeral类的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 ''
}
开发者ID:carlosrfernandez,项目名称:ReactiveTraderCloud,代码行数:7,代码来源:chartUtil.ts
示例2: convert
function convert (strVal: string): number {
if (strVal.length > 0 && (!strVal.includes(',') || containsAThousandSeparator(strVal))) {
return numeral(strVal).value()
} else {
return undefined
}
}
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:7,代码来源:numericUtils.ts
示例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;
}
开发者ID:sigmaframeworks,项目名称:sigma-ui-framework,代码行数:10,代码来源:ui-format.ts
示例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();
};
开发者ID:ManageIQ,项目名称:ui-components,代码行数:16,代码来源:abbrNumberFilter.ts
示例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,
}
}
开发者ID:tdeheurles,项目名称:ReactiveTraderCloud,代码行数:18,代码来源:spotTileOperations.ts
示例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
];
});
开发者ID:Resounding,项目名称:Jobs-Web,代码行数:20,代码来源:csv-export.ts
示例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);
};
}
}
开发者ID:boneill42,项目名称:pivot,代码行数:23,代码来源:formatter.ts
示例8: toView
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');
}
开发者ID:mobilemancer,项目名称:DroidWorx-Aurelia-dotNETCore,代码行数:24,代码来源:credit-converter.ts
示例9: formatMoney
static formatMoney (value: number): string {
return numeral(value).format(NUMBER_FORMAT)
}
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:3,代码来源:numberFormatter.ts
示例10: return
return (n: number) => {
if (isNaN(n) || !isFinite(n)) return '-';
return numeral(n).format(format);
};
开发者ID:boneill42,项目名称:pivot,代码行数:4,代码来源:formatter.ts
注:本文中的numeral类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论