Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const asdecimal = (arg: MessageArg): Decimal => {
switch (typeof arg) {
case 'string':
try {
return new Decimal(arg);
} catch (e) {
return DecimalConstants.NAN;
}
case 'number':
return new Decimal(arg);
case 'boolean':
return arg ? DecimalConstants.ONE : DecimalConstants.ZERO;
case 'object':
if (arg instanceof Decimal) {
return arg;
}
break;
}
return DecimalConstants.NAN;
};