ast-types 0.7.5 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.travis.yml CHANGED
@@ -1,6 +1,14 @@
1
1
  language: node_js
2
2
  node_js:
3
+ - "0.12"
3
4
  - "0.11"
4
5
  - "0.10"
5
6
  - "0.8"
6
7
  - "0.6"
8
+
9
+ before_install:
10
+ npm install -g npm@'>=1.4.3'
11
+
12
+ matrix:
13
+ allow_failures:
14
+ - node_js: "0.6"
package/def/babel.js ADDED
@@ -0,0 +1,101 @@
1
+ require("./es7");
2
+
3
+ var types = require("../lib/types");
4
+ var defaults = require("../lib/shared").defaults;
5
+ var def = types.Type.def;
6
+ var or = types.Type.or;
7
+
8
+ def("Noop")
9
+ .bases("Node")
10
+ .build();
11
+
12
+ def("DoExpression")
13
+ .bases("Expression")
14
+ .build("body")
15
+ .field("body", [def("Statement")]);
16
+
17
+ def("Super")
18
+ .bases("Expression")
19
+ .build();
20
+
21
+ def("BindExpression")
22
+ .bases("Expression")
23
+ .build("object", "callee")
24
+ .field("object", or(def("Expression"), null))
25
+ .field("callee", def("Expression"));
26
+
27
+ def("Decorator")
28
+ .bases("Node")
29
+ .build("expression")
30
+ .field("expression", def("Expression"));
31
+
32
+ def("Property")
33
+ .field("decorators",
34
+ or([def("Decorator")], null),
35
+ defaults["null"]);
36
+
37
+ def("MethodDefinition")
38
+ .field("decorators",
39
+ or([def("Decorator")], null),
40
+ defaults["null"]);
41
+
42
+ def("MetaProperty")
43
+ .bases("Expression")
44
+ .build("meta", "property")
45
+ .field("meta", def("Identifier"))
46
+ .field("property", def("Identifier"));
47
+
48
+ def("ParenthesizedExpression")
49
+ .bases("Expression")
50
+ .build("expression")
51
+ .field("expression", def("Expression"));
52
+
53
+ def("ModuleSpecifier")
54
+ .bases("Specifier")
55
+ .field("local", def("Identifier"));
56
+
57
+ def("ImportSpecifier")
58
+ .bases("ModuleSpecifier")
59
+ .build("imported", "local")
60
+ .field("imported", def("Identifier"));
61
+
62
+ def("ImportDefaultSpecifier")
63
+ .bases("ModuleSpecifier")
64
+ .build("local");
65
+
66
+ def("ImportNamespaceSpecifier")
67
+ .bases("ModuleSpecifier")
68
+ .build("local");
69
+
70
+ def("ExportDefaultDeclaration")
71
+ .bases("Declaration")
72
+ .build("declaration")
73
+ .field("declaration", or(def("Declaration"), def("Expression")));
74
+
75
+ def("ExportNamedDeclaration")
76
+ .bases("Declaration")
77
+ .build("declaration", "specifiers", "source")
78
+ .field("declaration", or(def("Declaration"), null))
79
+ .field("specifiers", [def("ExportSpecifier")], defaults.emptyArray)
80
+ .field("source", or(def("Literal"), null), defaults["null"]);
81
+
82
+ def("ExportSpecifier")
83
+ .bases("ModuleSpecifier")
84
+ .build("local", "exported")
85
+ .field("exported", def("Identifier"));
86
+
87
+ def("ExportNamespaceSpecifier")
88
+ .bases("Specifier")
89
+ .build("exported")
90
+ .field("exported", def("Identifier"));
91
+
92
+ def("ExportDefaultSpecifier")
93
+ .bases("Specifier")
94
+ .build("exported")
95
+ .field("exported", def("Identifier"));
96
+
97
+ def("ExportAllDeclaration")
98
+ .bases("Declaration")
99
+ .build("exported", "source")
100
+ .field("exported", or(def("Identifier"), null))
101
+ .field("source", def("Literal"));
package/def/core.js CHANGED
@@ -2,11 +2,6 @@ var types = require("../lib/types");
2
2
  var Type = types.Type;
3
3
  var def = Type.def;
4
4
  var or = Type.or;
5
- var builtin = types.builtInTypes;
6
- var isString = builtin.string;
7
- var isNumber = builtin.number;
8
- var isBoolean = builtin.boolean;
9
- var isRegExp = builtin.RegExp;
10
5
  var shared = require("../lib/shared");
11
6
  var defaults = shared.defaults;
12
7
  var geq = shared.geq;
@@ -21,7 +16,7 @@ def("Printable")
21
16
 
22
17
  def("Node")
23
18
  .bases("Printable")
