All files / src/node-obfuscators/replacers NumberLiteralReplacer.ts

100% Statements 7/7
100% Branches 2/2
100% Functions 0/0
100% Lines 7/7
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 191x 1x   1x           51217x   51217x 1012x     50205x      
import { AbstractReplacer } from './AbstractReplacer';
import { Utils } from '../../Utils';
 
export class NumberLiteralReplacer extends AbstractReplacer {
    /**
     * @param nodeValue
     * @returns {string}
     */
    public replace (nodeValue: number): string {
        const prefix: string = '0x';
 
        if (!Utils.isInteger(nodeValue)) {
            return String(nodeValue);
        }
 
        return `${prefix}${Utils.decToHex(nodeValue)}`;
    }
}