本文整理汇总了TypeScript中@elastic/numeral.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: validateMaxContentLength
export async function validateMaxContentLength(server: any, log: (message: string) => any) {
const config = server.config();
const { callWithInternalUser } = server.plugins.elasticsearch.getCluster('data');
const elasticClusterSettingsResponse = await callWithInternalUser('cluster.getSettings', {
includeDefaults: true,
});
const { persistent, transient, defaults: defaultSettings } = elasticClusterSettingsResponse;
const elasticClusterSettings = defaults({}, persistent, transient, defaultSettings);
const elasticSearchMaxContent = get(elasticClusterSettings, 'http.max_content_length', '100mb');
const elasticSearchMaxContentBytes = numeral().unformat(elasticSearchMaxContent.toUpperCase());
const kibanaMaxContentBytes = config.get(KIBANA_MAX_SIZE_BYTES_PATH);
if (kibanaMaxContentBytes > elasticSearchMaxContentBytes) {
log(
`${KIBANA_MAX_SIZE_BYTES_PATH} (${kibanaMaxContentBytes}) is higher than ElasticSearch's ${ES_MAX_SIZE_BYTES_PATH} (${elasticSearchMaxContentBytes}). ` +
`Please set ${ES_MAX_SIZE_BYTES_PATH} in ElasticSearch to match, or lower your ${KIBANA_MAX_SIZE_BYTES_PATH} in Kibana to avoid this warning.`
);
}
}
示例2: asPercent
export function asPercent(
numerator: number,
denominator: number | undefined,
fallbackResult = ''
) {
if (!denominator) {
return fallbackResult;
}
const decimal = numerator / denominator;
return numeral(decimal).format('0.0%');
}
示例3: asPercent
export function asPercent(
numerator: number,
denominator?: number,
fallbackResult = ''
) {
if (denominator === 0) {
return fallbackResult;
}
const decimal = denominator ? numerator / denominator : numerator;
return numeral(decimal).format('0.00%');
}
示例4: asInteger
export function asInteger(value: number) {
return numeral(value).format('0,0');
}
示例5: asDecimal
export function asDecimal(value: number) {
return numeral(value).format('0,0.0');
}
示例6: String
fn: (context, args) => {
if (!args.format) {
return String(context);
}
return numeral(context).format(args.format);
},