Socket
Socket
Sign inDemoInstall

babylon

Package Overview
Dependencies
Maintainers
7
Versions
132
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babylon - npm Package Compare versions

Comparing version 6.9.0 to 6.9.1

47

CHANGELOG.md

@@ -16,2 +16,49 @@ # Changelog

## 6.9.0 (2016-08-16)
### New syntax support
- Add JSX spread children ([#42](https://github.com/babel/babylon/pull/42)) @calebmer
(Be aware that React is not going to support this syntax)
```js
<div>
{...todos.map(todo => <Todo key={todo.id} todo={todo}/>)}
</div>
```
- Add support for declare module.exports ([#72](https://github.com/babel/babylon/pull/72)) @danez
```js
declare module "foo" {
declare module.exports: {}
}
```
### New Features
- If supplied, attach filename property to comment node loc. ([#80](https://github.com/babel/babylon/pull/80)) @divmain
- Add identifier name to node loc field ([#90](https://github.com/babel/babylon/pull/90)) @kittens
### Bug Fixes
- Fix exponential operator to behave according to spec ([#75](https://github.com/babel/babylon/pull/75)) @danez
- Fix lookahead to not add comments to arrays which are not cloned ([#76](https://github.com/babel/babylon/pull/76)) @danez
- Fix accidental fall-through in Flow type parsing. ([#82](https://github.com/babel/babylon/pull/82)) @xiemaisi
- Only allow declares inside declare module ([#73](https://github.com/babel/babylon/pull/73)) @danez
- Small fix for parsing type parameter declarations ([#83](https://github.com/babel/babylon/pull/83)) @gabelevi
- Fix arrow param locations with flow types ([#57](https://github.com/babel/babylon/pull/57)) @danez
- Fixes SyntaxError position with flow optional type ([#65](https://github.com/babel/babylon/pull/65)) @danez
### Internal
- Add codecoverage to tests @danez
- Fix tests to not save expected output if we expect the test to fail @danez
- Make a shallow clone of babel for testing @danez
- chore(package): update cross-env to version 2.0.0 ([#77](https://github.com/babel/babylon/pull/77)) @greenkeeperio-bot
- chore(package): update ava to version 0.16.0 ([#86](https://github.com/babel/babylon/pull/86)) @greenkeeperio-bot
- chore(package): update babel-plugin-istanbul to version 2.0.0 ([#89](https://github.com/babel/babylon/pull/89)) @greenkeeperio-bot
- chore(package): update nyc to version 8.0.0 ([#88](https://github.com/babel/babylon/pull/88)) @greenkeeperio-bot
## 6.8.4 (2016-07-06)

@@ -18,0 +65,0 @@

55

lib/parser/expression.js

@@ -317,3 +317,3 @@ "use strict";

_node4.callee = base;
_node4.arguments = this.parseCallExpressionArguments(_types.types.parenR, this.hasPlugin("trailingFunctionCommas"), possibleAsync);
_node4.arguments = this.parseCallExpressionArguments(_types.types.parenR, possibleAsync);
base = this.finishNode(_node4, "CallExpression");

@@ -337,3 +337,3 @@

pp.parseCallExpressionArguments = function (close, allowTrailingComma, possibleAsyncArrow) {
pp.parseCallExpressionArguments = function (close, possibleAsyncArrow) {
var innerParenStart = void 0;

@@ -348,3 +348,3 @@

this.expect(_types.types.comma);
if (allowTrailingComma && this.eat(close)) break;
if (this.eat(close)) break;
}

@@ -357,3 +357,3 @@

elts.push(this.parseExprListItem());
elts.push(this.parseExprListItem(undefined, possibleAsyncArrow ? { start: 0 } : undefined));
}

@@ -374,3 +374,2 @@

pp.parseAsyncArrowFromCallExpression = function (node, call) {
if (!this.hasPlugin("asyncFunctions")) this.unexpected();
this.expect(_types.types.arrow);

@@ -422,20 +421,18 @@ return this.parseArrowExpression(node, call.arguments, true);

node = this.startNode();
var allowAwait = this.hasPlugin("asyncFunctions") && this.state.value === "await" && this.state.inAsync;
var allowAwait = this.state.value === "await" && this.state.inAsync;
var allowYield = this.shouldAllowYieldIdentifier();
var id = this.parseIdentifier(allowAwait || allowYield);
if (this.hasPlugin("asyncFunctions")) {
if (id.name === "await") {
if (this.state.inAsync || this.inModule) {
return this.parseAwait(node);
}
} else if (id.name === "async" && this.match(_types.types._function) && !this.canInsertSemicolon()) {
this.next();
return this.parseFunction(node, false, false, true);
} else if (canBeArrow && id.name === "async" && this.match(_types.types.name)) {
var params = [this.parseIdentifier()];
this.expect(_types.types.arrow);
// let foo = bar => {};
return this.parseArrowExpression(node, params, true);
if (id.name === "await") {
if (this.state.inAsync || this.inModule) {
return this.parseAwait(node);
}
} else if (id.name === "async" && this.match(_types.types._function) && !this.canInsertSemicolon()) {
this.next();
return this.parseFunction(node, false, false, true);
} else if (canBeArrow && id.name === "async" && this.match(_types.types.name)) {
var params = [this.parseIdentifier()];
this.expect(_types.types.arrow);
// let foo = bar => {};
return this.parseArrowExpression(node, params, true);
}

@@ -493,3 +490,3 @@

this.next();
node.elements = this.parseExprList(_types.types.bracketR, true, true, refShorthandDefaultPos);
node.elements = this.parseExprList(_types.types.bracketR, true, refShorthandDefaultPos);
this.toReferencedList(node.elements);

@@ -591,3 +588,3 @@ return this.finishNode(node, "ArrayExpression");

this.expect(_types.types.comma, refNeedsArrowPos.start || null);
if (this.match(_types.types.parenR) && this.hasPlugin("trailingFunctionCommas")) {
if (this.match(_types.types.parenR)) {
optionalCommaStart = this.state.start;

@@ -695,3 +692,3 @@ break;

if (this.eat(_types.types.parenL)) {
node.arguments = this.parseExprList(_types.types.parenR, this.hasPlugin("trailingFunctionCommas"));
node.arguments = this.parseExprList(_types.types.parenR);
this.toReferencedList(node.arguments);

@@ -786,3 +783,3 @@ } else {

if (!isPattern && this.hasPlugin("asyncFunctions") && this.isContextual("async")) {
if (!isPattern && this.isContextual("async")) {
if (isGenerator) this.unexpected();

@@ -893,5 +890,3 @@

node.expression = false;
if (this.hasPlugin("asyncFunctions")) {
node.async = !!isAsync;
}
node.async = !!isAsync;
};

@@ -906,3 +901,3 @@

this.expect(_types.types.parenL);
node.params = this.parseBindingList(_types.types.parenR, false, this.hasPlugin("trailingFunctionCommas"));
node.params = this.parseBindingList(_types.types.parenR);
node.generator = isGenerator;

@@ -1036,3 +1031,3 @@ this.parseFunctionBody(node);

pp.parseExprList = function (close, allowTrailingComma, allowEmpty, refShorthandDefaultPos) {
pp.parseExprList = function (close, allowEmpty, refShorthandDefaultPos) {
var elts = [],

@@ -1045,3 +1040,3 @@ first = true;

this.expect(_types.types.comma);
if (allowTrailingComma && this.eat(close)) break;
if (this.eat(close)) break;
}

@@ -1061,3 +1056,3 @@

} else {
elt = this.parseMaybeAssign(false, refShorthandDefaultPos);
elt = this.parseMaybeAssign(false, refShorthandDefaultPos, this.parseParenItem);
}

@@ -1064,0 +1059,0 @@ return elt;

@@ -163,3 +163,3 @@ "use strict";

if (this.state.strict || this.state.inGenerator) this.unexpected();
// fall-through
case _types.types.name:

@@ -171,3 +171,3 @@ return this.parseIdentifier(true);

this.next();
node.elements = this.parseBindingList(_types.types.bracketR, true, true);
node.elements = this.parseBindingList(_types.types.bracketR, true);
return this.finishNode(node, "ArrayPattern");

@@ -183,3 +183,3 @@

pp.parseBindingList = function (close, allowEmpty, allowTrailingComma) {
pp.parseBindingList = function (close, allowEmpty) {
var elts = [];

@@ -195,3 +195,3 @@ var first = true;

elts.push(null);
} else if (allowTrailingComma && this.eat(close)) {
} else if (this.eat(close)) {
break;

@@ -198,0 +198,0 @@ } else if (this.match(_types.types.ellipsis)) {

@@ -144,3 +144,3 @@ "use strict";

case _types.types.name:
if (this.hasPlugin("asyncFunctions") && this.state.value === "async") {
if (this.state.value === "async") {
// peek ahead and see if next token is a function

@@ -657,3 +657,3 @@ var state = this.state.clone();

this.expect(_types.types.parenL);
node.params = this.parseBindingList(_types.types.parenR, false, this.hasPlugin("trailingFunctionCommas"));
node.params = this.parseBindingList(_types.types.parenR);
};

@@ -739,3 +739,3 @@

var isAsyncMethod = this.hasPlugin("asyncFunctions") && !this.match(_types.types.parenL) && !method.computed && method.key.type === "Identifier" && method.key.name === "async";
var isAsyncMethod = !this.match(_types.types.parenL) && !method.computed && method.key.type === "Identifier" && method.key.name === "async";
if (isAsyncMethod) {

@@ -951,3 +951,3 @@ if (this.hasPlugin("asyncGenerators") && this.eat(_types.types.star)) isGenerator = true;

pp.shouldParseExportDeclaration = function () {
return this.hasPlugin("asyncFunctions") && this.isContextual("async");
return this.isContextual("async");
};

@@ -954,0 +954,0 @@

@@ -183,7 +183,7 @@ "use strict";

instance.extend("toAssignable", function (inner) {
return function (node) {
return function (node, isBinding) {
if (node.type === "TypeCastExpression") {
return this.typeCastToParameter(node);
return inner.call(this, this.typeCastToParameter(node), isBinding);
} else {
return inner.apply(this, arguments);
return inner.call(this, node, isBinding);
}

@@ -222,3 +222,3 @@ };

// parse an item inside a expression list eg. `(NODE, NODE)` where NODE represents
// the position where this function is cal;ed
// the position where this function is called
instance.extend("parseExprListItem", function (inner) {

@@ -660,3 +660,3 @@ return function (allowEmpty, refShorthandDefaultPos) {

node.id = this.parseIdentifier();
node.id = this.flowParseQualifiedTypeIdentifier();
if (this.isRelational("<")) {

@@ -890,15 +890,23 @@ node.typeParameters = this.flowParseTypeParameterInstantiation();

pp.flowParseGenericType = function (startPos, startLoc, id) {
var node = this.startNodeAt(startPos, startLoc);
pp.flowParseQualifiedTypeIdentifier = function (startPos, startLoc, id) {
startPos = startPos || this.state.start;
startLoc = startLoc || this.state.startLoc;
var node = id || this.parseIdentifier();
node.typeParameters = null;
node.id = id;
while (this.eat(_types.types.dot)) {
var node2 = this.startNodeAt(startPos, startLoc);
node2.qualification = node.id;
node2.qualification = node;
node2.id = this.parseIdentifier();
node.id = this.finishNode(node2, "QualifiedTypeIdentifier");
node = this.finishNode(node2, "QualifiedTypeIdentifier");
}
return node;
};
pp.flowParseGenericType = function (startPos, startLoc, id) {
var node = this.startNodeAt(startPos, startLoc);
node.typeParameters = null;
node.id = this.flowParseQualifiedTypeIdentifier(startPos, startLoc, id);
if (this.isRelational("<")) {

@@ -905,0 +913,0 @@ node.typeParameters = this.flowParseTypeParameterInstantiation();

@@ -362,3 +362,3 @@ "use strict";

if (next === 42 && this.hasPlugin("exponentiationOperator")) {
if (next === 42) {
// '*'

@@ -365,0 +365,0 @@ width++;

{
"name": "babylon",
"version": "6.9.0",
"version": "6.9.1",
"description": "A JavaScript parser",

@@ -49,4 +49,4 @@ "author": "Sebastian McKenzie <sebmck@gmail.com>",

"include": [
"src/*.js",
"bin/*.js"
"src/**/*.js",
"bin/**/*.js"
],

@@ -53,0 +53,0 @@ "sourceMap": false,

@@ -14,3 +14,3 @@ <p align="center">

- ES6 enabled by default.
- The latest ECMAScript version enabled by default (ES2017).
- Comment attachment.

@@ -96,5 +96,2 @@ - Support for JSX and Flow.

plugins: [
// enable experimental async functions
"asyncFunctions",
// enable jsx and flow syntax

@@ -111,6 +108,4 @@ "jsx",

- `flow`
- `asyncFunctions`
- `classConstructorCall`
- `doExpressions`
- `trailingFunctionCommas`
- `objectRestSpread`

@@ -120,5 +115,4 @@ - `decorators`

- `exportExtensions`
- `exponentiationOperator`
- `asyncGenerators`
- `functionBind`
- `functionSent`
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc