summaryrefslogtreecommitdiff
path: root/source/helpers/loose-parse-int.ts
blob: c6d8f393472c96aaced13fdcdcee954889ba572b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
export default function looseParseInt(text: Node | string | undefined): number {
	if (!text) {
		return 0;
	}

	if (typeof text !== 'string') {
		text = text.textContent!;
	}

	return Number(text.replaceAll(/\D+/g, ''));
}