Sha256: af4719777970692f5a17a549a585eeb93c604cdd7697da3816deb52add4cee11

Contents?: true

Size: 997 Bytes

Versions: 161

Compression:

Stored size: 997 Bytes

Contents

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _index = require("../validators/generated/index.js");
var _index2 = require("../builders/generated/index.js");
var _default = exports.default = toStatement;
function toStatement(node, ignore) {
  if ((0, _index.isStatement)(node)) {
    return node;
  }
  let mustHaveId = false;
  let newType;
  if ((0, _index.isClass)(node)) {
    mustHaveId = true;
    newType = "ClassDeclaration";
  } else if ((0, _index.isFunction)(node)) {
    mustHaveId = true;
    newType = "FunctionDeclaration";
  } else if ((0, _index.isAssignmentExpression)(node)) {
    return (0, _index2.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;
}

//# sourceMappingURL=toStatement.js.map

Version data entries

161 entries across 15 versions & 2 rubygems

Version Path
immosquare-cleaner-0.1.49 node_modules/@babel/helper-builder-binary-assignment-operator-visitor/node_modules/@babel/types/lib/converters/toStatement.js
immosquare-cleaner-0.1.49 node_modules/@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly/node_modules/@babel/traverse/node_modules/@babel/types/lib/converters/toStatement.js
immosquare-cleaner-0.1.49 node_modules/@babel/plugin-transform-async-generator-functions/node_modules/@babel/traverse/node_modules/@babel/types/lib/converters/toStatement.js
immosquare-cleaner-0.1.49 node_modules/@babel/helpers/node_modules/@babel/types/lib/converters/toStatement.js
immosquare-cleaner-0.1.49 node_modules/@babel/helper-split-export-declaration/node_modules/@babel/types/lib/converters/toStatement.js
immosquare-cleaner-0.1.49 node_modules/@babel/helper-wrap-function/node_modules/@babel/types/lib/converters/toStatement.js
immosquare-cleaner-0.1.49 node_modules/@babel/helper-environment-visitor/node_modules/@babel/types/lib/converters/toStatement.js
immosquare-cleaner-0.1.49 node_modules/@babel/plugin-transform-classes/node_modules/@babel/helper-replace-supers/node_modules/@babel/helper-member-expression-to-functions/node_modules/@babel/types/lib/converters/toStatement.js
immosquare-cleaner-0.1.49 node_modules/@babel/types/lib/converters/toStatement.js
immosquare-cleaner-0.1.49 node_modules/jscodeshift/node_modules/@babel/core/node_modules/@babel/types/lib/converters/toStatement.js
immosquare-cleaner-0.1.49 node_modules/@babel/helper-remap-async-to-generator/node_modules/@babel/traverse/node_modules/@babel/types/lib/converters/toStatement.js
immosquare-cleaner-0.1.49 node_modules/@babel/helper-simple-access/node_modules/@babel/types/lib/converters/toStatement.js
immosquare-cleaner-0.1.49 node_modules/@babel/preset-modules/node_modules/@babel/types/lib/converters/toStatement.js
immosquare-cleaner-0.1.49 node_modules/@babel/helper-optimise-call-expression/node_modules/@babel/types/lib/converters/toStatement.js
immosquare-cleaner-0.1.49 node_modules/@babel/plugin-transform-classes/node_modules/@babel/traverse/node_modules/@babel/types/lib/converters/toStatement.js
immosquare-cleaner-0.1.49 node_modules/@babel/plugin-transform-object-super/node_modules/@babel/helper-replace-supers/node_modules/@babel/traverse/node_modules/@babel/types/lib/converters/toStatement.js
immosquare-cleaner-0.1.49 node_modules/@babel/helper-function-name/node_modules/@babel/types/lib/converters/toStatement.js
immosquare-cleaner-0.1.49 node_modules/@babel/helper-module-imports/node_modules/@babel/types/lib/converters/toStatement.js
immosquare-cleaner-0.1.49 node_modules/@babel/helper-skip-transparent-expression-wrappers/node_modules/@babel/types/lib/converters/toStatement.js
immosquare-cleaner-0.1.49 node_modules/@babel/helper-annotate-as-pure/node_modules/@babel/types/lib/converters/toStatement.js