Sha256: ac32d7cd5e020a4c9dd466c466906754a5f32962a7607aba26e0a09668525861

Contents?: true

Size: 1.07 KB

Versions: 7

Compression:

Stored size: 1.07 KB

Contents

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = shouldStoreRHSInTemporaryVariable;

var _core = require("@babel/core");

function shouldStoreRHSInTemporaryVariable(node) {
  if (_core.types.isArrayPattern(node)) {
    const nonNullElements = node.elements.filter(element => element !== null);
    if (nonNullElements.length > 1) return true;else return shouldStoreRHSInTemporaryVariable(nonNullElements[0]);
  } else if (_core.types.isObjectPattern(node)) {
    if (node.properties.length > 1) return true;else if (node.properties.length === 0) return false;else return shouldStoreRHSInTemporaryVariable(node.properties[0]);
  } else if (_core.types.isObjectProperty(node)) {
    return shouldStoreRHSInTemporaryVariable(node.value);
  } else if (_core.types.isAssignmentPattern(node)) {
    return shouldStoreRHSInTemporaryVariable(node.left);
  } else if (_core.types.isRestElement(node)) {
    if (_core.types.isIdentifier(node.argument)) return true;
    return shouldStoreRHSInTemporaryVariable(node.argument);
  } else {
    return false;
  }
}

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
disco_app-0.16.1 test/dummy/node_modules/@babel/plugin-proposal-object-rest-spread/lib/shouldStoreRHSInTemporaryVariable.js
disco_app-0.15.2 test/dummy/node_modules/@babel/plugin-proposal-object-rest-spread/lib/shouldStoreRHSInTemporaryVariable.js
disco_app-0.18.4 test/dummy/node_modules/@babel/plugin-proposal-object-rest-spread/lib/shouldStoreRHSInTemporaryVariable.js
disco_app-0.18.1 test/dummy/node_modules/@babel/plugin-proposal-object-rest-spread/lib/shouldStoreRHSInTemporaryVariable.js
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/@babel/plugin-proposal-object-rest-spread/lib/shouldStoreRHSInTemporaryVariable.js
disco_app-0.14.0 test/dummy/node_modules/@babel/plugin-proposal-object-rest-spread/lib/shouldStoreRHSInTemporaryVariable.js
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/@babel/plugin-proposal-object-rest-spread/lib/shouldStoreRHSInTemporaryVariable.js