本文整理匯總了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);
},