How to use the matchesPattern function from @babel/types

Find comprehensive JavaScript @babel/types.matchesPattern code examples handpicked from public code repositorys.

64
65
66
67
68
69
70
71
72
73
  return;
}

const isRegisterServiceWorker =
  types.isStringLiteral(args[0]) &&
  types.matchesPattern(callee, serviceWorkerPattern);

if (isRegisterServiceWorker) {
  // Treat service workers as an entry point so filenames remain consistent across builds.
  // https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle#avoid_changing_the_url_of_your_service_worker_script
fork icon0
star icon2
watch icon2

+ 3 other calls in file

189
190
191
192
193
194
195
196
197
198
if (t.matchesPattern(path.node, 'module.hot')) {
  path.replaceWith(t.identifier('null'));
}

if (
  t.matchesPattern(path.node, 'module.require') &&
  asset.options.target !== 'node'
) {
  path.replaceWith(t.identifier('null'));
}
fork icon0
star icon2
watch icon1

+ 7 other calls in file

24
25
26
27
28
29
30
31
32
33
34
35
36
exports.is = void 0;


var t = require("@babel/types");


function matchesPattern(pattern, allowPartial) {
  return t.matchesPattern(this.node, pattern, allowPartial);
}


function has(key) {
  const val = this.node && this.node[key];
fork icon1
star icon0
watch icon0

668
669
670
671
672
673
674
675
676
677
  if (node.computed && !this.isPure(node.key, constantsOnly)) return false;
  return this.isPure(node.value, constantsOnly);
} else if (t.isUnaryExpression(node)) {
  return this.isPure(node.argument, constantsOnly);
} else if (t.isTaggedTemplateExpression(node)) {
  return t.matchesPattern(node.tag, "String.raw") && !this.hasBinding("String", true) && this.isPure(node.quasi, constantsOnly);
} else if (t.isTemplateLiteral(node)) {
  for (const expression of node.expressions) {
    if (!this.isPure(expression, constantsOnly)) return false;
  }
fork icon0
star icon1
watch icon1

+ 16 other calls in file

Other functions in @babel/types

Sorted by popularity

function icon

@babel/types.identifier is the most popular function in @babel/types (20936 examples)