Sha256: fd46ed76e23fe3c49988bbd4e649fc750962e8e49137357e03f731cfc0cd2a74
Contents?: true
Size: 984 Bytes
Versions: 11
Compression:
Stored size: 984 Bytes
Contents
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _generated = require("../validators/generated"); var _generated2 = require("../builders/generated"); var _default = toStatement; exports.default = _default; function toStatement(node, ignore) { if ((0, _generated.isStatement)(node)) { return node; } let mustHaveId = false; let newType; if ((0, _generated.isClass)(node)) { mustHaveId = true; newType = "ClassDeclaration"; } else if ((0, _generated.isFunction)(node)) { mustHaveId = true; newType = "FunctionDeclaration"; } else if ((0, _generated.isAssignmentExpression)(node)) { return (0, _generated2.expressionStatement)(node); } if (mustHaveId && !node.id) { newType = false; } if (!newType) { if (ignore) { return false; } else { throw new Error(`cannot turn ${node.type} to a statement`); } } node.type = newType; return node; }
Version data entries
11 entries across 10 versions & 3 rubygems