UNPKG

747 BJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = is;
7
8var _shallowEqual = require("../utils/shallowEqual");
9
10var _isType = require("./isType");
11
12var _isPlaceholderType = require("./isPlaceholderType");
13
14var _definitions = require("../definitions");
15
16function 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}
\No newline at end of file