Sha256: 0d80ff4667f91af3f75c16b9fc4ff60fbe1dc548990ffbd8ac63f4baed1b534e

Contents?: true

Size: 1002 Bytes

Versions: 62

Compression:

Stored size: 1002 Bytes

Contents

"use strict";

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

var _generated = require("./generated");

function matchesPattern(member, match, allowPartial) {
  if (!(0, _generated.isMemberExpression)(member)) return false;
  const parts = Array.isArray(match) ? match : match.split(".");
  const nodes = [];
  let node;

  for (node = member; (0, _generated.isMemberExpression)(node); node = node.object) {
    nodes.push(node.property);
  }

  nodes.push(node);
  if (nodes.length < parts.length) return false;
  if (!allowPartial && nodes.length > parts.length) return false;

  for (let i = 0, j = nodes.length - 1; i < parts.length; i++, j--) {
    const node = nodes[j];
    let value;

    if ((0, _generated.isIdentifier)(node)) {
      value = node.name;
    } else if ((0, _generated.isStringLiteral)(node)) {
      value = node.value;
    } else {
      return false;
    }

    if (parts[i] !== value) return false;
  }

  return true;
}

Version data entries

62 entries across 61 versions & 12 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/@babel/types/lib/validators/matchesPattern.js
disco_app-0.18.0 test/dummy/node_modules/@babel/types/lib/validators/matchesPattern.js
disco_app-0.18.2 test/dummy/node_modules/@babel/types/lib/validators/matchesPattern.js
trusty-cms-5.0.7 node_modules/@babel/types/lib/validators/matchesPattern.js
trusty-cms-5.0.6 node_modules/@babel/types/lib/validators/matchesPattern.js
trusty-cms-5.0.5 node_modules/@babel/types/lib/validators/matchesPattern.js
trusty-cms-5.0.4 node_modules/@babel/types/lib/validators/matchesPattern.js
disco_app-0.16.1 test/dummy/node_modules/@babel/preset-modules/node_modules/@babel/types/lib/validators/matchesPattern.js
disco_app-0.15.2 test/dummy/node_modules/@babel/preset-modules/node_modules/@babel/types/lib/validators/matchesPattern.js
trusty-cms-5.0.3 node_modules/@babel/types/lib/validators/matchesPattern.js
trusty-cms-5.0.2 node_modules/@babel/types/lib/validators/matchesPattern.js
disco_app-0.18.4 test/dummy/node_modules/@babel/preset-modules/node_modules/@babel/types/lib/validators/matchesPattern.js
disco_app-0.18.1 test/dummy/node_modules/@babel/preset-modules/node_modules/@babel/types/lib/validators/matchesPattern.js
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/@babel/preset-modules/node_modules/@babel/types/lib/validators/matchesPattern.js
disco_app-0.14.0 test/dummy/node_modules/@babel/preset-modules/node_modules/@babel/types/lib/validators/matchesPattern.js
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/@babel/preset-modules/node_modules/@babel/types/lib/validators/matchesPattern.js
trusty-cms-5.0.1 node_modules/@babel/types/lib/validators/matchesPattern.js
trusty-cms-4.3.5 node_modules/@babel/types/lib/validators/matchesPattern.js
trusty-cms-5.0.0 node_modules/@babel/types/lib/validators/matchesPattern.js
trusty-cms-4.3.4 node_modules/@babel/types/lib/validators/matchesPattern.js