This commit is contained in:
Niklas Fondberg
2021-04-19 10:15:38 +02:00
parent e33d21e320
commit 6bd48467a3
2 changed files with 61 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
function isNumeric(n: any) {
return !isNaN(n);
}
function isBoolean(n: any) {
if (typeof n === 'boolean') {
return true;
}
n = new String(n).toLowerCase();
if (n === 'true' || n == 'false') {
return Boolean(n);
}
return false;
}
export function convertToPossibleType(n: any) {
if (isBoolean(n)) return Boolean('false');
if (isNumeric(n)) return Number(n);
return n;
}