-
-
Notifications
You must be signed in to change notification settings - Fork 184
Expand file tree
/
Copy pathParseFloat.ts
More file actions
13 lines (11 loc) · 531 Bytes
/
ParseFloat.ts
File metadata and controls
13 lines (11 loc) · 531 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
import { __TS__Match } from "./Match";
export function __TS__ParseFloat(this: void, numberString: string): number {
// Check if string is infinity
const [infinityMatch] = __TS__Match(numberString, "^%s*(-?Infinity)");
if (infinityMatch !== undefined) {
// eslint-disable-next-line @typescript-eslint/prefer-string-starts-ends-with
return infinityMatch[0] === "-" ? -Infinity : Infinity;
}
const number = tonumber(__TS__Match(numberString, "^%s*(-?%d+%.?%d*)")[0]);
return number ?? NaN;
}