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

Version Path
disco_app-0.16.1 test/dummy/node_modules/@babel/types/lib/converters/toStatement.js
disco_app-0.15.2 test/dummy/node_modules/@babel/types/lib/converters/toStatement.js
disco_app-0.18.4 test/dummy/node_modules/@babel/types/lib/converters/toStatement.js
disco_app-0.18.1 test/dummy/node_modules/@babel/types/lib/converters/toStatement.js
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/@babel/types/lib/converters/toStatement.js
disco_app-0.14.0 test/dummy/node_modules/@babel/types/lib/converters/toStatement.js
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/@babel/types/lib/converters/toStatement.js
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/@babel/types/lib/converters/toStatement.js
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/@babel/types/lib/converters/toStatement.js
ruby2js-4.0.4 lib/tasks/testrails/node_modules/@babel/types/lib/converters/toStatement.js
ruby2js-4.0.3 lib/tasks/testrails/node_modules/@babel/types/lib/converters/toStatement.js