1 line
1.0 KiB
JSON
1 line
1.0 KiB
JSON
{"ast":null,"code":"\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = toStatement;\n\nvar _generated = require(\"../validators/generated\");\n\nvar _generated2 = require(\"../builders/generated\");\n\nfunction toStatement(node, ignore) {\n if ((0, _generated.isStatement)(node)) {\n return node;\n }\n\n var mustHaveId = false;\n var newType;\n\n if ((0, _generated.isClass)(node)) {\n mustHaveId = true;\n newType = \"ClassDeclaration\";\n } else if ((0, _generated.isFunction)(node)) {\n mustHaveId = true;\n newType = \"FunctionDeclaration\";\n } else if ((0, _generated.isAssignmentExpression)(node)) {\n return (0, _generated2.expressionStatement)(node);\n }\n\n if (mustHaveId && !node.id) {\n newType = false;\n }\n\n if (!newType) {\n if (ignore) {\n return false;\n } else {\n throw new Error(\"cannot turn \".concat(node.type, \" to a statement\"));\n }\n }\n\n node.type = newType;\n return node;\n}","map":null,"metadata":{},"sourceType":"script"} |