summaryrefslogtreecommitdiff
path: root/source/helpers/loose-parse-int.ts
blob: 6816bba9e6e5df7f1d246c3bc136a2a203ba3ad7 (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.replace(/\D+/g, ''));
}