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

export const abbreviatedNumber: 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;
};