File size: 8,916 Bytes
443c22e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
/**
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * 
 */
'use strict';
/*::
import type {
  ESNode,
  Token,
  MostTokens,
  BlockComment,
  LineComment,
  AFunction,
  PropertyDefinition,
  PropertyDefinitionWithNonComputedName,
  MethodDefinition,
  MethodDefinitionConstructor,
  MethodDefinitionWithNonComputedName,
  MemberExpression,
  MemberExpressionWithNonComputedName,
  ObjectPropertyWithShorthandStaticName,
  ObjectPropertyWithNonShorthandStaticName,
  DestructuringObjectPropertyWithShorthandStaticName,
  DestructuringObjectPropertyWithNonShorthandStaticName,
  ClassMember,
  ClassDeclaration,
  ClassExpression,
  Literal,
  BigIntLiteral,
  BooleanLiteral,
  NullLiteral,
  NumericLiteral,
  RegExpLiteral,
  StringLiteral,
  Identifier,
  EnumDefaultedMember,
  Expression,
  Statement,
} from './types';
*/

Object.defineProperty(exports, "__esModule", {
  value: true
});
var _exportNames = {
  isClass: true,
  isPropertyDefinitionWithNonComputedName: true,
  isClassMember: true,
  isClassMemberWithNonComputedName: true,
  isComment: true,
  isFunction: true,
  isMethodDefinitionWithNonComputedName: true,
  isMemberExpressionWithNonComputedProperty: true,
  isOptionalMemberExpressionWithNonComputedProperty: true,
  isObjectPropertyWithShorthand: true,
  isObjectPropertyWithNonComputedName: true,
  isBigIntLiteral: true,
  isBooleanLiteral: true,
  isNullLiteral: true,
  isNumericLiteral: true,
  isRegExpLiteral: true,
  isStringLiteral: true,
  isExpression: true,
  isStatement: true
};
exports.isBigIntLiteral = isBigIntLiteral;
exports.isBooleanLiteral = isBooleanLiteral;
exports.isClass = isClass;
exports.isClassMember = isClassMember;
exports.isClassMemberWithNonComputedName = isClassMemberWithNonComputedName;
exports.isComment = isComment;
exports.isExpression = isExpression;
exports.isFunction = isFunction;
exports.isMemberExpressionWithNonComputedProperty = isMemberExpressionWithNonComputedProperty;
exports.isMethodDefinitionWithNonComputedName = isMethodDefinitionWithNonComputedName;
exports.isNullLiteral = isNullLiteral;
exports.isNumericLiteral = isNumericLiteral;
exports.isObjectPropertyWithNonComputedName = isObjectPropertyWithNonComputedName;
exports.isObjectPropertyWithShorthand = isObjectPropertyWithShorthand;
exports.isOptionalMemberExpressionWithNonComputedProperty = isOptionalMemberExpressionWithNonComputedProperty;
exports.isPropertyDefinitionWithNonComputedName = isPropertyDefinitionWithNonComputedName;
exports.isRegExpLiteral = isRegExpLiteral;
exports.isStatement = isStatement;
exports.isStringLiteral = isStringLiteral;

var _predicates = require("./generated/predicates");

Object.keys(_predicates).forEach(function (key) {
  if (key === "default" || key === "__esModule") return;
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
  if (key in exports && exports[key] === _predicates[key]) return;
  exports[key] = _predicates[key];
});

function isClass(node
/*: ESNode */
)
/*: implies node is (ClassDeclaration | ClassExpression) */
{
  return node.type === 'ClassDeclaration' || node.type === 'ClassExpression';
}

function isPropertyDefinitionWithNonComputedName(node
/*: ESNode */
)
/*: implies node is PropertyDefinitionWithNonComputedName */
{
  return node.type === 'PropertyDefinition' && node.computed === false;
}

function isClassMember(node
/*: ESNode */
)
/*: implies node is ClassMember */
{
  return node.type === 'PropertyDefinition' || node.type === 'MethodDefinition';
}

function isClassMemberWithNonComputedName(node
/*: ESNode */
)
/*: implies node is (PropertyDefinitionWithNonComputedName | MethodDefinitionConstructor | MethodDefinitionWithNonComputedName) */
{
  return (node.type === 'PropertyDefinition' || node.type === 'MethodDefinition') && node.computed === false;
}

function isComment(node
/*: ESNode | Token */
)
/*: implies node is (MostTokens | BlockComment | LineComment) */
{
  return node.type === 'Block' || node.type === 'Line';
}

function isFunction(node
/*: ESNode */
)
/*: implies node is AFunction */
{
  return node.type === 'ArrowFunctionExpression' || node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression';
}

function isMethodDefinitionWithNonComputedName(node
/*: ESNode */
)
/*: implies node is (MethodDefinitionConstructor | MethodDefinitionWithNonComputedName) */
{
  return node.type === 'MethodDefinition' && node.computed === false;
}

