How to use the escodegen.Precedence function in escodegen

To help you get started, we’ve selected a few escodegen 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 DefinitelyTyped / DefinitelyTyped / escodegen / escodegen-tests.ts View on Github external
let generateOptions: escodegen.GenerateOptions = {
  format: formatOptions,
  moz: mozillaOptions,
  parse: () => {},
  comment: true,
  sourceMap: " ",
  sourceMapWithCode: true,
  sourceContent: " ",
  sourceCode: " ",
  sourceMapRoot: " ",
  directive: true,
  file: " ",
  verbatim: " "
};

let precedence: escodegen.Precedence = escodegen.Precedence.Primary;

let myCode: string = escodegen.generate({}, generateOptions);

let ast: any = escodegen.attachComments({}, {}, {});
github javascript-obfuscator / javascript-obfuscator / dist / src / node-obfuscators / ObjectExpressionObfuscator.js View on Github external
value: function literalNodeController(node) {
            switch (_typeof(node.value)) {
                case 'string':
                    if (node['x-verbatim-property']) {
                        break;
                    }
                    node['x-verbatim-property'] = {
                        content: Utils_1.Utils.stringToUnicode(node.value),
                        precedence: escodegen.Precedence.Primary
                    };
                    break;
                default:
                    break;
            }
        }
    }, {
github javascript-obfuscator / javascript-obfuscator / dist / src / node-obfuscators / MemberExpressionObfuscator.js View on Github external
value: function identifierNodeController(node) {
            var nodeValue = node.name,
                literalNode = {
                raw: '\'' + nodeValue + '\'',
                'x-verbatim-property': {
                    content: this.replaceLiteralValueByUnicodeValue(nodeValue),
                    precedence: escodegen.Precedence.Primary
                },
                type: NodeType_1.NodeType.Literal,
                value: nodeValue
            };
            delete node.name;
            Object.assign(node, literalNode);
        }
    }, {
github javascript-obfuscator / javascript-obfuscator / dist / src / node-obfuscators / MemberExpressionObfuscator.js View on Github external
value: function literalNodeController(node) {
            switch (_typeof(node.value)) {
                case 'string':
                    if (node['x-verbatim-property']) {
                        break;
                    }
                    node['x-verbatim-property'] = {
                        content: this.replaceLiteralValueByUnicodeValue(node.value),
                        precedence: escodegen.Precedence.Primary
                    };
                    break;
                default:
                    break;
            }
        }
    }]);
github javascript-obfuscator / javascript-obfuscator / dist / src / node-obfuscators / LiteralObfuscator.js View on Github external
switch (_typeof(literalNode.value)) {
                case 'boolean':
                    content = this.replaceLiteralBooleanByJSFuck(literalNode.value);
                    break;
                case 'number':
                    content = this.replaceLiteralNumberByHexadecimalValue(literalNode.value);
                    break;
                case 'string':
                    content = this.replaceLiteralValueByUnicodeValue(literalNode.value);
                    break;
                default:
                    return;
            }
            literalNode['x-verbatim-property'] = {
                content: content,
                precedence: escodegen.Precedence.Primary
            };
        }
    }]);
github redexp / react-separate-template / conv.js View on Github external
function verbatimLiteral(str) {
    return {
        type: 'Literal',
        value: 0,
        'x-verbatim-property': {
            content: str,
            precedence : gen.Precedence.Primary
        }
    }
}
github javascript-obfuscator / javascript-obfuscator / dist / src / custom-nodes / unicode-array-nodes / UnicodeArrayNode.js View on Github external
'elements': this.unicodeArray.map(function (value) {
                            return {
                                'type': NodeType_1.NodeType.Literal,
                                'value': value,
                                'raw': '\'' + value + '\'',
                                'x-verbatim-property': {
                                    'content': value,
                                    precedence: escodegen.Precedence.Primary
                                }
                            };
                        })
                    }
github power-assert-js / espower / lib / assertion-visitor.js View on Github external
leave: function (currentNode, parentNode) {
        if (currentNode.type === syntax.Literal && typeof currentNode.raw !== 'undefined') {
          currentNode['x-verbatim-espower'] = {
            content: currentNode.raw,
            precedence: escodegen.Precedence.Primary
          };
          return currentNode;
        } else {
          return undefined;
        }
      }
    };
github javascript-obfuscator / javascript-obfuscator / src / node-obfuscators / LiteralObfuscator.ts View on Github external
public obfuscateNode (literalNode: any, parentNode: any): void {
        if (parentNode.type === 'Property' && parentNode.key === literalNode) {
            return;
        }

        switch (typeof literalNode.value) {
            case 'string':
                if (literalNode['x-verbatim-property']) {
                    break;
                }

                literalNode['x-verbatim-property'] = {
                    content : this.replaceLiteralStringByArrayElement(literalNode.value),
                    precedence: escodegen.Precedence.Primary
                };

                break;
        }
    }
}