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

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

	if (num === undefined || num === null || isNaN(num)) return null;

	return num;
};