NumberLiteralReplacer.ts 463 B

123456789101112131415161718
  1. import { AbstractReplacer } from './AbstractReplacer';
  2. import { Utils } from '../../Utils';
  3. export class NumberLiteralReplacer extends AbstractReplacer {
  4. /**
  5. * @param nodeValue
  6. * @returns {string}
  7. */
  8. public replace (nodeValue: number): string {
  9. const prefix: string = '0x';
  10. if (!Utils.isInteger(nodeValue)) {
  11. return String(nodeValue);
  12. }
  13. return `${prefix}${Utils.decToHex(nodeValue)}`;
  14. }
  15. }