aboutsummaryrefslogtreecommitdiff
path: root/src/arguments/abbreviatedNumber.ts
blob: 99f6df727a7f6f1c6ac8ea186bb96d33336d28d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
import { BushArgumentTypeCaster } from '@lib';
import numeral = require('numeral');

export const abbreviatedNumberTypeCaster: BushArgumentTypeCaster = (_, phrase): number | null => {
	if (!phrase) return null;
	const num = numeral(phrase?.toLowerCase()).value();

	if (!num || isNaN(num)) return null;

	return num;
};