Sha256: c4908e3249f4e93cdaad3e7efa92277d0fd62cdefc1bc2c3cc18ad8c0ba5d569

Contents?: true

Size: 1.45 KB

Versions: 164

Compression:

Stored size: 1.45 KB

Contents

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = isNodesEquivalent;
var _index = require("../definitions/index.js");
function isNodesEquivalent(a, b) {
  if (typeof a !== "object" || typeof b !== "object" || a == null || b == null) {
    return a === b;
  }
  if (a.type !== b.type) {
    return false;
  }
  const fields = Object.keys(_index.NODE_FIELDS[a.type] || a.type);
  const visitorKeys = _index.VISITOR_KEYS[a.type];
  for (const field of fields) {
    const val_a = a[field];
    const val_b = b[field];
    if (typeof val_a !== typeof val_b) {
      return false;
    }
    if (val_a == null && val_b == null) {
      continue;
    } else if (val_a == null || val_b == null) {
      return false;
    }
    if (Array.isArray(val_a)) {
      if (!Array.isArray(val_b)) {
        return false;
      }
      if (val_a.length !== val_b.length) {
        return false;
      }
      for (let i = 0; i < val_a.length; i++) {
        if (!isNodesEquivalent(val_a[i], val_b[i])) {
          return false;
        }
      }
      continue;
    }
    if (typeof val_a === "object" && !(visitorKeys != null && visitorKeys.includes(field))) {
      for (const key of Object.keys(val_a)) {
        if (val_a[key] !== val_b[key]) {
          return false;
        }
      }
      continue;
    }
    if (!isNodesEquivalent(val_a, val_b)) {
      return false;
    }
  }
  return true;
}

//# sourceMappingURL=isNodesEquivalent.js.map

Version data entries

164 entries across 16 versions & 3 rubygems

Version Path
immosquare-cleaner-0.1.49 node_modules/@babel/plugin-transform-react-jsx/node_modules/@babel/types/lib/validators/isNodesEquivalent.js
immosquare-cleaner-0.1.49 node_modules/@babel/preset-modules/node_modules/@babel/types/lib/validators/isNodesEquivalent.js
immosquare-cleaner-0.1.49 node_modules/@babel/types/lib/validators/isNodesEquivalent.js
immosquare-cleaner-0.1.49 node_modules/jscodeshift/node_modules/@babel/core/node_modules/@babel/types/lib/validators/isNodesEquivalent.js
immosquare-cleaner-0.1.48 node_modules/@babel/helper-annotate-as-pure/node_modules/@babel/types/lib/validators/isNodesEquivalent.js
immosquare-cleaner-0.1.48 node_modules/jscodeshift/node_modules/@babel/core/node_modules/@babel/types/lib/validators/isNodesEquivalent.js
immosquare-cleaner-0.1.48 node_modules/@babel/types/lib/validators/isNodesEquivalent.js
immosquare-cleaner-0.1.48 node_modules/@babel/preset-modules/node_modules/@babel/types/lib/validators/isNodesEquivalent.js
immosquare-cleaner-0.1.48 node_modules/@babel/plugin-transform-react-jsx/node_modules/@babel/types/lib/validators/isNodesEquivalent.js
immosquare-cleaner-0.1.48 node_modules/@babel/plugin-transform-object-super/node_modules/@babel/helper-replace-supers/node_modules/@babel/traverse/node_modules/@babel/types/lib/validators/isNodesEquivalent.js
immosquare-cleaner-0.1.48 node_modules/@babel/plugin-transform-object-super/node_modules/@babel/helper-replace-supers/node_modules/@babel/helper-member-expression-to-functions/node_modules/@babel/types/lib/validators/isNodesEquivalent.js
immosquare-cleaner-0.1.48 node_modules/@babel/plugin-transform-modules-systemjs/node_modules/@babel/traverse/node_modules/@babel/types/lib/validators/isNodesEquivalent.js
immosquare-cleaner-0.1.48 node_modules/@babel/plugin-transform-function-name/node_modules/@babel/traverse/node_modules/@babel/types/lib/validators/isNodesEquivalent.js
immosquare-cleaner-0.1.48 node_modules/@babel/plugin-transform-computed-properties/node_modules/@babel/template/node_modules/@babel/types/lib/validators/isNodesEquivalent.js
immosquare-cleaner-0.1.48 node_modules/@babel/plugin-transform-classes/node_modules/@babel/traverse/node_modules/@babel/types/lib/validators/isNodesEquivalent.js
immosquare-cleaner-0.1.48 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/validators/isNodesEquivalent.js
immosquare-cleaner-0.1.48 node_modules/@babel/plugin-transform-async-generator-functions/node_modules/@babel/traverse/node_modules/@babel/types/lib/validators/isNodesEquivalent.js
immosquare-cleaner-0.1.48 node_modules/@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly/node_modules/@babel/traverse/node_modules/@babel/types/lib/validators/isNodesEquivalent.js
immosquare-cleaner-0.1.48 node_modules/@babel/helpers/node_modules/@babel/types/lib/validators/isNodesEquivalent.js
immosquare-cleaner-0.1.48 node_modules/@babel/helper-wrap-function/node_modules/@babel/types/lib/validators/isNodesEquivalent.js