function isMemberExpressionWithNonComputedProperty(node
/*: ESNode */
)
/*: implies node is MemberExpressionWithNonComputedName */
{
  return node.type === 'MemberExpression' && node.computed === false;
}

function isOptionalMemberExpressionWithNonComputedProperty(node
/*: ESNode */
)
/*: implies node is MemberExpressionWithNonComputedName */
{
  return node.type === 'MemberExpression' && node.computed === false;
}

function isObjectPropertyWithShorthand(node
/*: ESNode */
)
/*: implies node is (ObjectPropertyWithShorthandStaticName | DestructuringObjectPropertyWithShorthandStaticName) */
{
  return node.type === 'Property' && node.shorthand === true;
}

function isObjectPropertyWithNonComputedName(node
/*: ESNode */
)
/*: implies node is (ObjectPropertyWithNonShorthandStaticName | ObjectPropertyWithShorthandStaticName | DestructuringObjectPropertyWithNonShorthandStaticName | DestructuringObjectPropertyWithShorthandStaticName) */
{
  return node.type === 'Property' && node.computed === false;
}

function isBigIntLiteral(node
/*: ESNode */
)
/*: implies node is BigIntLiteral */
{
  return node.type === 'Literal' && node.literalType === 'bigint';
}

function isBooleanLiteral(node
/*: ESNode */
)
/*: implies node is BooleanLiteral */
{
  return node.type === 'Literal' && node.literalType === 'boolean';
}

function isNullLiteral(node
/*: ESNode */
)
/*: implies node is NullLiteral */
{
  return node.type === 'Literal' && node.literalType === 'null';
}

function isNumericLiteral(node
/*: ESNode */
)
/*: implies node is NumericLiteral */
{
  return node.type === 'Literal' && node.literalType === 'numeric';
}

function isRegExpLiteral(node
/*: ESNode */
)
/*: implies node is RegExpLiteral */
{
  return node.type === 'Literal' && node.literalType === 'regexp';
}

function isStringLiteral(node
/*: ESNode */
)
/*: implies node is StringLiteral */
{
  return node.type === 'Literal' && node.literalType === 'string';
}

function isExpression(node
/*: ESNode */
)
/*: implies node is Expression */
{
  return node.type === 'ThisExpression' || node.type === 'ArrayExpression' || node.type === 'ObjectExpression' || // $FlowFixMe[incompatible-type]
  node.type === 'ObjectExpression' || node.type === 'FunctionExpression' || node.type === 'ArrowFunctionExpression' || node.type === 'YieldExpression' || node.type === 'Literal' || node.type === 'UnaryExpression' || node.type === 'UpdateExpression' || node.type === 'BinaryExpression' || node.type === 'AssignmentExpression' || node.type === 'LogicalExpression' || node.type === 'MemberExpression' || node.type === 'ConditionalExpression' || node.type === 'CallExpression' || node.type === 'NewExpression' || node.type === 'SequenceExpression' || node.type === 'TemplateLiteral' || node.type === 'TaggedTemplateExpression' || node.type === 'ClassExpression' || node.type === 'MetaProperty' || node.type === 'Identifier' || node.type === 'AwaitExpression' || node.type === 'ImportExpression' || node.type === 'ChainExpression' || node.type === 'TypeCastExpression' || node.type === 'AsExpression' || node.type === 'AsConstExpression' || node.type === 'JSXFragment' || node.type === 'JSXElement';
}

function isStatement(node
/*: ESNode */
)
/*: implies node is Statement */
{
  return node.type === 'BlockStatement' || node.type === 'BreakStatement' || node.type === 'ClassDeclaration' || node.type === 'ContinueStatement' || node.type === 'DebuggerStatement' || node.type === 'DeclareClass' || node.type === 'DeclareVariable' || node.type === 'DeclareFunction' || node.type === 'DeclareInterface' || node.type === 'DeclareModule' || node.type === 'DeclareOpaqueType' || node.type === 'DeclareTypeAlias' || node.type === 'DoWhileStatement' || node.type === 'EmptyStatement' || node.type === 'EnumDeclaration' || node.type === 'ExpressionStatement' || node.type === 'ForInStatement' || node.type === 'ForOfStatement' || node.type === 'ForStatement' || node.type === 'FunctionDeclaration' || node.type === 'IfStatement' || node.type === 'InterfaceDeclaration' || node.type === 'LabeledStatement' || node.type === 'OpaqueType' || node.type === 'ReturnStatement' || node.type === 'SwitchStatement' || node.type === 'ThrowStatement' || node.type === 'TryStatement' || node.type === 'TypeAlias' || node.type === 'VariableDeclaration' || node.type === 'WhileStatement' || node.type === 'WithStatement';
}