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

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

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