Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// @ts-ignore
import numeral from '@elastic/numeral';
// @ts-ignore
import numeralLanguages from '@elastic/numeral/languages';
import { KBN_FIELD_TYPES } from '../../kbn_field_types/types';
import { FieldFormat } from '../field_format';
import { TextContextTypeConvert } from '../types';
const numeralInst = numeral();
numeralLanguages.forEach((numeralLanguage: Record) => {
numeral.language(numeralLanguage.id, numeralLanguage.lang);
});
export abstract class NumeralFormat extends FieldFormat {
static fieldType = KBN_FIELD_TYPES.NUMBER;
abstract id: string;
abstract title: string;
getParamDefaults = () => ({
pattern: this.getConfig!(`format:${this.id}:defaultPattern`),
});
protected getConvertedValue(val: any): string {
if (val === -Infinity) return '-∞';
if (val === +Infinity) return '+∞';