Files
graphql-api-js/src/datasources/utils.ts
T
2021-04-19 10:15:38 +02:00

21 lines
398 B
TypeScript

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;
}