is.js
 1  "use strict";
 2  
 3  Object.defineProperty(exports, "__esModule", {
 4    value: true
 5  });
 6  exports.default = is;
 7  
 8  var _shallowEqual = require("../utils/shallowEqual");
 9  
10  var _isType = require("./isType");
11  
12  var _isPlaceholderType = require("./isPlaceholderType");
13  
14  var _definitions = require("../definitions");
15  
16  function is(type, node, opts) {
17    if (!node) return false;
18    const matches = (0, _isType.default)(node.type, type);
19  
20    if (!matches) {
21      if (!opts && node.type === "Placeholder" && type in _definitions.FLIPPED_ALIAS_KEYS) {
22        return (0, _isPlaceholderType.default)(node.expectedNode, type);
23      }
24  
25      return false;
26    }
27  
28    if (typeof opts === "undefined") {
29      return true;
30    } else {
31      return (0, _shallowEqual.default)(node, opts);
32    }
33  }