24
- .field("type", isString)
19
+ .field("type", String)
25
20
  .field("comments", or(
26
21
  [def("Comment")],
27
22
  null
@@ -31,13 +26,18 @@ def("SourceLocation")
31
26
  .build("start", "end", "source")
32
27
  .field("start", def("Position"))
33
28
  .field("end", def("Position"))
34
- .field("source", or(isString, null), defaults["null"]);
29
+ .field("source", or(String, null), defaults["null"]);
35
30
 
36
31
  def("Position")
37
32
  .build("line", "column")
38
33
  .field("line", geq(1))
39
34
  .field("column", geq(0));
40
35
 
36
+ def("File")
37
+ .bases("Node")
38
+ .build("program")
39
+ .field("program", def("Program"));
40
+
41
41
  def("Program")
42
42
  .bases("Node")
43
43
  .build("body")
@@ -101,7 +101,7 @@ def("SwitchStatement")
101
101
  .build("discriminant", "cases", "lexical")
102
102
  .field("discriminant", def("Expression"))
103
103
  .field("cases", [def("SwitchCase")])
104
- .field("lexical", isBoolean, defaults["false"]);
104
+ .field("lexical", Boolean, defaults["false"]);
105
105
 
106
106
  def("ReturnStatement")
107
107
  .bases("Statement")
@@ -158,13 +158,12 @@ def("ForStatement")
158
158
 
159
159
  def("ForInStatement")
160
160
  .bases("Statement")
161
- .build("left", "right", "body", "each")
161
+ .build("left", "right", "body")
162
162
  .field("left", or(
163
163
  def("VariableDeclaration"),
164
164
  def("Expression")))
165
165
  .field("right", def("Expression"))
166
- .field("body", def("Statement"))
167
- .field("each", isBoolean);
166
+ .field("body", def("Statement"));
168
167
 
169
168
  def("DebuggerStatement").bases("Statement").build();
170
169
 
@@ -183,10 +182,7 @@ def("VariableDeclaration")
183
182
  .bases("Declaration")
184
183
  .build("kind", "declarations")
185
184
  .field("kind", or("var", "let", "const"))
186
- .field("declarations", [or(
187
- def("VariableDeclarator"),
188
- def("Identifier") // TODO Esprima deviation.
189
- )]);
185
+ .field("declarations", [def("VariableDeclarator")]);
190
186
 
191
187
  def("VariableDeclarator")
192
188
  .bases("Node")
@@ -215,8 +211,7 @@ def("Property")
215
211
  .build("kind", "key", "value")
216
212
  .field("kind", or("init", "get", "set"))
217
213
  .field("key", or(def("Literal"), def("Identifier")))
218
- // esprima allows Pattern
219
- .field("value", or(def("Expression"), def("Pattern")));
214
+ .field("value", def("Expression"));
220
215
 
221
216
  def("SequenceExpression")
222
217
  .bases("Expression")
@@ -232,9 +227,9 @@ def("UnaryExpression")
232
227
  .build("operator", "argument", "prefix")
233
228
  .field("operator", UnaryOperator)
234
229
  .field("argument", def("Expression"))
235
- // TODO Esprima doesn't bother with this field, presumably because
236
- // it's always true for unary operators.
237
- .field("prefix", isBoolean, defaults["true"]);
230
+ // Esprima doesn't bother with this field, presumably because it's
231
+ // always true for unary operators.
232
+ .field("prefix", Boolean, defaults["true"]);
238
233
 
239
234
  var BinaryOperator = or(
240
235
  "==", "!=", "===", "!==",
@@ -271,7 +266,7 @@ def("UpdateExpression")
271
266
  .build("operator", "argument", "prefix")
272
267
  .field("operator", UpdateOperator)
273
268
  .field("argument", def("Expression"))
274
- .field("prefix", isBoolean);
269
+ .field("prefix", Boolean);
275
270
 
276
271
  var LogicalOperator = or("||", "&&");
277
272
 
@@ -310,28 +305,10 @@ def("MemberExpression")
310
305
  .build("object", "property", "computed")
311
306
  .field("object", def("Expression"))
312
307
  .field("property", or(def("Identifier"), def("Expression")))
313
- .field("computed", isBoolean, defaults["false"]);
308
+ .field("computed", Boolean, defaults["false"]);
314
309
 
315
310
  def("Pattern").bases("Node");
316
311
 
317
- def("ObjectPattern")
318
- .bases("Pattern")
319
- .build("properties")
320
- // TODO File a bug to get PropertyPattern added to the interfaces API.
321
- // esprima uses Property
322
- .field("properties", [or(def("PropertyPattern"), def("Property"))]);
323
-
324
- def("PropertyPattern")
325
- .bases("Pattern")
326
- .build("key", "pattern")
327
- .field("key", or(def("Literal"), def("Identifier")))
328
- .field("pattern", def("Pattern"));
329
-
330
- def("ArrayPattern")
331
- .bases("Pattern")
332
- .build("elements")
333
- .field("elements", [or(def("Pattern"), null)]);
334
-
335
312
  def("SwitchCase")
336
313
  .bases("Node")
337
314
  .build("test", "consequent")
@@ -342,48 +319,44 @@ def("Identifier")
342
319
  // But aren't Expressions and Patterns already Nodes? TODO Report this.
343
320
  .bases("Node", "Expression", "Pattern")
344
321
  .build("name")
345
- .field("name", isString);
322
+ .field("name", String);
346
323
 
347
324
  def("Literal")
348
325
  // But aren't Expressions already Nodes? TODO Report this.
349
326
  .bases("Node", "Expression")
350
327
  .build("value")
351
- .field("value", or(
352
- isString,
353
- isBoolean,
354
- null, // isNull would also work here.
355
- isNumber,
356
- isRegExp
357
- ))
328
+ .field("value", or(String, Boolean, null, Number, RegExp))
358
329
  .field("regex", or({
359
- pattern: isString,
360
- flags: isString
330
+ pattern: String,
331
+ flags: String
361
332
  }, null), function() {
362
- if (!isRegExp.check(this.value))
363
- return null;
364
-
365
- var flags = "";
366
- if (this.value.ignoreCase) flags += "i";
367
- if (this.value.multiline) flags += "m";
368
- if (this.value.global) flags += "g";
369
-
370
- return {
371
- pattern: this.value.source,
372
- flags: flags
373
- };
333
+ if (this.value instanceof RegExp) {
334
+ var flags = "";
335
+
336
+ if (this.value.ignoreCase) flags += "i";
337
+ if (this.value.multiline) flags += "m";
338
+ if (this.value.global) flags += "g";
339
+
340
+ return {
341
+ pattern: this.value.source,
342
+ flags: flags
343
+ };
344
+ }
345
+
346
+ return null;
374
347
  });
375
348
 
376
349
  // Abstract (non-buildable) comment supertype. Not a Node.
377
350
  def("Comment")
378
351
  .bases("Printable")
379
- .field("value", isString)
352
+ .field("value", String)
380
353
  // A .leading comment comes before the node, whereas a .trailing
381
354
  // comment comes after it. These two fields should not both be true,
382
355
  // but they might both be false when the comment falls inside a node
383
356
  // and the node has no children for the comment to lead or trail,
384
357
  // e.g. { /*dangling*/ }.
385
- .field("leading", isBoolean, defaults["true"])
386
- .field("trailing", isBoolean, defaults["false"]);
358
+ .field("leading", Boolean, defaults["true"])
359
+ .field("trailing", Boolean, defaults["false"]);
387
360
 
388
361
  // Block comment. The .type really should be BlockComment rather than
389
362
  // Block, but that's what we're stuck with for now.
package/def/e4x.js CHANGED
@@ -2,9 +2,6 @@ require("./core");
2
2
  var types = require("../lib/types");
3
3
  var def = types.Type.def;
4
4
  var or = types.Type.or;
5
- var builtin = types.builtInTypes;
6
- var isString = builtin.string;
7
- var isBoolean = builtin.boolean;
8
5
 
9
6
  // Note that none of these types are buildable because the Mozilla Parser
10
7
  // API doesn't specify any builder functions, and nobody uses E4X anymore.
@@ -19,12 +16,12 @@ def("XMLQualifiedIdentifier")
19
16
  .bases("Expression")
20
17
  .field("left", or(def("Identifier"), def("XMLAnyName")))
21
18
  .field("right", or(def("Identifier"), def("Expression")))
22
- .field("computed", isBoolean);
19
+ .field("computed", Boolean);
23
20
 
24
21
  def("XMLFunctionQualifiedIdentifier")
25
22
  .bases("Expression")
26
23
  .field("right", or(def("Identifier"), def("Expression")))
27
- .field("computed", isBoolean);
24
+ .field("computed", Boolean);
28
25
 
29
26
  def("XMLAttributeSelector")
30
27
  .bases("Expression")
@@ -51,7 +48,7 @@ def("XMLEscape")
51
48
 
52
49
  def("XMLText")
53
50
  .bases("XML")
54
- .field("text", isString);
51
+ .field("text", String);
55
52
 
56
53
  def("XMLStartTag")
57
54
  .bases("XML")
@@ -67,21 +64,21 @@ def("XMLPointTag")
67
64
 
68
65
  def("XMLName")
69
66
  .bases("XML")
70
- .field("contents", or(isString, [def("XML")]));
67
+ .field("contents", or(String, [def("XML")]));
71
68
 
72
69
  def("XMLAttribute")
73
70
  .bases("XML")
74
- .field("value", isString);
71
+ .field("value", String);
75
72
 
76
73
  def("XMLCdata")
77
74
  .bases("XML")
78
- .field("contents", isString);
75
+ .field("contents", String);
79
76
 
80
77
  def("XMLComment")
81
78
  .bases("XML")
82
- .field("contents", isString);
79
+ .field("contents", String);
83
80
 
84
81
  def("XMLProcessingInstruction")
85
82
  .bases("XML")
86
- .field("target", isString)
87
- .field("contents", or(isString, null));
83
+ .field("target", String)
84
+ .field("contents", or(String, null));
package/def/es6.js CHANGED
@@ -2,27 +2,34 @@ require("./core");
2
2
  var types = require("../lib/types");
3
3
  var def = types.Type.def;
4
4
  var or = types.Type.or;
5
- var builtin = types.builtInTypes;
6
- var isBoolean = builtin.boolean;
7
- var isObject = builtin.object;
8
- var isString = builtin.string;
9
5
  var defaults = require("../lib/shared").defaults;
10
6
 
11
7
  def("Function")
12
- .field("generator", isBoolean, defaults["false"])
13
- .field("expression", isBoolean, defaults["false"])
8
+ .field("generator", Boolean, defaults["false"])
9
+ .field("expression", Boolean, defaults["false"])
14
10
  .field("defaults", [or(def("Expression"), null)], defaults.emptyArray)
15
- // TODO This could be represented as a SpreadElementPattern in .params.
11
+ // TODO This could be represented as a RestElement in .params.
16
12
  .field("rest", or(def("Identifier"), null), defaults["null"]);
17
13
 
14
+ // The ESTree way of representing a ...rest parameter.
15
+ def("RestElement")
16
+ .bases("Pattern")
17
+ .build("argument")
18
+ .field("argument", def("Pattern"));
19
+
20
+ def("SpreadElementPattern")
21
+ .bases("Pattern")
22
+ .build("argument")
23
+ .field("argument", def("Pattern"));
24
+
18
25
  def("FunctionDeclaration")
19
26
  .build("id", "params", "body", "generator", "expression");
20
27
 
21
28
  def("FunctionExpression")
22
29
  .build("id", "params", "body", "generator", "expression");
23
30
 
24
- // TODO The Parser API calls this ArrowExpression, but Esprima uses
25
- // ArrowFunctionExpression.
31
+ // The Parser API calls this ArrowExpression, but Esprima and all other
32
+ // actual parsers use ArrowFunctionExpression.
26
33
  def("ArrowFunctionExpression")
27
34
  .bases("Function", "Expression")
28
35
  .build("params", "body", "expression")
@@ -39,7 +46,7 @@ def("YieldExpression")
39
46
  .bases("Expression")
40
47
  .build("argument", "delegate")
41
48
  .field("argument", or(def("Expression"), null))
42
- .field("delegate", isBoolean, defaults["false"]);
49
+ .field("delegate", Boolean, defaults["false"]);
43
50
 
44
51
  def("GeneratorExpression")
45
52
  .bases("Expression")
@@ -60,27 +67,40 @@ def("ComprehensionBlock")
60
67
  .build("left", "right", "each")
61
68
  .field("left", def("Pattern"))
62
69
  .field("right", def("Expression"))
63
- .field("each", isBoolean);
70
+ .field("each", Boolean);
64
71
 
65
72
  def("Property")
66
- // Esprima extensions not mentioned in the Mozilla Parser API:
67
73
  .field("key", or(def("Literal"), def("Identifier"), def("Expression")))
68
- .field("method", isBoolean, defaults["false"])
69
- .field("shorthand", isBoolean, defaults["false"])
70
- .field("computed", isBoolean, defaults["false"]);
74
+ .field("value", or(def("Expression"), def("Pattern")))
75
+ .field("method", Boolean, defaults["false"])
76
+ .field("shorthand", Boolean, defaults["false"])
77
+ .field("computed", Boolean, defaults["false"]);
71
78
 
72
79
  def("PropertyPattern")
80
+ .bases("Pattern")
81
+ .build("key", "pattern")
73
82
  .field("key", or(def("Literal"), def("Identifier"), def("Expression")))
74
- .field("computed", isBoolean, defaults["false"]);
83
+ .field("pattern", def("Pattern"))
84
+ .field("computed", Boolean, defaults["false"]);
85
+
86
+ def("ObjectPattern")
87
+ .bases("Pattern")
88
+ .build("properties")
89
+ .field("properties", [or(def("PropertyPattern"), def("Property"))]);
90
+
91
+ def("ArrayPattern")
92
+ .bases("Pattern")
93
+ .build("elements")
94
+ .field("elements", [or(def("Pattern"), null)]);
75
95
 
76
96
  def("MethodDefinition")
77
97
  .bases("Declaration")
78
98
  .build("kind", "key", "value", "static")
79
- .field("kind", or("init", "get", "set", ""))
99
+ .field("kind", or("constructor", "method", "get", "set"))
80
100
  .field("key", or(def("Literal"), def("Identifier"), def("Expression")))
81
101
  .field("value", def("Function"))
82
- .field("computed", isBoolean, defaults["false"])
83
- .field("static", isBoolean, defaults["false"]);
102
+ .field("computed", Boolean, defaults["false"])
103
+ .field("static", Boolean, defaults["false"]);
84
104
 
85
105
  def("SpreadElement")
86
106
  .bases("Node")
@@ -96,18 +116,17 @@ def("NewExpression")
96
116
  def("CallExpression")
97
117
  .field("arguments", [or(def("Expression"), def("SpreadElement"))]);
98
118
 
99
- def("SpreadElementPattern")
119
+ // Note: this node type is *not* an AssignmentExpression with a Pattern on
120
+ // the left-hand side! The existing AssignmentExpression type already
121
+ // supports destructuring assignments. AssignmentPattern nodes may appear
122
+ // wherever a Pattern is allowed, and the right-hand side represents a
123
+ // default value to be destructured against the left-hand side, if no
124
+ // value is otherwise provided. For example: default parameter values.
125
+ def("AssignmentPattern")
100
126
  .bases("Pattern")
101
- .build("argument")
102
- .field("argument", def("Pattern"));
103
-
104
- def("ArrayPattern")
105
- .field("elements", [or(
106
- def("Pattern"),
107
- null,
108
- // used by esprima
109
- def("SpreadElement")
110
- )]);
127
+ .build("left", "right")
128
+ .field("left", def("Pattern"))
129
+ .field("right", def("Expression"));
111
130
 
112
131
  var ClassBodyElement = or(
113
132
  def("MethodDefinition"),
@@ -120,7 +139,7 @@ def("ClassProperty")
120
139
  .bases("Declaration")
121
140
  .build("key")
122
141
  .field("key", or(def("Literal"), def("Identifier"), def("Expression")))
123
- .field("computed", isBoolean, defaults["false"]);
142
+ .field("computed", Boolean, defaults["false"]);
124
143
 
125
144
  def("ClassPropertyDefinition") // static property
126
145
  .bases("Declaration")
@@ -157,68 +176,10 @@ def("ClassImplements")
157
176
  // Specifier and NamedSpecifier are abstract non-standard types that I
158
177
  // introduced for definitional convenience.
159
178
  def("Specifier").bases("Node");
160
- def("NamedSpecifier")
161
- .bases("Specifier")
162
- // Note: this abstract type is intentionally not buildable.
163
- .field("id", def("Identifier"))
164
- .field("name", or(def("Identifier"), null), defaults["null"]);
165
-
166
- // Like NamedSpecifier, except type:"ExportSpecifier" and buildable.
167
- // export {<id [as name]>} [from ...];
168
- def("ExportSpecifier")
169
- .bases("NamedSpecifier")
170
- .build("id", "name");
171
-
172
- // export <*> from ...;
173
- def("ExportBatchSpecifier")
174
- .bases("Specifier")
175
- .build();
176
-
177
- // Like NamedSpecifier, except type:"ImportSpecifier" and buildable.
178
- // import {<id [as name]>} from ...;
179
- def("ImportSpecifier")
180
- .bases("NamedSpecifier")
181
- .build("id", "name");
182
-
183
- // import <* as id> from ...;
184
- def("ImportNamespaceSpecifier")
185
- .bases("Specifier")
186
- .build("id")
187
- .field("id", def("Identifier"));
188
-
189
- // import <id> from ...;
190
- def("ImportDefaultSpecifier")
191
- .bases("Specifier")
192
- .build("id")
193
- .field("id", def("Identifier"));
194
-
195
- def("ExportDeclaration")
196
- .bases("Declaration")
197
- .build("default", "declaration", "specifiers", "source")
198
- .field("default", isBoolean)
199
- .field("declaration", or(
200
- def("Declaration"),
201
- def("Expression"), // Implies default.
202
- null
203
- ))
204
- .field("specifiers", [or(
205
- def("ExportSpecifier"),
206
- def("ExportBatchSpecifier")
207
- )], defaults.emptyArray)
208
- .field("source", or(def("Literal"), null), defaults["null"]);
209
-
210
- def("ImportDeclaration")
211
- .bases("Declaration")
212
- .build("specifiers", "source")
213
- .field("specifiers", [or(
214
- def("ImportSpecifier"),
215
- def("ImportNamespaceSpecifier"),
216
- def("ImportDefaultSpecifier")
217
- )], defaults.emptyArray)
218
- .field("source", def("Literal"));
219
179
 
220
180
  def("TaggedTemplateExpression")
221
181
  .bases("Expression")
182
+ .build("tag", "quasi")
222
183
  .field("tag", def("Expression"))
223
184
  .field("quasi", def("TemplateLiteral"));
224
185
 
@@ -231,5 +192,5 @@ def("TemplateLiteral")
231
192
  def("TemplateElement")
232
193
  .bases("Node")
233
194
  .build("value", "tail")
234
- .field("value", {"cooked": isString, "raw": isString})
235
- .field("tail", isBoolean);
195
+ .field("value", {"cooked": String, "raw": String})
196
+ .field("tail", Boolean);
package/def/es7.js CHANGED
@@ -1,13 +1,13 @@
1
- require("./core");
1
+ require("./es6");
2
+
2
3
  var types = require("../lib/types");
3
4
  var def = types.Type.def;
4
5
  var or = types.Type.or;
5
6
  var builtin = types.builtInTypes;
6
- var isBoolean = builtin.boolean;
7
7
  var defaults = require("../lib/shared").defaults;
8
8
 
9
9
  def("Function")
10
- .field("async", isBoolean, defaults["false"]);
10
+ .field("async", Boolean, defaults["false"]);
11
11
 
12
12
  def("SpreadProperty")
13
13
  .bases("Node")
@@ -24,15 +24,13 @@ def("SpreadPropertyPattern")
24
24
 
25
25
  def("ObjectPattern")
26
26
  .field("properties", [or(
27
- def("PropertyPattern"),
28
- def("SpreadPropertyPattern"),
29
- // used by esprima
30
27
  def("Property"),
31
- def("SpreadProperty")
28
+ def("PropertyPattern"),
29
+ def("SpreadPropertyPattern")
32
30
  )]);
33
31
 
34
32
  def("AwaitExpression")
35
33
  .bases("Expression")
36
34
  .build("argument", "all")
37
35
  .field("argument", or(def("Expression"), null))
38
- .field("all", isBoolean, defaults["false"]);
36
+ .field("all", Boolean, defaults["false"]);
package/def/esprima.js ADDED
@@ -0,0 +1,96 @@
1
+ require("./es7");
2
+
3
+ var types = require("../lib/types");
4
+ var defaults = require("../lib/shared").defaults;
5
+ var def = types.Type.def;
6
+ var or = types.Type.or;
7
+
8
+ def("VariableDeclaration")
9
+ .field("declarations", [or(
10
+ def("VariableDeclarator"),
11
+ def("Identifier") // Esprima deviation.
12
+ )]);
13
+
14
+ def("Property")
15
+ .field("value", or(
16
+ def("Expression"),
17
+ def("Pattern") // Esprima deviation.
18
+ ));
19
+
20
+ def("ArrayPattern")
21
+ .field("elements", [or(
22
+ def("Pattern"),
23
+ def("SpreadElement"),
24
+ null
25
+ )]);
26
+
27
+ def("ObjectPattern")
28
+ .field("properties", [or(
29
+ def("Property"),
30
+ def("PropertyPattern"),
31
+ def("SpreadPropertyPattern"),
32
+ def("SpreadProperty") // Used by Esprima.
33
+ )]);
34
+
35
+ def("NamedSpecifier")
36
+ .bases("Specifier")
37
+ // Note: this abstract type is intentionally not buildable.
38
+ .field("id", def("Identifier"))
39
+ .field("name", or(def("Identifier"), null), defaults["null"]);
40
+
41
+ // Like NamedSpecifier, except type:"ExportSpecifier" and buildable.
42
+ // export {<id [as name]>} [from ...];
43
+ def("ExportSpecifier")
44
+ .bases("NamedSpecifier")
45
+ .build("id", "name");
46
+
47
+ // export <*> from ...;
48
+ def("ExportBatchSpecifier")
49
+ .bases("Specifier")
50
+ .build();
51
+
52
+ // Like NamedSpecifier, except type:"ImportSpecifier" and buildable.
53
+ // import {<id [as name]>} from ...;
54
+ def("ImportSpecifier")
55
+ .bases("NamedSpecifier")
56
+ .build("id", "name");
57
+
58
+ // import <* as id> from ...;
59
+ def("ImportNamespaceSpecifier")
60
+ .bases("Specifier")
61
+ .build("id")
62
+ .field("id", def("Identifier"));
63
+
64
+ // import <id> from ...;
65
+ def("ImportDefaultSpecifier")
66
+ .bases("Specifier")
67
+ .build("id")
68
+ .field("id", def("Identifier"));
69
+
70
+ def("ExportDeclaration")
71
+ .bases("Declaration")
72
+ .build("default", "declaration", "specifiers", "source")
73
+ .field("default", Boolean)
74
+ .field("declaration", or(
75
+ def("Declaration"),
76
+ def("Expression"), // Implies default.
77
+ null
78
+ ))
79
+ .field("specifiers", [or(
80
+ def("ExportSpecifier"),
81
+ def("ExportBatchSpecifier")
82
+ )], defaults.emptyArray)
83
+ .field("source", or(
84
+ def("Literal"),
85
+ null
86
+ ), defaults["null"]);
87
+
88
+ def("ImportDeclaration")
89
+ .bases("Declaration")
90
+ .build("specifiers", "source")
91
+ .field("specifiers", [or(
92
+ def("ImportSpecifier"),
93
+ def("ImportNamespaceSpecifier"),
94
+ def("ImportDefaultSpecifier")
95
+ )], defaults.emptyArray)
96
+ .field("source", def("Literal"));
package/def/fb-harmony.js CHANGED
@@ -1,10 +1,8 @@
1
- require("./core");
1
+ require("./es7");
2
+
2
3
  var types = require("../lib/types");
3
4
  var def = types.Type.def;
4
5
  var or = types.Type.or;
5
- var builtin = types.builtInTypes;
6
- var isString = builtin.string;
7
- var isBoolean = builtin.boolean;
8
6
  var defaults = require("../lib/shared").defaults;
9
7
 
10
8
  def("JSXAttribute")
@@ -20,7 +18,7 @@ def("JSXAttribute")
20
18
  def("JSXIdentifier")
21
19
  .bases("Identifier")
22
20
  .build("name")
23
- .field("name", isString);
21
+ .field("name", String);
24
22
 
25
23
  def("JSXNamespacedName")
26
24
  .bases("Node")
@@ -33,7 +31,7 @@ def("JSXMemberExpression")
33
31
  .build("object", "property")
34
32
  .field("object", or(def("JSXIdentifier"), def("JSXMemberExpression")))
35
33
  .field("property", def("JSXIdentifier"))
36
- .field("computed", isBoolean, defaults.false);
34
+ .field("computed", Boolean, defaults.false);
37
35
 
38
36
  var JSXElementName = or(
39
37
  def("JSXIdentifier"),
@@ -75,7 +73,7 @@ def("JSXElement")
75
73
  // guaranteed to be available.
76
74
  return this.openingElement.name;
77
75
  })
78
- .field("selfClosing", isBoolean, function() {
76
+ .field("selfClosing", Boolean, function() {
79
77
  return this.openingElement.selfClosing;
80
78
  })
81
79
  .field("attributes", JSXAttributes, function() {
@@ -87,7 +85,7 @@ def("JSXOpeningElement")
87
85
  .build("name", "attributes", "selfClosing")
88
86
  .field("name", JSXElementName)
89
87
  .field("attributes", JSXAttributes, defaults.emptyArray)
90
- .field("selfClosing", isBoolean, defaults["false"]);
88
+ .field("selfClosing", Boolean, defaults["false"]);
91
89
 
92
90
  def("JSXClosingElement")
93
91
  .bases("Node") // TODO Same concern.
@@ -97,34 +95,54 @@ def("JSXClosingElement")
97
95
  def("JSXText")
98
96
  .bases("Literal")
99
97
  .build("value")
100
- .field("value", isString);
98
+ .field("value", String);
101
99
 
102
100
  def("JSXEmptyExpression").bases("Expression").build();
103
101
 
104
102
  // Type Annotations
105
- def("Type")
106
- .bases("Node");
103
+ def("Type").bases("Node");
107
104
 
108
105
  def("AnyTypeAnnotation")
109
- .bases("Type");
106
+ .bases("Type")
107
+ .build();
108
+
109
+ def("MixedTypeAnnotation")
110
+ .bases("Type")
111
+ .build();
110
112
 
111
113
  def("VoidTypeAnnotation")
112
- .bases("Type");
114
+ .bases("Type")
115
+ .build();
113
116
 
114
117
  def("NumberTypeAnnotation")
115
- .bases("Type");
118
+ .bases("Type")
119
+ .build();
120
+
121
+ def("NumberLiteralTypeAnnotation")
122
+ .bases("Type")
123
+ .build("value", "raw")
124
+ .field("value", Number)
125
+ .field("raw", String);
116
126
 
117
127
  def("StringTypeAnnotation")
118
- .bases("Type");
128
+ .bases("Type")
129
+ .build();
119
130
 
120
131
  def("StringLiteralTypeAnnotation")
121
132
  .bases("Type")
122
133
  .build("value", "raw")
123
- .field("value", isString)
124
- .field("raw", isString);
134
+ .field("value", String)
135
+ .field("raw", String);
125
136
 
126
137
  def("BooleanTypeAnnotation")
127
- .bases("Type");
138
+ .bases("Type")
139
+ .build();
140
+
141
+ def("BooleanLiteralTypeAnnotation")
142
+ .bases("Type")
143
+ .build("value", "raw")
144
+ .field("value", Boolean)
145
+ .field("raw", String);
128
146
 
129
147
  def("TypeAnnotation")
130
148
  .bases("Node")
@@ -149,7 +167,7 @@ def("FunctionTypeParam")
149
167
  .build("name", "typeAnnotation", "optional")
150
168
  .field("name", def("Identifier"))
151
169
  .field("typeAnnotation", def("Type"))
152
- .field("optional", isBoolean);
170
+ .field("optional", Boolean);
153
171
 
154
172
  def("ArrayTypeAnnotation")
155
173
  .bases("Type")
@@ -161,14 +179,16 @@ def("ObjectTypeAnnotation")
161
179
  .build("properties")
162
180
  .field("properties", [def("ObjectTypeProperty")])
163
181
  .field("indexers", [def("ObjectTypeIndexer")], defaults.emptyArray)
164
- .field("callProperties", [def("ObjectTypeCallProperty")], defaults.emptyArray);
182
+ .field("callProperties",
183
+ [def("ObjectTypeCallProperty")],
184
+ defaults.emptyArray);
165
185
 
166
186
  def("ObjectTypeProperty")
167
187
  .bases("Node")
168
188
  .build("key", "value", "optional")
169
189
  .field("key", or(def("Literal"), def("Identifier")))
170
190
  .field("value", def("Type"))
171
- .field("optional", isBoolean);
191
+ .field("optional", Boolean);
172
192
 
173
193
  def("ObjectTypeIndexer")
174
194
  .bases("Node")
@@ -181,12 +201,14 @@ def("ObjectTypeCallProperty")
181
201
  .bases("Node")
182
202
  .build("value")
183
203
  .field("value", def("FunctionTypeAnnotation"))
184
- .field("static", isBoolean, false);
204
+ .field("static", Boolean, false);
185
205
 
186
206
  def("QualifiedTypeIdentifier")
187
207
  .bases("Node")
188
208
  .build("qualification", "id")
189
- .field("qualification", or(def("Identifier"), def("QualifiedTypeIdentifier")))
209
+ .field("qualification",
210
+ or(def("Identifier"),
211
+ def("QualifiedTypeIdentifier")))
190
212
  .field("id", def("Identifier"));
191
213
 
192
214
  def("GenericTypeAnnotation")
@@ -199,7 +221,9 @@ def("MemberTypeAnnotation")
199
221
  .bases("Type")
200
222
  .build("object", "property")
201
223
  .field("object", def("Identifier"))
202
- .field("property", or(def("MemberTypeAnnotation"), def("GenericTypeAnnotation")));
224
+ .field("property",
225
+ or(def("MemberTypeAnnotation"),
226
+ def("GenericTypeAnnotation")));
203
227
 
204
228
  def("UnionTypeAnnotation")
205
229
  .bases("Type")
@@ -230,22 +254,30 @@ def("TypeParameterInstantiation")
230
254
  .field("params", [def("Type")]);
231
255
 
232
256
  def("Function")
233
- .field("returnType", or(def("TypeAnnotation"), null), defaults["null"])
234
- .field("typeParameters", or(def("TypeParameterDeclaration"), null), defaults["null"]);
257
+ .field("returnType",
258
+ or(def("TypeAnnotation"), null),
259
+ defaults["null"])
260
+ .field("typeParameters",
261
+ or(def("TypeParameterDeclaration"), null),
262
+ defaults["null"]);
235
263
 
236
264
  def("ClassProperty")
237
265
  .build("key", "typeAnnotation")
238
266
  .field("typeAnnotation", def("TypeAnnotation"))
239
- .field("static", isBoolean, false);
267
+ .field("static", Boolean, false);
240
268
 
241
269
  def("ClassImplements")
242
- .field("typeParameters", or(def("TypeParameterInstantiation"), null), defaults["null"]);
270
+ .field("typeParameters",
271
+ or(def("TypeParameterInstantiation"), null),
272
+ defaults["null"]);
243
273
 
244
274
  def("InterfaceDeclaration")
245
275
  .bases("Statement")
246
276
  .build("id", "body", "extends")
247
277
  .field("id", def("Identifier"))
248
- .field("typeParameters", or(def("TypeParameterDeclaration"), null), defaults["null"])
278
+ .field("typeParameters",
279
+ or(def("TypeParameterDeclaration"), null),
280
+ defaults["null"])
249
281
  .field("body", def("ObjectTypeAnnotation"))
250
282
  .field("extends", [def("InterfaceExtends")]);
251
283
 
package/def/mozilla.js CHANGED
@@ -2,12 +2,18 @@ require("./core");
2
2
  var types = require("../lib/types");
3
3
  var def = types.Type.def;
4
4
  var or = types.Type.or;
5
- var geq = require("../lib/shared").geq;
5
+ var shared = require("../lib/shared");
6
+ var geq = shared.geq;
7
+ var defaults = shared.defaults;
6
8
 
7
9
  def("Function")
8
10
  // SpiderMonkey allows expression closures: function(x) x+1
9
11
  .field("body", or(def("BlockStatement"), def("Expression")));
10
12
 
13
+ def("ForInStatement")
14
+ .build("left", "right", "body", "each")
15
+ .field("each", Boolean, defaults["false"]);
16
+
11
17
  def("ForOfStatement")
12
18
  .bases("Statement")
13
19
  .build("left", "right", "body")
package/lib/types.js CHANGED
@@ -80,27 +80,33 @@ Tp.toString = function() {
80
80
  return name + " type";
81
81
  };
82
82
 
83
+ var builtInCtorFns = [];
84
+ var builtInCtorTypes = [];
83
85
  var builtInTypes = {};
84
86
  exports.builtInTypes = builtInTypes;
85
87
 
86
88
  function defBuiltInType(example, name) {
87
89
  var objStr = objToStr.call(example);
88
90
 
89
- Object.defineProperty(builtInTypes, name, {
90
- enumerable: true,
91
- value: new Type(function(value) {
92
- return objToStr.call(value) === objStr;
93
- }, name)
94
- });
91
+ var type = new Type(function(value) {
92
+ return objToStr.call(value) === objStr;
93
+ }, name);
95
94
 
96
- return builtInTypes[name];
95
+ builtInTypes[name] = type;
96
+
97
+ if (example && typeof example.constructor === "function") {
98
+ builtInCtorFns.push(example.constructor);
99
+ builtInCtorTypes.push(type);
100
+ }
101
+
102
+ return type;
97
103
  }
98
104
 
99
105
  // These types check the underlying [[Class]] attribute of the given
100
106
  // value, rather than using the problematic typeof operator. Note however
101
107
  // that no subtyping is considered; so, for instance, isObject.check
102
108
  // returns false for [], /./, new Date, and null.
103
- var isString = defBuiltInType("", "string");
109
+ var isString = defBuiltInType("truthy", "string");
104
110
  var isFunction = defBuiltInType(function(){}, "function");
105
111
  var isArray = defBuiltInType([], "array");
106
112
  var isObject = defBuiltInType({}, "object");
@@ -132,10 +138,17 @@ function toType(from, name) {
132
138
  if (isObject.check(from))
133
139
  return Type.fromObject(from);
134
140
 
135
- // If isFunction.check(from), assume that from is a binary predicate
136
- // function we can use to define the type.
137
- if (isFunction.check(from))
141
+ if (isFunction.check(from)) {
142
+ var bicfIndex = builtInCtorFns.indexOf(from);
143
+ if (bicfIndex >= 0) {
144
+ return builtInCtorTypes[bicfIndex];
145
+ }
146
+
147
+ // If isFunction.check(from), and from is not a built-in
148
+ // constructor, assume from is a binary predicate function we can
149
+ // use to define the type.
138
150
  return new Type(from, name);
151
+ }
139
152
 
140
153
  // As a last resort, toType returns a type that matches any value that
141
154
  // is === from. This is primarily useful for literal values like
@@ -324,7 +337,7 @@ exports.computeSupertypeLookupTable = function(candidates) {
324
337
  for (var i = 0; i < typeNameCount; ++i) {
325
338
  var typeName = typeNames[i];
326
339
  var d = defCache[typeName];
327
- assert.strictEqual(d.finalized, true);
340
+ assert.strictEqual(d.finalized, true, typeName);
328
341
  for (var j = 0; j < d.supertypeList.length; ++j) {
329
342
  var superTypeName = d.supertypeList[j];
330
343
  if (hasOwn.call(candidates, superTypeName)) {
@@ -339,7 +352,7 @@ exports.computeSupertypeLookupTable = function(candidates) {
339
352
 
340
353
  Dp.checkAllFields = function(value, deep) {
341
354
  var allFields = this.allFields;
342
- assert.strictEqual(this.finalized, true);
355
+ assert.strictEqual(this.finalized, true, this.typeName);
343
356
 
344
357
  function checkFieldByName(name) {
345
358
  var field = allFields[name];
@@ -403,11 +416,15 @@ Dp.check = function(value, deep) {
403
416
  };
404
417
 
405
418
  Dp.bases = function() {
419
+ var args = slice.call(arguments);
406
420
  var bases = this.baseNames;
407
421
 
408
- assert.strictEqual(this.finalized, false);
422
+ if (this.finalized) {
423
+ assert.deepEqual(args, bases);
424
+ return this;
425
+ }
409
426
 
410
- each.call(arguments, function(baseName) {
427
+ args.forEach(function(baseName) {
411
428
  isString.assert(baseName);
412
429
 
413
430
  // This indexOf lookup may be O(n), but the typical number of base
@@ -450,6 +467,8 @@ exports.defineMethod = function(name, func) {
450
467
  return old;
451
468
  };
452
469
 
470
+ var isArrayOfString = isString.arrayOf();
471
+
453
472
  // Calling the .build method of a Def simultaneously marks the type as
454
473
  // buildable (by defining builders[getBuilderName(typeName)]) and
455
474
  // specifies the order of arguments that should be passed to the builder
@@ -457,18 +476,18 @@ exports.defineMethod = function(name, func) {
457
476
  Dp.build = function(/* param1, param2, ... */) {
458
477
  var self = this;
459
478
 
479
+ var newBuildParams = slice.call(arguments);
480
+ isArrayOfString.assert(newBuildParams);
481
+
460
482
  // Calling Def.prototype.build multiple times has the effect of merely
461
483
  // redefining this property.
462
484
  Object.defineProperty(self, "buildParams", {
463
- value: slice.call(arguments),
485
+ value: newBuildParams,
464
486
  writable: false,
465
487
  enumerable: false,
466
488
  configurable: true
467
489
  });
468
490
 
469
- assert.strictEqual(self.finalized, false);
470
- isString.arrayOf().assert(self.buildParams);
471
-
472
491
  if (self.buildable) {
473
492
  // If this Def is already buildable, update self.buildParams and
474
493
  // continue using the old builder function.
@@ -478,7 +497,7 @@ Dp.build = function(/* param1, param2, ... */) {
478
497
  // Every buildable type will have its "type" field filled in
479
498
  // automatically. This includes types that are not subtypes of Node,
480
499
  // like SourceLocation, but that seems harmless (TODO?).
481
- self.field("type", self.typeName, function() { return self.typeName });
500
+ self.field("type", String, function() { return self.typeName });
482
501
 
483
502
  // Override Dp.buildable for this Def instance.
484
503
  Object.defineProperty(self, "buildable", { value: true });
@@ -570,13 +589,25 @@ function getBuilderName(typeName) {
570
589
  }
571
590
  });
572
591
  }
592
+ exports.getBuilderName = getBuilderName;
593
+
594
+ function getStatementBuilderName(typeName) {
595
+ typeName = getBuilderName(typeName);
596
+ return typeName.replace(/(Expression)?$/, "Statement");
597
+ }
598
+ exports.getStatementBuilderName = getStatementBuilderName;
573
599
 
574
600
  // The reason fields are specified using .field(...) instead of an object
575
601
  // literal syntax is somewhat subtle: the object literal syntax would
576
602
  // support only one key and one value, but with .field(...) we can pass
577
603
  // any number of arguments to specify the field.
578
604
  Dp.field = function(name, type, defaultFn, hidden) {
579
- assert.strictEqual(this.finalized, false);
605
+ if (this.finalized) {
606
+ console.error("Ignoring attempt to redefine field " +
607
+ JSON.stringify(name) + " of finalized type " +
608
+ JSON.stringify(this.typeName));
609
+ return this;
610
+ }
580
611
  this.ownFields[name] = new Field(name, type, defaultFn, hidden);
581
612
  return this; // For chaining.
582
613
  };
@@ -643,44 +674,77 @@ exports.someField = function(object, callback, context) {
643
674
  Object.defineProperty(Dp, "finalized", { value: false });
644
675
 
645
676
  Dp.finalize = function() {
677
+ var self = this;
678
+
646
679
  // It's not an error to finalize a type more than once, but only the
647
680
  // first call to .finalize does anything.
648
- if (!this.finalized) {
649
- var allFields = this.allFields;
650
- var allSupertypes = this.allSupertypes;
681
+ if (!self.finalized) {
682
+ var allFields = self.allFields;
683
+ var allSupertypes = self.allSupertypes;
651
684
 
652
- this.baseNames.forEach(function(name) {
685
+ self.baseNames.forEach(function(name) {
653
686
  var def = defCache[name];
654
- def.finalize();
655
- extend(allFields, def.allFields);
656
- extend(allSupertypes, def.allSupertypes);
687
+ if (def instanceof Def) {
688
+ def.finalize();
689
+ extend(allFields, def.allFields);
690
+ extend(allSupertypes, def.allSupertypes);
691
+ } else {
692
+ var message = "unknown supertype name " +
693
+ JSON.stringify(name) +
694
+ " for subtype " +
695
+ JSON.stringify(self.typeName);
696
+ assert.ok(false, message);
697
+ }
657
698
  });
658
699
 
659
700
  // TODO Warn if fields are overridden with incompatible types.
660
- extend(allFields, this.ownFields);
661
- allSupertypes[this.typeName] = this;
701
+ extend(allFields, self.ownFields);
702
+ allSupertypes[self.typeName] = self;
662
703
 
663
- this.fieldNames.length = 0;
704
+ self.fieldNames.length = 0;
664
705
  for (var fieldName in allFields) {
665
706
  if (hasOwn.call(allFields, fieldName) &&
666
707
  !allFields[fieldName].hidden) {
667
- this.fieldNames.push(fieldName);
708
+ self.fieldNames.push(fieldName);
668
709
  }
669
710
  }
670
711
 
671
712
  // Types are exported only once they have been finalized.
672
- Object.defineProperty(namedTypes, this.typeName, {
713
+ Object.defineProperty(namedTypes, self.typeName, {
673
714
  enumerable: true,
674
- value: this.type
715
+ value: self.type
675
716
  });
676
717
 
677
- Object.defineProperty(this, "finalized", { value: true });
718
+ Object.defineProperty(self, "finalized", { value: true });
678
719
 
679
720
  // A linearization of the inheritance hierarchy.
680
- populateSupertypeList(this.typeName, this.supertypeList);
721
+ populateSupertypeList(self.typeName, self.supertypeList);
722
+
723
+ if (self.buildable && self.supertypeList.lastIndexOf("Expression") >= 0) {
724
+ wrapExpressionBuilderWithStatement(self.typeName);
725
+ }
681
726
  }
682
727
  };
683
728
 
729
+ // Adds an additional builder for Expression subtypes
730
+ // that wraps the built Expression in an ExpressionStatements.
731
+ function wrapExpressionBuilderWithStatement(typeName) {
732
+ var wrapperName = getStatementBuilderName(typeName);
733
+
734
+ // skip if the builder already exists
735
+ if (builders[wrapperName]) return;
736
+
737
+ // the builder function to wrap with builders.ExpressionStatement
738
+ var wrapped = builders[getBuilderName(typeName)];
739
+
740
+ // skip if there is nothing to wrap
741
+ if (!wrapped) return;
742
+
743
+ builders[wrapperName] = function() {
744
+ return builders.expressionStatement(wrapped.apply(builders, arguments));
745
+ };
746
+ }
747
+
684
748
  function populateSupertypeList(typeName, list) {
685
749
  list.length = 0;
686
750
  list.push(typeName);
package/main.js CHANGED
@@ -11,6 +11,8 @@ require("./def/es7");
11
11
  require("./def/mozilla");
12
12
  require("./def/e4x");
13
13
  require("./def/fb-harmony");
14
+ require("./def/esprima");
15
+ require("./def/babel");
14
16
 
15
17
  types.finalize();
16
18
 
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "transformation",
19
19
  "syntax"
20
20
  ],
21
- "version": "0.7.5",
21
+ "version": "0.8.2",
22
22
  "homepage": "http://github.com/benjamn/ast-types",
23
23
  "repository": {
24
24
  "type": "git",
@@ -27,16 +27,16 @@
27
27
  "license": "MIT",
28
28
  "main": "main.js",
29
29
  "scripts": {
30
- "test": "mocha --reporter spec test/run.js"
31
- },
32
- "dependencies": {
30
+ "test": "mocha --reporter spec --full-trace test/run.js"
33
31
  },
32
+ "dependencies": {},
34
33
  "devDependencies": {
34
+ "babel-core": "^5.6.15",
35
35
  "esprima": "~1.2.2",
36
36
  "esprima-fb": "~14001.1.0-dev-harmony-fb",
37
- "mocha": "~1.20.1"
37
+ "mocha": "~2.2.5"
38
38
  },
39
39
  "engines": {
40
- "node": ">= 0.6"
40
+ "node": ">= 0.8"
41
41
  }
42
42
  }