saleor-dashboard/src/utils/toFixed.ts
Patryk Andrzejewski 1d2eeb7592
Strict mode plugin (#3778)
* Stric mode plugin

* Update command
2023-06-21 11:28:00 +02:00

9 lines
250 B
TypeScript

// @ts-strict-ignore
export function toFixed(num: string | number, fixed: number) {
if (num === "" || num === null) {
return "";
}
const re = new RegExp("^-?\\d+(?:.\\d{0," + (fixed || -1) + "})?");
return num.toString().match(re)[0];
}