How to use the @phensley/decimal.DecimalConstants.NAN function in @phensley/decimal

To help you get started, we’ve selected a few @phensley/decimal examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github phensley / cldr-engine / packages / messageformat / src / evaluation / args.ts View on Github external
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;
};