Socket
Socket
Sign inDemoInstall

babel

Package Overview
Dependencies
Maintainers
1
Versions
165
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel - npm Package Compare versions

Comparing version 4.5.0 to 4.5.1

2

bin/babel/dir.js

@@ -67,3 +67,3 @@ var outputFileSync = require("output-file-sync");

var relative = path.relative(dirname, filename) || filename;
write(filename, relative);
if (util.canCompile(filename)) write(filename, relative);
});

@@ -70,0 +70,0 @@ });

@@ -27,2 +27,3 @@ var resolveRc = require("../../lib/babel/api/register/resolve-rc");

opts.filename = filename;
resolveRc(filename, opts);

@@ -46,5 +47,4 @@ var result;

exports.compile = function (filename, opts) {
resolveRc(filename, opts);
var code = fs.readFileSync(filename, "utf8");
return exports.transform(filename, code, opts);
};

@@ -13,2 +13,45 @@ # Contributing

#### Setup
```sh
$ git clone https://github.com/babel/babel
$ cd babel
$ make bootstrap
```
Then you need to run:
```sh
$ make watch-core
```
This will compile babel and then sit in the background and on file modification
recompile the necessary files.
#### Running tests
You can run tests via:
```sh
$ make test
```
This will usually take around two minutes as it's compiling the entire
[test262](https://github.com/tc39/test262) test suite and validating it's AST.
This is mostly overkill and you can limit the tests to a select few by directly
running them with `mocha`:
```sh
$ mocha test/transformation.js
```
#### Linting
Please follow the correct code style, this ensures that the code is consistent
and increases maintainability.
```sh
$ make lint
```
#### Workflow

@@ -22,4 +65,3 @@

* Ensure the test are passing (`make test`)
* Create new pull request explaining your proposed change or reference an issue
in your commit message
* Create new pull request explaining your proposed change or reference an issue in your commit message

@@ -48,9 +90,1 @@ #### Code Standards

* No pollution of global variables and prototypes
## Testing
$ make test
## Linting
$ make lint

@@ -1,1 +0,1 @@

(function(global){var babelHelpers=global.babelHelpers={};babelHelpers.inherits=function(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass)}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)subClass.__proto__=superClass};babelHelpers.defaults=function(obj,defaults){var keys=Object.getOwnPropertyNames(defaults);for(var i=0;i<keys.length;i++){var key=keys[i];var value=Object.getOwnPropertyDescriptor(defaults,key);if(value&&value.configurable&&obj[key]===undefined){Object.defineProperty(obj,key,value)}}return obj};babelHelpers.prototypeProperties=function(child,staticProps,instanceProps){if(staticProps)Object.defineProperties(child,staticProps);if(instanceProps)Object.defineProperties(child.prototype,instanceProps)};babelHelpers.applyConstructor=function(Constructor,args){var instance=Object.create(Constructor.prototype);var result=Constructor.apply(instance,args);return result!=null&&(typeof result=="object"||typeof result=="function")?result:instance};babelHelpers.taggedTemplateLiteral=function(strings,raw){return Object.freeze(Object.defineProperties(strings,{raw:{value:Object.freeze(raw)}}))};babelHelpers.taggedTemplateLiteralLoose=function(strings,raw){strings.raw=raw;return strings};babelHelpers.interopRequire=function(obj){return obj&&obj.__esModule?obj.default:obj};babelHelpers.toArray=function(arr){return Array.isArray(arr)?arr:Array.from(arr)};babelHelpers.toConsumableArray=function(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++)arr2[i]=arr[i];return arr2}else{return Array.from(arr)}};babelHelpers.slicedToArray=function(arr,i){if(Array.isArray(arr)){return arr}else if(Symbol.iterator in Object(arr)){var _arr=[];for(var _iterator=arr[Symbol.iterator](),_step;!(_step=_iterator.next()).done;){_arr.push(_step.value);if(i&&_arr.length===i)break}return _arr}else{throw new TypeError("Invalid attempt to destructure non-iterable instance")}};babelHelpers.objectWithoutProperties=function(obj,keys){var target={};for(var i in obj){if(keys.indexOf(i)>=0)continue;if(!Object.prototype.hasOwnProperty.call(obj,i))continue;target[i]=obj[i]}return target};babelHelpers.hasOwn=Object.prototype.hasOwnProperty;babelHelpers.slice=Array.prototype.slice;babelHelpers.bind=Function.prototype.bind;babelHelpers.defineProperty=function(obj,key,value){return Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})};babelHelpers.asyncToGenerator=function(fn){return function(){var gen=fn.apply(this,arguments);return new Promise(function(resolve,reject){var callNext=step.bind(null,"next");var callThrow=step.bind(null,"throw");function step(key,arg){try{var info=gen[key](arg);var value=info.value}catch(error){reject(error);return}if(info.done){resolve(value)}else{Promise.resolve(value).then(callNext,callThrow)}}callNext()})}};babelHelpers.interopRequireWildcard=function(obj){return obj&&obj.__esModule?obj:{"default":obj}};babelHelpers._typeof=function(obj){return obj&&obj.constructor===Symbol?"symbol":typeof obj};babelHelpers._extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key]}}}return target};babelHelpers.get=function get(object,property,receiver){var desc=Object.getOwnPropertyDescriptor(object,property);if(desc===undefined){var parent=Object.getPrototypeOf(object);if(parent===null){return undefined}else{return get(parent,property,receiver)}}else if("value"in desc&&desc.writable){return desc.value}else{var getter=desc.get;if(getter===undefined){return undefined}return getter.call(receiver)}};babelHelpers.set=function set(object,property,value,receiver){var desc=Object.getOwnPropertyDescriptor(object,property);if(desc===undefined){var parent=Object.getPrototypeOf(object);if(parent!==null){return set(parent,property,value,receiver)}}else if("value"in desc&&desc.writable){return desc.value=value}else{var setter=desc.set;if(setter!==undefined){return setter.call(receiver,value)}}};babelHelpers.classCallCheck=function(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}};babelHelpers.objectDestructuringEmpty=function(obj){if(obj==null)throw new TypeError("Cannot destructure undefined")};babelHelpers.temporalUndefined={};babelHelpers.temporalAssertDefined=function(val,name,undef){if(val===undef){throw new ReferenceError(name+" is not defined - temporal dead zone")}return true};babelHelpers.selfGlobal=typeof global==="undefined"?self:global})(typeof global==="undefined"?self:global);
(function(global){var babelHelpers=global.babelHelpers={};babelHelpers.inherits=function(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass)}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)subClass.__proto__=superClass};babelHelpers.defaults=function(obj,defaults){var keys=Object.getOwnPropertyNames(defaults);for(var i=0;i<keys.length;i++){var key=keys[i];var value=Object.getOwnPropertyDescriptor(defaults,key);if(value&&value.configurable&&obj[key]===undefined){Object.defineProperty(obj,key,value)}}return obj};babelHelpers.prototypeProperties=function(child,staticProps,instanceProps){if(staticProps)Object.defineProperties(child,staticProps);if(instanceProps)Object.defineProperties(child.prototype,instanceProps)};babelHelpers.applyConstructor=function(Constructor,args){var instance=Object.create(Constructor.prototype);var result=Constructor.apply(instance,args);return result!=null&&(typeof result=="object"||typeof result=="function")?result:instance};babelHelpers.taggedTemplateLiteral=function(strings,raw){return Object.freeze(Object.defineProperties(strings,{raw:{value:Object.freeze(raw)}}))};babelHelpers.taggedTemplateLiteralLoose=function(strings,raw){strings.raw=raw;return strings};babelHelpers.interopRequire=function(obj){return obj&&obj.__esModule?obj["default"]:obj};babelHelpers.toArray=function(arr){return Array.isArray(arr)?arr:Array.from(arr)};babelHelpers.toConsumableArray=function(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++)arr2[i]=arr[i];return arr2}else{return Array.from(arr)}};babelHelpers.slicedToArray=function(arr,i){if(Array.isArray(arr)){return arr}else if(Symbol.iterator in Object(arr)){var _arr=[];for(var _iterator=arr[Symbol.iterator](),_step;!(_step=_iterator.next()).done;){_arr.push(_step.value);if(i&&_arr.length===i)break}return _arr}else{throw new TypeError("Invalid attempt to destructure non-iterable instance")}};babelHelpers.objectWithoutProperties=function(obj,keys){var target={};for(var i in obj){if(keys.indexOf(i)>=0)continue;if(!Object.prototype.hasOwnProperty.call(obj,i))continue;target[i]=obj[i]}return target};babelHelpers.hasOwn=Object.prototype.hasOwnProperty;babelHelpers.slice=Array.prototype.slice;babelHelpers.bind=Function.prototype.bind;babelHelpers.defineProperty=function(obj,key,value){return Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})};babelHelpers.asyncToGenerator=function(fn){return function(){var gen=fn.apply(this,arguments);return new Promise(function(resolve,reject){var callNext=step.bind(null,"next");var callThrow=step.bind(null,"throw");function step(key,arg){try{var info=gen[key](arg);var value=info.value}catch(error){reject(error);return}if(info.done){resolve(value)}else{Promise.resolve(value).then(callNext,callThrow)}}callNext()})}};babelHelpers.interopRequireWildcard=function(obj){return obj&&obj.__esModule?obj:{"default":obj}};babelHelpers._typeof=function(obj){return obj&&obj.constructor===Symbol?"symbol":typeof obj};babelHelpers._extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key]}}}return target};babelHelpers.get=function get(object,property,receiver){var desc=Object.getOwnPropertyDescriptor(object,property);if(desc===undefined){var parent=Object.getPrototypeOf(object);if(parent===null){return undefined}else{return get(parent,property,receiver)}}else if("value"in desc&&desc.writable){return desc.value}else{var getter=desc.get;if(getter===undefined){return undefined}return getter.call(receiver)}};babelHelpers.set=function set(object,property,value,receiver){var desc=Object.getOwnPropertyDescriptor(object,property);if(desc===undefined){var parent=Object.getPrototypeOf(object);if(parent!==null){return set(parent,property,value,receiver)}}else if("value"in desc&&desc.writable){return desc.value=value}else{var setter=desc.set;if(setter!==undefined){return setter.call(receiver,value)}}};babelHelpers.classCallCheck=function(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}};babelHelpers.objectDestructuringEmpty=function(obj){if(obj==null)throw new TypeError("Cannot destructure undefined")};babelHelpers.temporalUndefined={};babelHelpers.temporalAssertDefined=function(val,name,undef){if(val===undef){throw new ReferenceError(name+" is not defined - temporal dead zone")}return true};babelHelpers.selfGlobal=typeof global==="undefined"?self:global})(typeof global==="undefined"?self:global);

@@ -39,8 +39,18 @@ "use strict";

var runScripts = function () {
var runScripts = function runScripts() {
var scripts = [];
var types = ["text/ecmascript-6", "text/6to5", "text/babel", "module"];
var index = 0;
var types = ["text/ecmascript-6", "text/6to5", "text/babel", "module"];
var index = 0;
var exec = function () {
var exec = (function (_exec) {
var _execWrapper = function exec() {
return _exec.apply(this, arguments);
};
_execWrapper.toString = function () {
return _exec.toString();
};
return _execWrapper;
})(function () {
var param = scripts[index];

@@ -52,5 +62,5 @@ if (param instanceof Array) {

}
};
});
var run = function (script, i) {
var run = function run(script, i) {
var opts = {};

@@ -69,3 +79,3 @@

var _scripts = global.document .getElementsByTagName("script");
var _scripts = global.document.getElementsByTagName("script");

@@ -88,2 +98,2 @@ for (var i = 0; i < _scripts.length; ++i) {

global.attachEvent("onload", runScripts);
}
}
"use strict";
var isFunction = require("lodash/lang/isFunction");
var transform = require("../transformation");
var util = require("../util");
var fs = require("fs");
var transform = require("../transformation");
var util = require("../util");
var fs = require("fs");

@@ -58,2 +58,2 @@ exports.version = require("../../../package").version;

return transform(fs.readFileSync(filename), opts);
};
};

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

require("../../polyfill");
require("../../polyfill");
"use strict";
var path = require("path");
var os = require("os");
var fs = require("fs");
var os = require("os");
var fs = require("fs");

@@ -19,7 +19,17 @@ var FILENAME = process.env.BABEL_CACHE_PATH || path.join(os.tmpdir(), "babel.json");

var sigint = function () {
var sigint = (function (_sigint) {
var _sigintWrapper = function sigint() {
return _sigint.apply(this, arguments);
};
_sigintWrapper.toString = function () {
return _sigint.toString();
};
return _sigintWrapper;
})(function () {
process.removeListener("SIGINT", sigint);
exports.save();
process.kill(process.pid, "SIGINT");
};
});

@@ -39,2 +49,2 @@ process.on("SIGINT", sigint);

return data;
};
};

@@ -6,12 +6,12 @@ "use strict";

var sourceMapSupport = require("source-map-support");
var registerCache = require("./cache");
var resolveRc = require("./resolve-rc");
var extend = require("lodash/object/extend");
var babel = require("../node");
var each = require("lodash/collection/each");
var util = require("../../util");
var fs = require("fs");
var registerCache = require("./cache");
var resolveRc = require("./resolve-rc");
var extend = require("lodash/object/extend");
var babel = require("../node");
var each = require("lodash/collection/each");
var util = require("../../util");
var fs = require("fs");
sourceMapSupport.install({
retrieveSourceMap: function (source) {
retrieveSourceMap: function retrieveSourceMap(source) {
var map = maps && maps[source];

@@ -37,12 +37,12 @@ if (map) {

var transformOpts = {};
var ignoreRegex = /node_modules/;
var ignoreRegex = /node_modules/;
var onlyRegex;
var exts = {};
var maps = {};
var exts = {};
var maps = {};
var mtime = function (filename) {
var mtime = function mtime(filename) {
return +fs.statSync(filename).mtime;
};
var compile = function (filename) {
var compile = function compile(filename) {
var result;

@@ -65,3 +65,3 @@

sourceMap: true,
ast: false
ast: false
}));

@@ -80,4 +80,4 @@ }

var shouldIgnore = function (filename) {
return (ignoreRegex && ignoreRegex.test(filename)) || (onlyRegex && !onlyRegex.test(filename));
var shouldIgnore = function shouldIgnore(filename) {
return ignoreRegex && ignoreRegex.test(filename) || onlyRegex && !onlyRegex.test(filename);
};

@@ -87,3 +87,4 @@

if (process.env.running_under_istanbul) { // jshint ignore:line
if (process.env.running_under_istanbul) {
// jshint ignore:line
// we need to monkey patch fs.readFileSync so we can hook into

@@ -105,3 +106,3 @@ // what istanbul gets, it's extremely dirty but it's the only way

var istanbulLoader = function (m, filename, old) {
var istanbulLoader = function istanbulLoader(m, filename, old) {
istanbulMonkey[filename] = true;

@@ -111,7 +112,7 @@ old(m, filename);

var normalLoader = function (m, filename) {
var normalLoader = function normalLoader(m, filename) {
m._compile(compile(filename), filename);
};
var registerExtension = function (ext) {
var registerExtension = function registerExtension(ext) {
var old = require.extensions[ext];

@@ -131,3 +132,3 @@

var hookExtensions = function (_exts) {
var hookExtensions = function hookExtensions(_exts) {
each(exts, function (old, ext) {

@@ -164,2 +165,2 @@ require.extensions[ext] = old;

extend(transformOpts, opts);
};
};
"use strict";
var merge = require("lodash/object/merge");
var path = require("path");
var fs = require("fs");
var path = require("path");
var fs = require("fs");

@@ -33,7 +33,13 @@ var cache = {};

opts = merge(json, opts);
if (json.breakConfig) return;
merge(opts, json, function (a, b) {
if (Array.isArray(a)) {
return a.concat(b);
}
});
}
var up = path.dirname(start);
if (up !== start) { // root
if (up !== start) {
// root
find(up, rel);

@@ -46,2 +52,2 @@ }

return opts;
};
};
"use strict";
var buildHelpers = require("./build-helpers");
var generator = require("./generation");
var util = require("./util");
var t = require("./types");
var generator = require("./generation");
var util = require("./util");
var t = require("./types");

@@ -11,12 +11,7 @@ module.exports = function () {

var body = [];
var body = [];
var container = t.functionExpression(null, [t.identifier("global")], t.blockStatement(body));
var tree = t.program([t.expressionStatement(t.callExpression(container, [util.template("self-global")]))]);
var tree = t.program([t.expressionStatement(t.callExpression(container, [util.template("self-global")]))]);
body.push(t.variableDeclaration("var", [
t.variableDeclarator(
namespace,
t.assignmentExpression("=", t.memberExpression(t.identifier("global"), namespace), t.objectExpression([]))
)
]));
body.push(t.variableDeclaration("var", [t.variableDeclarator(namespace, t.assignmentExpression("=", t.memberExpression(t.identifier("global"), namespace), t.objectExpression([])))]));

@@ -26,2 +21,2 @@ buildHelpers(body, namespace);

return generator(tree).code;
};
};

@@ -0,5 +1,7 @@

"use strict";
var File = require("./transformation/file");
var util = require("./util");
var each = require("lodash/collection/each");
var t = require("./types");
var t = require("./types");

@@ -9,6 +11,4 @@ module.exports = function (body, namespace) {

var key = t.identifier(t.toIdentifier(name));
body.push(t.expressionStatement(
t.assignmentExpression("=", t.memberExpression(namespace, key), util.template(name))
));
body.push(t.expressionStatement(t.assignmentExpression("=", t.memberExpression(namespace, key), util.template(name))));
});
};
};

@@ -0,6 +1,8 @@

"use strict";
module.exports = detect;
var SYNTAX_KEYS = require("./syntax-keys");
var traverse = require("../traversal");
var visitors = traverse.explode(require("./visitors"));
var traverse = require("../traversal");
var visitors = traverse.explode(require("./visitors"));

@@ -13,3 +15,3 @@ function detect(ast) {

var detectedSyntax = function (name) {
var detectedSyntax = function detectedSyntax(name) {
stats.syntax[name] = true;

@@ -19,3 +21,3 @@ };

traverse(ast, {
enter: function (node, parent) {
enter: function enter(node, parent) {
if (SYNTAX_KEYS[node.type]) {

@@ -31,2 +33,2 @@ detectedSyntax(SYNTAX_KEYS[node.type]);

return stats;
}
}

@@ -0,1 +1,3 @@

"use strict";
var t = require("../types");

@@ -54,2 +56,2 @@ var includes = require("lodash/collection/includes");

}
};
};

@@ -8,10 +8,10 @@ "use strict";

var isBoolean = require("lodash/lang/isBoolean");
var includes = require("lodash/collection/includes");
var isNumber = require("lodash/lang/isNumber");
var includes = require("lodash/collection/includes");
var isNumber = require("lodash/lang/isNumber");
function Buffer(position, format) {
this.position = position;
this._indent = format.indent.base;
this.format = format;
this.buf = "";
this._indent = format.indent.base;
this.format = format;
this.buf = "";
}

@@ -124,4 +124,3 @@

var lastNewlineIndex = this.buf.lastIndexOf("\n");
if (lastNewlineIndex === -1)
return;
if (lastNewlineIndex === -1) return;

@@ -177,2 +176,2 @@ var index = this.buf.length - 1;

}
};
};

@@ -21,2 +21,2 @@ "use strict";

}
};
};
"use strict";
exports.ClassExpression =
exports.ClassDeclaration = function (node, print) {
exports.ClassExpression = exports.ClassDeclaration = function (node, print) {
this.push("class");

@@ -37,3 +36,3 @@

exports.MethodDefinition = function (node, print) {
if (node.static) {
if (node["static"]) {
this.push("static ");

@@ -43,2 +42,2 @@ }

this._method(node, print);
};
};

@@ -29,2 +29,2 @@ "use strict";

this.push(node.generator ? ")" : "]");
};
};
"use strict";
var isInteger = require("is-integer");
var isNumber = require("lodash/lang/isNumber");
var t = require("../../types");
var isNumber = require("lodash/lang/isNumber");
var t = require("../../types");

@@ -87,3 +87,3 @@ exports.UnaryExpression = function (node, print) {

var buildYieldAwait = function (keyword) {
var buildYieldAwait = function buildYieldAwait(keyword) {
return function (node, print) {

@@ -115,6 +115,3 @@ this.push(keyword);

exports.BinaryExpression =
exports.LogicalExpression =
exports.AssignmentPattern =
exports.AssignmentExpression = function (node, print) {
exports.BinaryExpression = exports.LogicalExpression = exports.AssignmentPattern = exports.AssignmentExpression = function (node, print) {
// todo: add cases where the spaces can be dropped when in compact mode

@@ -156,2 +153,2 @@ print(node.left);

}
};
};
"use strict";
exports.AnyTypeAnnotation =
exports.ArrayTypeAnnotation =
exports.BooleanTypeAnnotation =
exports.ClassProperty =
exports.DeclareClass =
exports.DeclareFunction =
exports.DeclareModule =
exports.DeclareVariable =
exports.FunctionTypeAnnotation =
exports.FunctionTypeParam =
exports.GenericTypeAnnotation =
exports.InterfaceExtends =
exports.InterfaceDeclaration =
exports.IntersectionTypeAnnotation =
exports.NullableTypeAnnotation =
exports.NumberTypeAnnotation =
exports.StringLiteralTypeAnnotation =
exports.StringTypeAnnotation =
exports.TupleTypeAnnotation =
exports.TypeofTypeAnnotation =
exports.TypeAlias =
exports.TypeAnnotation =
exports.TypeParameterDeclaration =
exports.TypeParameterInstantiation =
exports.ObjectTypeAnnotation =
exports.ObjectTypeCallProperty =
exports.ObjectTypeIndexer =
exports.ObjectTypeProperty =
exports.QualifiedTypeIdentifier =
exports.UnionTypeAnnotation =
exports.TypeCastExpression =
exports.VoidTypeAnnotation = function () {
// todo: implement these once we have a `--keep-types` option
};
exports.AnyTypeAnnotation = exports.ArrayTypeAnnotation = exports.BooleanTypeAnnotation = exports.ClassProperty = exports.DeclareClass = exports.DeclareFunction = exports.DeclareModule = exports.DeclareVariable = exports.FunctionTypeAnnotation = exports.FunctionTypeParam = exports.GenericTypeAnnotation = exports.InterfaceExtends = exports.InterfaceDeclaration = exports.IntersectionTypeAnnotation = exports.NullableTypeAnnotation = exports.NumberTypeAnnotation = exports.StringLiteralTypeAnnotation = exports.StringTypeAnnotation = exports.TupleTypeAnnotation = exports.TypeofTypeAnnotation = exports.TypeAlias = exports.TypeAnnotation = exports.TypeParameterDeclaration = exports.TypeParameterInstantiation = exports.ObjectTypeAnnotation = exports.ObjectTypeCallProperty = exports.ObjectTypeIndexer = exports.ObjectTypeProperty = exports.QualifiedTypeIdentifier = exports.UnionTypeAnnotation = exports.TypeCastExpression = exports.VoidTypeAnnotation = function () {};
// todo: implement these once we have a `--keep-types` option
"use strict";
var t = require("../../types");
var t = require("../../types");
var each = require("lodash/collection/each");

@@ -43,3 +43,3 @@

exports.JSXElement = function (node, print) {
var self = this;
var _this = this;

@@ -53,3 +53,3 @@ var open = node.openingElement;

if (t.isLiteral(child)) {
self.push(child.value);
_this.push(child.value);
} else {

@@ -80,2 +80,2 @@ print(child);

exports.JSXEmptyExpression = function () {};
exports.JSXEmptyExpression = function () {};

@@ -13,4 +13,4 @@ "use strict";

var value = node.value;
var kind = node.kind;
var key = node.key;
var kind = node.kind;
var key = node.key;

@@ -40,4 +40,3 @@ if (!kind || kind === "init") {

exports.FunctionDeclaration =
exports.FunctionExpression = function (node, print) {
exports.FunctionDeclaration = exports.FunctionExpression = function (node, print) {
if (node.async) this.push("async ");

@@ -70,2 +69,2 @@ this.push("function");

print(node.body);
};
};
"use strict";
var t = require("../../types");
var t = require("../../types");
var each = require("lodash/collection/each");

@@ -31,3 +31,3 @@

if (node.default) {
if (node["default"]) {
this.push("default ");

@@ -62,3 +62,3 @@ }

exports.ImportDeclaration = function (node, print) {
var self = this;
var _this = this;

@@ -77,3 +77,3 @@ this.push("import ");

if (+i > 0) {
self.push(", ");
_this.push(", ");
}

@@ -85,3 +85,3 @@

foundImportSpecifier = true;
self.push("{ ");
_this.push("{ ");
}

@@ -106,2 +106,2 @@

print(node.name);
};
};

@@ -9,2 +9,2 @@ "use strict";

};
});
});
"use strict";
var repeating = require("repeating");
var t = require("../../types");
var t = require("../../types");

@@ -60,3 +60,3 @@ exports.WithStatement = function (node, print) {

var buildForXStatement = function (op) {
var buildForXStatement = function buildForXStatement(op) {
return function (node, print) {

@@ -86,3 +86,3 @@ this.keyword("for");

var buildLabelStatement = function (prefix, key) {
var buildLabelStatement = function buildLabelStatement(prefix, key) {
return function (node, print) {

@@ -102,4 +102,4 @@ this.push(prefix);

exports.ContinueStatement = buildLabelStatement("continue");
exports.ReturnStatement = buildLabelStatement("return", "argument");
exports.BreakStatement = buildLabelStatement("break");
exports.ReturnStatement = buildLabelStatement("return", "argument");
exports.BreakStatement = buildLabelStatement("break");

@@ -157,3 +157,3 @@ exports.LabeledStatement = function (node, print) {

indent: true,
addNewlines: function (leading, cas) {
addNewlines: function addNewlines(leading, cas) {
if (!leading && node.cases[node.cases.length - 1] === cas) return -1;

@@ -229,2 +229,2 @@ }

}
};
};

@@ -15,7 +15,8 @@ "use strict";

exports.TemplateLiteral = function (node, print) {
var _this = this;
this.push("`");
var quasis = node.quasis;
var self = this;
var len = quasis.length;
var len = quasis.length;

@@ -26,5 +27,5 @@ each(quasis, function (quasi, i) {

if (i + 1 < len) {
self.push("${ ");
_this.push("${ ");
print(node.expressions[i]);
self.push(" }");
_this.push(" }");
}

@@ -34,2 +35,2 @@ });

this._push("`");
};
};

@@ -9,5 +9,3 @@ "use strict";

exports.RestElement =
exports.SpreadElement =
exports.SpreadProperty = function (node, print) {
exports.RestElement = exports.SpreadElement = exports.SpreadProperty = function (node, print) {
this.push("...");

@@ -23,4 +21,3 @@ print(node.argument);

exports.ObjectExpression =
exports.ObjectPattern = function (node, print) {
exports.ObjectExpression = exports.ObjectPattern = function (node, print) {
var props = node.properties;

@@ -60,7 +57,7 @@

exports.ArrayExpression =
exports.ArrayPattern = function (node, print) {
exports.ArrayExpression = exports.ArrayPattern = function (node, print) {
var _this = this;
var elems = node.elements;
var self = this;
var len = elems.length;
var len = elems.length;

@@ -76,7 +73,7 @@ this.push("[");

// both (all) of the holes.
self.push(",");
_this.push(",");
} else {
if (i > 0) self.push(" ");
if (i > 0) _this.push(" ");
print(elem);
if (i < len - 1) self.push(",");
if (i < len - 1) _this.push(",");
}

@@ -89,3 +86,3 @@ });

exports.Literal = function (node) {
var val = node.value;
var val = node.value;
var type = typeof val;

@@ -111,2 +108,2 @@

}
};
};

@@ -11,12 +11,12 @@ "use strict";

var detectIndent = require("detect-indent");
var Whitespace = require("./whitespace");
var repeating = require("repeating");
var SourceMap = require("./source-map");
var Position = require("./position");
var messages = require("../messages");
var Buffer = require("./buffer");
var extend = require("lodash/object/extend");
var each = require("lodash/collection/each");
var n = require("./node");
var t = require("../types");
var Whitespace = require("./whitespace");
var repeating = require("repeating");
var SourceMap = require("./source-map");
var Position = require("./position");
var messages = require("../messages");
var Buffer = require("./buffer");
var extend = require("lodash/object/extend");
var each = require("lodash/collection/each");
var n = require("./node");
var t = require("../types");

@@ -27,11 +27,11 @@ function CodeGenerator(ast, opts, code) {

this.comments = ast.comments || [];
this.tokens = ast.tokens || [];
this.format = CodeGenerator.normalizeOptions(code, opts);
this.opts = opts;
this.ast = ast;
this.tokens = ast.tokens || [];
this.format = CodeGenerator.normalizeOptions(code, opts);
this.opts = opts;
this.ast = ast;
this.whitespace = new Whitespace(this.tokens, this.comments, this.format);
this.position = new Position;
this.map = new SourceMap(this.position, opts, code);
this.buffer = new Buffer(this.position, this.format);
this.position = new Position();
this.map = new SourceMap(this.position, opts, code);
this.buffer = new Buffer(this.position, this.format);
}

@@ -75,13 +75,13 @@

templateLiterals: require("./generators/template-literals"),
comprehensions: require("./generators/comprehensions"),
expressions: require("./generators/expressions"),
statements: require("./generators/statements"),
playground: require("./generators/playground"),
classes: require("./generators/classes"),
methods: require("./generators/methods"),
modules: require("./generators/modules"),
types: require("./generators/types"),
flow: require("./generators/flow"),
base: require("./generators/base"),
jsx: require("./generators/jsx")
comprehensions: require("./generators/comprehensions"),
expressions: require("./generators/expressions"),
statements: require("./generators/statements"),
playground: require("./generators/playground"),
classes: require("./generators/classes"),
methods: require("./generators/methods"),
modules: require("./generators/modules"),
types: require("./generators/types"),
flow: require("./generators/flow"),
base: require("./generators/base"),
jsx: require("./generators/jsx")
};

@@ -105,3 +105,3 @@

return {
map: this.map.get(),
map: this.map.get(),
code: this.buffer.get()

@@ -112,6 +112,6 @@ };

CodeGenerator.prototype.buildPrint = function (parent) {
var self = this;
var _this = this;
var print = function (node, opts) {
return self.print(node, parent, opts);
return _this.print(node, parent, opts);
};

@@ -122,7 +122,7 @@

opts.statement = true;
return self.printJoin(print, nodes, opts);
return _this.printJoin(print, nodes, opts);
};
print.join = function (nodes, opts) {
return self.printJoin(print, nodes, opts);
return _this.printJoin(print, nodes, opts);
};

@@ -137,7 +137,7 @@

print.block = function (node) {
return self.printBlock(print, node);
return _this.printBlock(print, node);
};
print.indentOnComments = function (node) {
return self.printAndIndentOnComments(print, node);
return _this.printAndIndentOnComments(print, node);
};

@@ -149,2 +149,4 @@

CodeGenerator.prototype.print = function (node, parent, opts) {
var _this = this;
if (!node) return "";

@@ -161,4 +163,2 @@

var self = this;
opts = opts || {};

@@ -176,5 +176,5 @@

if (leading) {
lines = self.whitespace.getNewlinesBefore(node);
lines = _this.whitespace.getNewlinesBefore(node);
} else {
lines = self.whitespace.getNewlinesAfter(node);
lines = _this.whitespace.getNewlinesAfter(node);
}

@@ -191,6 +191,6 @@ } else {

// generated nodes can't add starting file whitespace
if (!self.buffer.buf) lines = 0;
if (!_this.buffer.buf) lines = 0;
}
self.newline(lines);
_this.newline(lines);
};

@@ -200,3 +200,3 @@

var needsNoLineTermParens = n.needsParensNoLineTerminator(node, parent);
var needsParens = needsNoLineTermParens || n.needsParens(node, parent);
var needsParens = needsNoLineTermParens || n.needsParens(node, parent);

@@ -235,2 +235,4 @@ if (needsParens) this.push("(");

CodeGenerator.prototype.printJoin = function (print, nodes, opts) {
var _this = this;
if (!nodes || !nodes.length) return;

@@ -240,6 +242,5 @@

var self = this;
var len = nodes.length;
var len = nodes.length;
if (opts.indent) self.indent();
if (opts.indent) this.indent();

@@ -256,3 +257,3 @@ each(nodes, function (node, i) {

if (opts.separator && i < len - 1) {
self.push(opts.separator);
_this.push(opts.separator);
}

@@ -263,3 +264,3 @@ }

if (opts.indent) self.dedent();
if (opts.indent) this.dedent();
};

@@ -302,2 +303,4 @@

CodeGenerator.prototype.getComments = function (key, node, parent) {
var _this = this;
if (t.isExpressionStatement(parent)) {

@@ -308,4 +311,3 @@ return [];

var comments = [];
var nodes = [node];
var self = this;
var nodes = [node];

@@ -317,3 +319,3 @@ if (t.isExpressionStatement(node)) {

each(nodes, function (node) {
comments = comments.concat(self._getComments(key, node));
comments = comments.concat(_this._getComments(key, node));
});

@@ -325,6 +327,8 @@

CodeGenerator.prototype._getComments = function (key, node) {
return (node && node[key]) || [];
return node && node[key] || [];
};
CodeGenerator.prototype._printComments = function (comments) {
var _this = this;
if (this.format.compact) return;

@@ -335,4 +339,2 @@

var self = this;
each(comments, function (comment) {

@@ -342,3 +344,3 @@ var skip = false;

// find the original comment in the ast and set it as displayed
each(self.ast.comments, function (origComment) {
each(_this.ast.comments, function (origComment) {
if (origComment.start === comment.start) {

@@ -356,9 +358,9 @@ // comment has already been output

// whitespace before
self.newline(self.whitespace.getNewlinesBefore(comment));
_this.newline(_this.whitespace.getNewlinesBefore(comment));
var column = self.position.column;
var val = self.generateComment(comment);
var column = _this.position.column;
var val = _this.generateComment(comment);
if (column && !self.isLast(["\n", " ", "[", "{"])) {
self._push(" ");
if (column && !_this.isLast(["\n", " ", "[", "{"])) {
_this._push(" ");
column++;

@@ -369,3 +371,3 @@ }

if (comment.type === "Block" && self.format.indent.adjustMultilineComment) {
if (comment.type === "Block" && _this.format.indent.adjustMultilineComment) {
var offset = comment.loc.start.column;

@@ -377,3 +379,3 @@ if (offset) {

var indent = Math.max(self.indentSize(), column);
var indent = Math.max(_this.indentSize(), column);
val = val.replace(/\n/g, "\n" + repeating(" ", indent));

@@ -383,3 +385,3 @@ }

if (column === 0) {
val = self.getIndent() + val;
val = _this.getIndent() + val;
}

@@ -389,7 +391,7 @@

self._push(val);
_this._push(val);
// whitespace after
self.newline(self.whitespace.getNewlinesAfter(comment));
_this.newline(_this.whitespace.getNewlinesAfter(comment));
});
};
};

@@ -6,8 +6,8 @@ "use strict";

var whitespace = require("./whitespace");
var parens = require("./parentheses");
var each = require("lodash/collection/each");
var some = require("lodash/collection/some");
var t = require("../../types");
var parens = require("./parentheses");
var each = require("lodash/collection/each");
var some = require("lodash/collection/some");
var t = require("../../types");
var find = function (obj, node, parent) {
var find = function find(obj, node, parent) {
if (!obj) return;

@@ -32,3 +32,3 @@ var result;

this.parent = parent;
this.node = node;
this.node = node;
}

@@ -59,3 +59,3 @@

return (linesInfo && linesInfo[type]) || 0;
return linesInfo && linesInfo[type] || 0;
};

@@ -98,4 +98,3 @@

if (t.isContinueStatement(parent) || t.isBreakStatement(parent) ||
t.isReturnStatement(parent) || t.isThrowStatement(parent)) {
if (t.isContinueStatement(parent) || t.isBreakStatement(parent) || t.isReturnStatement(parent) || t.isThrowStatement(parent)) {
return true;

@@ -121,2 +120,2 @@ }

};
});
});
"use strict";
var t = require("../../types");
var t = require("../../types");
var each = require("lodash/collection/each");

@@ -8,15 +8,3 @@

each([
["||"],
["&&"],
["|"],
["^"],
["&"],
["==", "===", "!=", "!=="],
["<", ">", "<=", ">=", "in", "instanceof"],
[">>", "<<", ">>>"],
["+", "-"],
["*", "/", "%"],
["**"]
], function (tier, i) {
each([["||"], ["&&"], ["|"], ["^"], ["&"], ["==", "===", "!=", "!=="], ["<", ">", "<=", ">=", "in", "instanceof"], [">>", "<<", ">>>"], ["+", "-"], ["*", "/", "%"], ["**"]], function (tier, i) {
each(tier, function (op) {

@@ -62,3 +50,3 @@ PRECEDENCE[op] = i;

if (t.isBinary(parent)) {
var parentOp = parent.operator;
var parentOp = parent.operator;
var parentPos = PRECEDENCE[parentOp];

@@ -112,9 +100,3 @@

exports.YieldExpression = function (node, parent) {
return t.isBinary(parent) ||
t.isUnaryLike(parent) ||
t.isCallExpression(parent) ||
t.isMemberExpression(parent) ||
t.isNewExpression(parent) ||
t.isConditionalExpression(parent) ||
t.isYieldExpression(parent);
return t.isBinary(parent) || t.isUnaryLike(parent) || t.isCallExpression(parent) || t.isMemberExpression(parent) || t.isNewExpression(parent) || t.isConditionalExpression(parent) || t.isYieldExpression(parent);
};

@@ -147,4 +129,3 @@

exports.AssignmentExpression =
exports.ConditionalExpression = function (node, parent) {
exports.AssignmentExpression = exports.ConditionalExpression = function (node, parent) {
if (t.isUnaryLike(parent)) {

@@ -173,2 +154,2 @@ return true;

return false;
};
};
"use strict";
var isBoolean = require("lodash/lang/isBoolean");
var each = require("lodash/collection/each");
var map = require("lodash/collection/map");
var t = require("../../types");
var each = require("lodash/collection/each");
var map = require("lodash/collection/map");
var t = require("../../types");
var crawl = function (node, state) {
var crawl = (function (_crawl) {
var _crawlWrapper = function crawl() {
return _crawl.apply(this, arguments);
};
_crawlWrapper.toString = function () {
return _crawl.toString();
};
return _crawlWrapper;
})(function (node, state) {
state = state || {};

@@ -27,5 +37,15 @@

return state;
};
});
var isHelper = function (node) {
var isHelper = (function (_isHelper) {
var _isHelperWrapper = function isHelper() {
return _isHelper.apply(this, arguments);
};
_isHelperWrapper.toString = function () {
return _isHelper.toString();
};
return _isHelperWrapper;
})(function (node) {
if (t.isMemberExpression(node)) {

@@ -38,17 +58,16 @@ return isHelper(node.object) || isHelper(node.property);

} else if (t.isBinary(node) || t.isAssignmentExpression(node)) {
return (t.isIdentifier(node.left) && isHelper(node.left)) || isHelper(node.right);
return t.isIdentifier(node.left) && isHelper(node.left) || isHelper(node.right);
} else {
return false;
}
};
});
var isType = function (node) {
return t.isLiteral(node) || t.isObjectExpression(node) || t.isArrayExpression(node) ||
t.isIdentifier(node) || t.isMemberExpression(node);
var isType = function isType(node) {
return t.isLiteral(node) || t.isObjectExpression(node) || t.isArrayExpression(node) || t.isIdentifier(node) || t.isMemberExpression(node);
};
exports.nodes = {
AssignmentExpression: function (node) {
AssignmentExpression: function AssignmentExpression(node) {
var state = crawl(node.right);
if ((state.hasCall && state.hasHelper) || state.hasFunction) {
if (state.hasCall && state.hasHelper || state.hasFunction) {
return {

@@ -61,3 +80,3 @@ before: state.hasFunction,

SwitchCase: function (node, parent) {
SwitchCase: function SwitchCase(node, parent) {
return {

@@ -68,3 +87,3 @@ before: node.consequent.length || parent.cases[0] === node

LogicalExpression: function (node) {
LogicalExpression: function LogicalExpression(node) {
if (t.isFunction(node.left) || t.isFunction(node.right)) {

@@ -77,3 +96,3 @@ return {

Literal: function (node) {
Literal: function Literal(node) {
if (node.value === "use strict") {

@@ -86,3 +105,3 @@ return {

CallExpression: function (node) {
CallExpression: function CallExpression(node) {
if (t.isFunction(node.callee) || isHelper(node)) {

@@ -96,3 +115,3 @@ return {

VariableDeclaration: function (node) {
VariableDeclaration: function VariableDeclaration(node) {
for (var i = 0; i < node.declarations.length; i++) {

@@ -104,3 +123,3 @@ var declar = node.declarations[i];

var state = crawl(declar.init);
enabled = (isHelper(declar.init) && state.hasCall) || state.hasFunction;
enabled = isHelper(declar.init) && state.hasCall || state.hasFunction;
}

@@ -117,3 +136,3 @@

IfStatement: function (node) {
IfStatement: function IfStatement(node) {
if (t.isBlockStatement(node.consequent)) {

@@ -128,4 +147,3 @@ return {

exports.nodes.Property =
exports.nodes.SpreadProperty = function (node, parent) {
exports.nodes.Property = exports.nodes.SpreadProperty = function (node, parent) {
if (parent.properties[0] === node) {

@@ -139,11 +157,11 @@ return {

exports.list = {
VariableDeclaration: function (node) {
VariableDeclaration: function VariableDeclaration(node) {
return map(node.declarations, "init");
},
ArrayExpression: function (node) {
ArrayExpression: function ArrayExpression(node) {
return node.elements;
},
ObjectExpression: function (node) {
ObjectExpression: function ObjectExpression(node) {
return node.properties;

@@ -170,2 +188,2 @@ }

});
});
});

@@ -29,2 +29,2 @@ "use strict";

}
};
};

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

var sourceMap = require("source-map");
var t = require("../types");
var t = require("../types");
function SourceMap(position, opts, code) {
this.position = position;
this.opts = opts;
this.opts = opts;

@@ -57,2 +57,2 @@ if (opts.sourceMap) {

});
};
};

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

this.tokens = sortBy(tokens.concat(comments), "start");
this.used = {};
this.used = {};

@@ -105,3 +105,3 @@ // Profiling this code shows that while generator passes over it, indexes

var start = startToken ? startToken.loc.end.line : 1;
var end = endToken.loc.start.line;
var end = endToken.loc.start.line;
var lines = 0;

@@ -117,2 +117,2 @@

return lines;
};
};

@@ -0,21 +1,23 @@

"use strict";
var lineNumbers = require("line-numbers");
var repeating = require("repeating");
var jsTokens = require("js-tokens");
var esutils = require("esutils");
var chalk = require("chalk");
var ary = require("lodash/function/ary");
var repeating = require("repeating");
var jsTokens = require("js-tokens");
var esutils = require("esutils");
var chalk = require("chalk");
var ary = require("lodash/function/ary");
var defs = {
string: chalk.red,
string: chalk.red,
punctuation: chalk.white.bold,
operator: chalk.white.bold,
curly: chalk.green,
parens: chalk.blue.bold,
square: chalk.yellow,
name: chalk.white,
keyword: chalk.cyan,
number: chalk.magenta,
regex: chalk.magenta,
comment: chalk.grey,
invalid: chalk.inverse
operator: chalk.white.bold,
curly: chalk.green,
parens: chalk.blue.bold,
square: chalk.yellow,
name: chalk.white,
keyword: chalk.cyan,
number: chalk.magenta,
regex: chalk.magenta,
comment: chalk.grey,
invalid: chalk.inverse
};

@@ -25,4 +27,4 @@

var highlight = function (text) {
var tokenType = function (match) {
var highlight = function highlight(text) {
var tokenType = function tokenType(match) {
var token = jsTokens.matchToToken(match);

@@ -70,3 +72,3 @@ if (token.type === "name" && esutils.keyword.isKeywordES6(token.value)) {

var start = Math.max(lineNumber - 3, 0);
var end = Math.min(lines.length, lineNumber + 3);
var end = Math.min(lines.length, lineNumber + 3);

@@ -82,3 +84,3 @@ if (!lineNumber && !colNumber) {

after: " | ",
transform: function (params) {
transform: function transform(params) {
if (params.number !== lineNumber) {

@@ -88,4 +90,3 @@ return;

if (colNumber) {
params.line += "\n" + params.before + repeating(" ", params.width) +
params.after + repeating(" ", colNumber - 1) + "^";
params.line += "\n" + params.before + repeating(" ", params.width) + params.after + repeating(" ", colNumber - 1) + "^";
}

@@ -95,2 +96,2 @@ params.before = params.before.replace(/^./, ">");

}).join("\n");
};
};

@@ -0,1 +1,3 @@

"use strict";
var t = require("../types");

@@ -9,2 +11,2 @@

}
};
};

@@ -5,2 +5,2 @@ "use strict";

return Object.create(null);
};
};

@@ -0,5 +1,7 @@

"use strict";
var normalizeAst = require("./normalize-ast");
var estraverse = require("estraverse");
var codeFrame = require("./code-frame");
var acorn = require("acorn-babel");
var estraverse = require("estraverse");
var codeFrame = require("./code-frame");
var acorn = require("acorn-babel");

@@ -9,14 +11,14 @@ module.exports = function (opts, code, callback) {

var comments = [];
var tokens = [];
var tokens = [];
var ast = acorn.parse(code, {
allowImportExportEverywhere: opts.allowImportExportEverywhere,
allowReturnOutsideFunction: !opts._anal,
ecmaVersion: opts.experimental ? 7 : 6,
playground: opts.playground,
strictMode: opts.strictMode,
onComment: comments,
locations: true,
onToken: tokens,
ranges: true
allowReturnOutsideFunction: !opts._anal,
ecmaVersion: opts.experimental ? 7 : 6,
playground: opts.playground,
strictMode: opts.strictMode,
onComment: comments,
locations: true,
onToken: tokens,
ranges: true
});

@@ -50,2 +52,2 @@

}
};
};

@@ -17,2 +17,2 @@ "use strict";

eval(obj);
};
};

@@ -0,1 +1,3 @@

"use strict";
var util = require("util");

@@ -51,2 +53,2 @@

});
};
};
"use strict";
var extend = require("lodash/object/extend");
var t = require("./types");
var t = require("./types");

@@ -14,53 +14,24 @@ // estraverse

var types = require("ast-types");
var def = types.Type.def;
var or = types.Type.or;
var def = types.Type.def;
var or = types.Type.or;
def("File")
.bases("Node")
.build("program")
.field("program", def("Program"));
def("File").bases("Node").build("program").field("program", def("Program"));
def("AssignmentPattern")
.bases("Pattern")
.build("left", "right")
.field("left", def("Pattern"))
.field("right", def("Expression"));
def("AssignmentPattern").bases("Pattern").build("left", "right").field("left", def("Pattern")).field("right", def("Expression"));
// Acorn - Same as ImportNamespaceSpecifier but `id` is `name`
def("ImportBatchSpecifier")
.bases("Specifier")
.build("name")
.field("name", def("Identifier"));
def("ImportBatchSpecifier").bases("Specifier").build("name").field("name", def("Identifier"));
def("RestElement")
.bases("Pattern")
.build("argument")
.field("argument", def("expression"));
def("RestElement").bases("Pattern").build("argument").field("argument", def("expression"));
// Abstract references
def("VirtualPropertyExpression")
.bases("Expression")
.build("object", "property")
.field("object", def("Expression"))
.field("property", or(def("Identifier"), def("Expression")));
def("VirtualPropertyExpression").bases("Expression").build("object", "property").field("object", def("Expression")).field("property", or(def("Identifier"), def("Expression")));
def("PrivateDeclaration")
.bases("Declaration")
.build("declarations")
.field("declarations", [def("Identifier")]);
def("PrivateDeclaration").bases("Declaration").build("declarations").field("declarations", [def("Identifier")]);
// Playground
def("BindMemberExpression")
.bases("Expression")
.build("object", "property", "arguments")
.field("object", def("Expression"))
.field("property", or(def("Identifier"), def("Expression")))
.field("arguments", [def("Expression")]);
def("BindMemberExpression").bases("Expression").build("object", "property", "arguments").field("object", def("Expression")).field("property", or(def("Identifier"), def("Expression"))).field("arguments", [def("Expression")]);
def("BindFunctionExpression")
.bases("Expression")
.build("callee", "arguments")
.field("callee", def("Expression"))
.field("arguments", [def("Expression")]);
def("BindFunctionExpression").bases("Expression").build("callee", "arguments").field("callee", def("Expression")).field("arguments", [def("Expression")]);
types.finalize();
types.finalize();

@@ -9,2 +9,2 @@ "use strict";

require("core-js/shim");
require("regenerator-babel/runtime");
require("regenerator-babel/runtime");

@@ -6,29 +6,29 @@ "use strict";

var sourceMapToComment = require("source-map-to-comment");
var shebangRegex = require("shebang-regex");
var isFunction = require("lodash/lang/isFunction");
var transform = require("./index");
var generate = require("../generation");
var defaults = require("lodash/object/defaults");
var includes = require("lodash/collection/includes");
var assign = require("lodash/object/assign");
var parse = require("../helpers/parse");
var Scope = require("../traversal/scope");
var slash = require("slash");
var util = require("../util");
var path = require("path");
var each = require("lodash/collection/each");
var t = require("../types");
var shebangRegex = require("shebang-regex");
var isFunction = require("lodash/lang/isFunction");
var transform = require("./index");
var generate = require("../generation");
var defaults = require("lodash/object/defaults");
var includes = require("lodash/collection/includes");
var assign = require("lodash/object/assign");
var parse = require("../helpers/parse");
var Scope = require("../traversal/scope");
var slash = require("slash");
var util = require("../util");
var path = require("path");
var each = require("lodash/collection/each");
var t = require("../types");
function File(opts) {
this.dynamicImportedNoDefault = [];
this.dynamicImportIds = {};
this.dynamicImported = [];
this.dynamicImports = [];
this.dynamicImportIds = {};
this.dynamicImported = [];
this.dynamicImports = [];
this.dynamicData = {};
this.data = {};
this.dynamicData = {};
this.data = {};
this.lastStatements = [];
this.opts = this.normalizeOptions(opts);
this.ast = {};
this.lastStatements = [];
this.opts = this.normalizeOptions(opts);
this.ast = {};

@@ -38,69 +38,12 @@ this.buildTransformers();

File.helpers = [
"inherits",
"defaults",
"prototype-properties",
"apply-constructor",
"tagged-template-literal",
"tagged-template-literal-loose",
"interop-require",
"to-array",
"to-consumable-array",
"sliced-to-array",
"object-without-properties",
"has-own",
"slice",
"bind",
"define-property",
"async-to-generator",
"interop-require-wildcard",
"typeof",
"extends",
"get",
"set",
"class-call-check",
"object-destructuring-empty",
"temporal-undefined",
"temporal-assert-defined",
"self-global"
];
File.helpers = ["inherits", "defaults", "prototype-properties", "apply-constructor", "tagged-template-literal", "tagged-template-literal-loose", "interop-require", "to-array", "to-consumable-array", "sliced-to-array", "object-without-properties", "has-own", "slice", "bind", "define-property", "async-to-generator", "interop-require-wildcard", "typeof", "extends", "get", "set", "class-call-check", "object-destructuring-empty", "temporal-undefined", "temporal-assert-defined", "self-global"];
File.validOptions = [
"filename",
"filenameRelative",
"blacklist",
"whitelist",
"loose",
"optional",
"modules",
"sourceMap",
"sourceMapName",
"sourceFileName",
"sourceRoot",
"moduleRoot",
"moduleIds",
"comments",
"reactCompat",
"keepModuleIdExtensions",
"code",
"ast",
"playground",
"experimental",
"externalHelpers",
"auxiliaryComment",
"compact",
File.validOptions = ["filename", "filenameRelative", "blacklist", "whitelist", "loose", "optional", "modules", "sourceMap", "sourceMapName", "sourceFileName", "sourceRoot", "moduleRoot", "moduleIds", "comments", "reactCompat", "keepModuleIdExtensions", "code", "ast", "playground", "experimental", "externalHelpers", "auxiliaryComment", "compact", "resolveModuleSource", "moduleId",
"resolveModuleSource",
"moduleId",
// legacy
"format",
// legacy
"format",
// these are used by plugins
"ignore", "only", "extensions", "accept"];
// these are used by plugins
"ignore",
"only",
"extensions",
"accept"
];
File.prototype.normalizeOptions = function (opts) {

@@ -117,20 +60,20 @@ opts = assign({}, opts);

keepModuleIdExtensions: false,
resolveModuleSource: null,
externalHelpers: false,
auxilaryComment: "",
experimental: false,
reactCompat: false,
playground: false,
moduleIds: false,
blacklist: [],
whitelist: [],
sourceMap: false,
optional: [],
comments: true,
filename: "unknown",
modules: "common",
compact: "auto",
loose: [],
code: true,
ast: true
resolveModuleSource: null,
externalHelpers: false,
auxilaryComment: "",
experimental: false,
reactCompat: false,
playground: false,
moduleIds: false,
blacklist: [],
whitelist: [],
sourceMap: false,
optional: [],
comments: true,
filename: "unknown",
modules: "common",
compact: "auto",
loose: [],
code: true,
ast: true
});

@@ -152,5 +95,5 @@

opts.whitelist = util.arrayify(opts.whitelist);
opts.optional = util.arrayify(opts.optional);
opts.compact = util.booleanify(opts.compact);
opts.loose = util.arrayify(opts.loose);
opts.optional = util.arrayify(opts.optional);
opts.compact = util.booleanify(opts.compact);
opts.loose = util.arrayify(opts.loose);

@@ -175,3 +118,3 @@ if (includes(opts.loose, "all") || includes(opts.loose, true)) {

sourceFileName: opts.filenameRelative,
sourceMapName: opts.filenameRelative
sourceMapName: opts.filenameRelative
});

@@ -189,4 +132,4 @@

opts.whitelist = transform._ensureTransformerNames("whitelist", opts.whitelist);
opts.optional = transform._ensureTransformerNames("optional", opts.optional);
opts.loose = transform._ensureTransformerNames("loose", opts.loose);
opts.optional = transform._ensureTransformerNames("optional", opts.optional);
opts.loose = transform._ensureTransformerNames("loose", opts.loose);

@@ -198,3 +141,3 @@ if (opts.reactCompat) {

var ensureEnabled = function (key) {
var ensureEnabled = function ensureEnabled(key) {
var namespace = transform.transformerNamespaces[key];

@@ -360,5 +303,3 @@ if (namespace === "es7") opts.experimental = true;

File.prototype.logDeopt = function () {
// todo, (node, msg)
};
File.prototype.logDeopt = function () {};

@@ -381,3 +322,3 @@ File.prototype.errorWithNode = function (node, msg, Error) {

File.prototype.parse = function (code) {
var self = this;
var _this = this;

@@ -392,4 +333,4 @@ code = this.addCode(code);

return parse(opts, code, function (tree) {
self.transform(tree);
return self.generate();
_this.transform(tree);
return _this.generate();
});

@@ -432,3 +373,3 @@ };

var checkTransformerVisitor = {
enter: function (node, parent, scope, state) {
enter: function enter(node, parent, scope, state) {
checkNode(state.stack, node, scope);

@@ -438,3 +379,3 @@ }

var checkNode = function (stack, node, scope) {
var checkNode = function checkNode(stack, node, scope) {
each(stack, function (pass) {

@@ -459,3 +400,3 @@ if (pass.shouldRun) return;

var opts = this.opts;
var ast = this.ast;
var ast = this.ast;

@@ -473,3 +414,3 @@ var result = {

result.code = _result.code;
result.map = _result.map;
result.map = _result.map;

@@ -488,1 +429,3 @@ if (this.shebang) {

};
// todo, (node, msg)
"use strict";
var explode = require("./explode-assignable-expression");
var t = require("../../types");
var t = require("../../types");
module.exports = function (exports, opts) {
var isAssignment = function (node) {
var isAssignment = function isAssignment(node) {
return node.operator === opts.operator + "=";
};
var buildAssignment = function (left, right) {
var buildAssignment = function buildAssignment(left, right) {
return t.assignmentExpression("=", left, right);

@@ -22,8 +22,6 @@ };

var nodes = [];
var nodes = [];
var exploded = explode(expr.left, nodes, file, scope, true);
nodes.push(t.expressionStatement(
buildAssignment(exploded.ref, opts.build(exploded.uid, expr.right))
));
nodes.push(t.expressionStatement(buildAssignment(exploded.ref, opts.build(exploded.uid, expr.right))));

@@ -36,3 +34,3 @@ return nodes;

var nodes = [];
var nodes = [];
var exploded = explode(node.left, nodes, file, scope);

@@ -48,2 +46,2 @@ nodes.push(buildAssignment(exploded.ref, opts.build(exploded.uid, node.right)));

};
};
};

@@ -20,7 +20,3 @@ "use strict";

return t.forOfStatement(
t.variableDeclaration("let", [t.variableDeclarator(self.left)]),
self.right,
t.blockStatement([child])
);
};
return t.forOfStatement(t.variableDeclaration("let", [t.variableDeclarator(self.left)]), self.right, t.blockStatement([child]));
};
"use strict";
var explode = require("./explode-assignable-expression");
var t = require("../../types");
var t = require("../../types");
module.exports = function (exports, opts) {
var buildAssignment = function (left, right) {
var buildAssignment = function buildAssignment(left, right) {
return t.assignmentExpression("=", left, right);

@@ -22,6 +22,3 @@ };

nodes.push(t.ifStatement(
opts.build(exploded.uid, file),
t.expressionStatement(buildAssignment(exploded.ref, expr.right))
));
nodes.push(t.ifStatement(opts.build(exploded.uid, file), t.expressionStatement(buildAssignment(exploded.ref, expr.right))));

@@ -34,10 +31,6 @@ return nodes;

var nodes = [];
var nodes = [];
var exploded = explode(node.left, nodes, file, scope);
nodes.push(t.logicalExpression(
"&&",
opts.build(exploded.uid, file),
buildAssignment(exploded.ref, node.right)
));
nodes.push(t.logicalExpression("&&", opts.build(exploded.uid, file), buildAssignment(exploded.ref, node.right)));

@@ -49,2 +42,2 @@ // todo: duplicate expression node

};
};
};

@@ -10,5 +10,5 @@ "use strict";

var messages = require("../../messages");
var esutils = require("esutils");
var react = require("./react");
var t = require("../../types");
var esutils = require("esutils");
var react = require("./react");
var t = require("../../types");

@@ -37,3 +37,3 @@ module.exports = function (exports, opts) {

exports.JSXMemberExpression = {
exit: function (node) {
exit: function exit(node) {
node.computed = t.isLiteral(node.property);

@@ -49,3 +49,3 @@ node.type = "MemberExpression";

exports.JSXAttribute = {
enter: function (node) {
enter: function enter(node) {
var value = node.value;

@@ -57,3 +57,3 @@ if (t.isLiteral(value) && isString(value.value)) {

exit: function (node) {
exit: function exit(node) {
var value = node.value || t.literal(true);

@@ -65,3 +65,3 @@ return t.inherits(t.property("init", node.name, value), node);

exports.JSXOpeningElement = {
exit: function (node, parent, scope, file) {
exit: function exit(node, parent, scope, file) {
var tagExpr = node.name;

@@ -80,3 +80,3 @@ var args = [];

tagName: tagName,
args: args
args: args
};

@@ -112,7 +112,7 @@

var buildJSXOpeningElementAttributes = function (attribs, file) {
var buildJSXOpeningElementAttributes = function buildJSXOpeningElementAttributes(attribs, file) {
var _props = [];
var objs = [];
var pushProps = function () {
var pushProps = function pushProps() {
if (!_props.length) return;

@@ -146,6 +146,3 @@

// spread it
attribs = t.callExpression(
file.addHelper("extends"),
objs
);
attribs = t.callExpression(file.addHelper("extends"), objs);
}

@@ -157,3 +154,3 @@

exports.JSXElement = {
exit: function (node) {
exit: function exit(node) {
var callExpr = node.openingElement;

@@ -184,7 +181,7 @@

var isStringLiteral = function (node) {
var isStringLiteral = function isStringLiteral(node) {
return t.isLiteral(node) && isString(node.value);
};
var flatten = function (args) {
var flatten = function flatten(args) {
var flattened = [];

@@ -206,3 +203,3 @@ var last;

var cleanJSXElementLiteralChild = function (child, args) {
var cleanJSXElementLiteralChild = function cleanJSXElementLiteralChild(child, args) {
var lines = child.value.split(/\r\n|\n|\r/);

@@ -251,3 +248,3 @@

var addDisplayName = function (id, call) {
var addDisplayName = function addDisplayName(id, call) {
var props = call.arguments[0].properties;

@@ -270,3 +267,3 @@ var safe = true;

exports.ExportDeclaration = function (node, parent, scope, file) {
if (node.default && react.isCreateClass(node.declaration)) {
if (node["default"] && react.isCreateClass(node.declaration)) {
addDisplayName(file.opts.basename, node.declaration);

@@ -276,5 +273,3 @@ }

exports.AssignmentExpression =
exports.Property =
exports.VariableDeclarator = function (node) {
exports.AssignmentExpression = exports.Property = exports.VariableDeclarator = function (node) {
var left, right;

@@ -301,2 +296,2 @@

};
};
};

@@ -0,7 +1,9 @@

"use strict";
var cloneDeep = require("lodash/lang/cloneDeep");
var traverse = require("../../traversal");
var clone = require("lodash/lang/clone");
var each = require("lodash/collection/each");
var has = require("lodash/object/has");
var t = require("../../types");
var traverse = require("../../traversal");
var clone = require("lodash/lang/clone");
var each = require("lodash/collection/each");
var has = require("lodash/object/has");
var t = require("../../types");

@@ -73,2 +75,2 @@ exports.push = function (mutatorMap, key, kind, computed, value) {

return objExpr;
};
};

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

var getObjRef = function (node, nodes, file, scope) {
var getObjRef = function getObjRef(node, nodes, file, scope) {
var ref;

@@ -33,9 +33,7 @@ if (t.isIdentifier(node)) {

var temp = scope.generateUidBasedOnNode(ref);
nodes.push(t.variableDeclaration("var", [
t.variableDeclarator(temp, ref)
]));
nodes.push(t.variableDeclaration("var", [t.variableDeclarator(temp, ref)]));
return temp;
};
var getPropRef = function (node, nodes, file, scope) {
var getPropRef = function getPropRef(node, nodes, file, scope) {
var prop = node.property;

@@ -46,5 +44,3 @@ var key = t.toComputedKey(node, prop);

var temp = scope.generateUidBasedOnNode(prop);
nodes.push(t.variableDeclaration("var", [
t.variableDeclarator(temp, prop)
]));
nodes.push(t.variableDeclaration("var", [t.variableDeclarator(temp, prop)]));
return temp;

@@ -76,2 +72,2 @@ };

};
};
};
"use strict";
var util = require("../../util");
var t = require("../../types");
var t = require("../../types");
var visitor = {
enter: function (node, parent, scope, state) {
enter: function enter(node, parent, scope, state) {
// check if this node is a referenced identifier that matches the same as our

@@ -22,3 +22,3 @@ // function id

var wrap = function (state, method, id, scope) {
var wrap = function wrap(state, method, id, scope) {
if (state.selfReference) {

@@ -39,10 +39,9 @@ var templateName = "property-method-assignment-wrapper";

var visit = function (node, name, scope) {
var visit = function visit(node, name, scope) {
var state = {
selfAssignment: false,
selfReference: false,
outerDeclar: scope.getBindingIdentifier(name),
references: [],
name: name,
};
selfReference: false,
outerDeclar: scope.getBindingIdentifier(name),
references: [],
name: name };

@@ -69,12 +68,3 @@ // check to see if we have a local binding of the id we're setting inside of

state.selfReference = true;
} else {
// otherwise it's defined somewhere in scope like:
//
// var t = function () {
// var t = 2;
// };
//
// so we can safely just set the id and move along as it shadows the
// bound function id
}
} else {}
} else {

@@ -95,3 +85,3 @@ scope.traverse(node, visitor, state);

var method = node.value;
var state = visit(method, name, scope);
var state = visit(method, name, scope);
node.value = wrap(state, method, id, scope);

@@ -123,1 +113,10 @@ };

};
// otherwise it's defined somewhere in scope like:
//
// var t = function () {
// var t = 2;
// };
//
// so we can safely just set the id and move along as it shadows the
// bound function id

@@ -0,1 +1,3 @@

"use strict";
var t = require("../../types");

@@ -26,2 +28,2 @@

return tagName && /^[a-z]|\-/.test(tagName);
};
};

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

var visitor = {
enter: function (node) {
enter: function enter(node) {
if (t.isFunction(node)) this.skip();

@@ -33,5 +33,3 @@

if (t.isFunctionDeclaration(node)) {
var declar = t.variableDeclaration("let", [
t.variableDeclarator(id, call)
]);
var declar = t.variableDeclaration("let", [t.variableDeclarator(id, call)]);
declar._blockHoist = true;

@@ -42,2 +40,2 @@ return declar;

}
};
};

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

var messages = require("../../messages");
var t = require("../../types");
var t = require("../../types");

@@ -18,11 +18,11 @@ /**

this.topLevelThisReference = opts.topLevelThisReference;
this.methodNode = opts.methodNode;
this.className = opts.className;
this.superName = opts.superName;
this.isStatic = opts.isStatic;
this.hasSuper = false;
this.inClass = inClass;
this.isLoose = opts.isLoose;
this.scope = opts.scope;
this.file = opts.file;
this.methodNode = opts.methodNode;
this.className = opts.className;
this.superName = opts.superName;
this.isStatic = opts.isStatic;
this.hasSuper = false;
this.inClass = inClass;
this.isLoose = opts.isLoose;
this.scope = opts.scope;
this.file = opts.file;
}

@@ -46,16 +46,3 @@

ReplaceSupers.prototype.setSuperProperty = function (property, value, isComputed, thisExpression) {
return t.callExpression(
this.file.addHelper("set"),
[
t.callExpression(
t.memberExpression(t.identifier("Object"), t.identifier("getPrototypeOf")),
[
this.isStatic ? this.className : t.memberExpression(this.className, t.identifier("prototype"))
]
),
isComputed ? property : t.literal(property.name),
value,
thisExpression
]
);
return t.callExpression(this.file.addHelper("set"), [t.callExpression(t.memberExpression(t.identifier("Object"), t.identifier("getPrototypeOf")), [this.isStatic ? this.className : t.memberExpression(this.className, t.identifier("prototype"))]), isComputed ? property : t.literal(property.name), value, thisExpression]);
};

@@ -78,15 +65,3 @@

ReplaceSupers.prototype.getSuperProperty = function (property, isComputed, thisExpression) {
return t.callExpression(
this.file.addHelper("get"),
[
t.callExpression(
t.memberExpression(t.identifier("Object"), t.identifier("getPrototypeOf")),
[
this.isStatic ? this.className : t.memberExpression(this.className, t.identifier("prototype"))
]
),
isComputed ? property : t.literal(property.name),
thisExpression
]
);
return t.callExpression(this.file.addHelper("get"), [t.callExpression(t.memberExpression(t.identifier("Object"), t.identifier("getPrototypeOf")), [this.isStatic ? this.className : t.memberExpression(this.className, t.identifier("prototype"))]), isComputed ? property : t.literal(property.name), thisExpression]);
};

@@ -103,3 +78,3 @@

var visitor = {
enter: function (node, parent, scope, state) {
enter: function enter(node, parent, scope, state) {
var topLevel = state.topLevel;

@@ -120,6 +95,6 @@ var self = state.self;

var getThisReference = topLevel ?
// top level so `this` is the instance
t.thisExpression :
// not in the top level so we need to create a reference
self.getThisReference.bind(self);
// top level so `this` is the instance
t.thisExpression :
// not in the top level so we need to create a reference
self.getThisReference.bind(self);

@@ -153,5 +128,3 @@ var callback = self.specHandle;

var ref = this.topLevelThisReference = this.scope.generateUidIdentifier("this");
this.methodNode.value.body.body.unshift(t.variableDeclaration("var", [
t.variableDeclarator(this.topLevelThisReference, t.thisExpression())
]));
this.methodNode.value.body.body.unshift(t.variableDeclaration("var", [t.variableDeclarator(this.topLevelThisReference, t.thisExpression())]));
return ref;

@@ -173,3 +146,3 @@ }

var methodName = methodNode.key;
var superName = this.superName || t.identifier("Function");
var superName = this.superName || t.identifier("Function");

@@ -189,3 +162,3 @@ if (parent.property === id) {

// foo() { super(); }
if (!methodNode.static) {
if (!methodNode["static"]) {
id = t.memberExpression(id, t.identifier("prototype"));

@@ -197,3 +170,3 @@ }

}
} else if (t.isMemberExpression(parent) && !methodNode.static) {
} else if (t.isMemberExpression(parent) && !methodNode["static"]) {
// super.test -> ClassName.prototype.test

@@ -289,11 +262,5 @@ return t.memberExpression(superName, t.identifier("prototype"));

// super(...arguments);
return t.callExpression(
t.memberExpression(superProperty, t.identifier("apply")),
[thisReference, args[0].argument]
);
return t.callExpression(t.memberExpression(superProperty, t.identifier("apply")), [thisReference, args[0].argument]);
} else {
return t.callExpression(
t.memberExpression(superProperty, t.identifier("call")),
[thisReference].concat(args)
);
return t.callExpression(t.memberExpression(superProperty, t.identifier("call")), [thisReference].concat(args));
}

@@ -305,3 +272,3 @@ } else {

var isIllegalBareSuper = function (node, parent) {
var isIllegalBareSuper = function isIllegalBareSuper(node, parent) {
if (!isSuper(node, parent)) return false;

@@ -313,4 +280,4 @@ if (t.isMemberExpression(parent, { computed: false })) return false;

var isSuper = function (node, parent) {
var isSuper = function isSuper(node, parent) {
return t.isIdentifier(node, { name: "super" }) && t.isReferenced(node, parent);
};
};

@@ -21,2 +21,2 @@ "use strict";

}
};
};

@@ -6,6 +6,6 @@ "use strict";

var normalizeAst = require("../helpers/normalize-ast");
var Transformer = require("./transformer");
var object = require("../helpers/object");
var File = require("./file");
var each = require("lodash/collection/each");
var Transformer = require("./transformer");
var object = require("../helpers/object");
var File = require("./file");
var each = require("lodash/collection/each");

@@ -53,4 +53,4 @@ function transform(code, opts) {

transform.transformerNamespaces = object();
transform.transformers = object();
transform.namespaces = object();
transform.transformers = object();
transform.namespaces = object();

@@ -70,2 +70,2 @@ transform.deprecatedTransformerMap = require("./transformers/deprecated");

transform.transformers[key] = new Transformer(key, transformer);
});
});

@@ -6,11 +6,11 @@ "use strict";

var messages = require("../../messages");
var extend = require("lodash/object/extend");
var object = require("../../helpers/object");
var util = require("../../util");
var t = require("../../types");
var extend = require("lodash/object/extend");
var object = require("../../helpers/object");
var util = require("../../util");
var t = require("../../types");
function DefaultFormatter(file) {
this.scope = file.scope;
this.file = file;
this.ids = object();
this.file = file;
this.ids = object();

@@ -33,3 +33,3 @@ this.hasNonDefaultExports = false;

DefaultFormatter.prototype.doDefaultExportInterop = function (node) {
return node.default && !this.noInteropRequireExport && !this.hasNonDefaultExports;
return node["default"] && !this.noInteropRequireExport && !this.hasNonDefaultExports;
};

@@ -45,3 +45,3 @@

var exportsVisitor = {
enter: function (node, parent, scope, formatter) {
enter: function enter(node, parent, scope, formatter) {
var declar = node && node.declaration;

@@ -55,3 +55,3 @@ if (t.isExportDeclaration(node)) {

if (!node.default) {
if (!node["default"]) {
formatter.hasNonDefaultExports = true;

@@ -72,3 +72,3 @@ }

var importsVisitor = {
enter: function (node, parent, scope, formatter) {
enter: function enter(node, parent, scope, formatter) {
if (t.isImportDeclaration(node)) {

@@ -87,3 +87,3 @@ formatter.hasLocalImports = true;

var remapVisitor = {
enter: function (node, parent, scope, formatter) {
enter: function enter(node, parent, scope, formatter) {
if (t.isUpdateExpression(node) && formatter.isLocalReference(node.argument, scope)) {

@@ -109,3 +109,4 @@ this.skip();

operator = "+";
} else { // "++"
} else {
// "++"
operator = "-";

@@ -137,11 +138,3 @@ }

DefaultFormatter.prototype.remapExportAssignment = function (node) {
return t.assignmentExpression(
"=",
node.left,
t.assignmentExpression(
node.operator,
t.memberExpression(t.identifier("exports"), node.left),
node.right
)
);
return t.assignmentExpression("=", node.left, t.assignmentExpression(node.operator, t.memberExpression(t.identifier("exports"), node.left), node.right));
};

@@ -172,3 +165,3 @@

// remove sourceRoot from filename
var sourceRootRegEx = new RegExp("^" + opts.sourceRoot + "\/?");
var sourceRootRegEx = new RegExp("^" + opts.sourceRoot + "/?");
filenameRelative = filenameRelative.replace(sourceRootRegEx, "");

@@ -242,7 +235,3 @@ }

// export { foo } from "test";
nodes.push(this.buildExportsAssignment(
t.getSpecifierName(specifier),
ref,
node
));
nodes.push(this.buildExportsAssignment(t.getSpecifierName(specifier), ref, node));
}

@@ -256,6 +245,3 @@ } else {

DefaultFormatter.prototype.buildExportsWildcard = function (objectIdentifier) {
return t.expressionStatement(t.callExpression(this.file.addHelper("defaults"), [
t.identifier("exports"),
t.callExpression(this.file.addHelper("interop-require-wildcard"), [objectIdentifier])
]));
return t.expressionStatement(t.callExpression(this.file.addHelper("defaults"), [t.identifier("exports"), t.callExpression(this.file.addHelper("interop-require-wildcard"), [objectIdentifier])]));
};

@@ -267,3 +253,3 @@

VALUE: init,
KEY: id
KEY: id
}, true);

@@ -277,3 +263,3 @@ };

if (node.default) {
if (node["default"]) {
id = t.identifier("default");

@@ -308,2 +294,2 @@ }

}
};
};

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

module.exports = function (Parent) {
var Constructor = function () {
var Constructor = function Constructor() {
this.noInteropRequireImport = true;

@@ -16,2 +16,2 @@ this.noInteropRequireExport = true;

return Constructor;
};
};
"use strict";
module.exports = require("./_strict")(require("./amd"));
module.exports = require("./_strict")(require("./amd"));

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

var DefaultFormatter = require("./_default");
var CommonFormatter = require("./common");
var includes = require("lodash/collection/includes");
var values = require("lodash/object/values");
var util = require("../../util");
var t = require("../../types");
var CommonFormatter = require("./common");
var includes = require("lodash/collection/includes");
var values = require("lodash/object/values");
var util = require("../../util");
var t = require("../../types");

@@ -88,5 +88,3 @@ function AMDFormatter() {

this.ids[node.source.value] = ref;
} else if (t.isImportBatchSpecifier(specifier)) {
// import * as bar from "foo";
} else if (!includes(this.file.dynamicImported, node) && t.isSpecifierDefault(specifier) && !this.noInteropRequireImport) {
} else if (t.isImportBatchSpecifier(specifier)) {} else if (!includes(this.file.dynamicImported, node) && t.isSpecifierDefault(specifier) && !this.noInteropRequireImport) {
// import foo from "foo";

@@ -99,5 +97,3 @@ ref = t.callExpression(this.file.addHelper("interop-require"), [ref]);

nodes.push(t.variableDeclaration("var", [
t.variableDeclarator(key, ref)
]));
nodes.push(t.variableDeclaration("var", [t.variableDeclarator(key, ref)]));
};

@@ -112,1 +108,3 @@

};
// import * as bar from "foo";
"use strict";
module.exports = require("./_strict")(require("./common"));
module.exports = require("./_strict")(require("./common"));

@@ -6,5 +6,5 @@ "use strict";

var DefaultFormatter = require("./_default");
var includes = require("lodash/collection/includes");
var util = require("../../util");
var t = require("../../types");
var includes = require("lodash/collection/includes");
var util = require("../../util");
var t = require("../../types");

@@ -18,3 +18,3 @@ function CommonJSFormatter() {

CommonJSFormatter.prototype.init = function () {
var file = this.file;
var file = this.file;
var scope = file.scope;

@@ -54,13 +54,6 @@

// import * as bar from "foo";
nodes.push(t.variableDeclaration("var", [
t.variableDeclarator(variableName, ref)
]));
nodes.push(t.variableDeclaration("var", [t.variableDeclarator(variableName, ref)]));
} else {
// import { foo } from "foo";
nodes.push(t.variableDeclaration("var", [
t.variableDeclarator(
variableName,
t.memberExpression(ref, t.getSpecifierId(specifier))
)
]));
nodes.push(t.variableDeclaration("var", [t.variableDeclarator(variableName, t.memberExpression(ref, t.getSpecifierId(specifier)))]));
}

@@ -102,5 +95,3 @@ }

var uid = this.scope.generateUidIdentifier(source);
nodes.push(t.variableDeclaration("var", [
t.variableDeclarator(uid, call)
]));
nodes.push(t.variableDeclaration("var", [t.variableDeclarator(uid, call)]));
return uid;

@@ -110,2 +101,2 @@ } else {

}
};
};

@@ -7,6 +7,4 @@ "use strict";

function IgnoreFormatter() {
function IgnoreFormatter() {}
}
IgnoreFormatter.prototype.exportDeclaration = function (node, nodes) {

@@ -17,6 +15,2 @@ var declar = t.toStatement(node.declaration, true);

IgnoreFormatter.prototype.importDeclaration =
IgnoreFormatter.prototype.importSpecifier =
IgnoreFormatter.prototype.exportSpecifier = function () {
};
IgnoreFormatter.prototype.importDeclaration = IgnoreFormatter.prototype.importSpecifier = IgnoreFormatter.prototype.exportSpecifier = function () {};

@@ -0,10 +1,12 @@

"use strict";
module.exports = {
commonStrict: require("./common-strict"),
amdStrict: require("./amd-strict"),
umdStrict: require("./umd-strict"),
common: require("./common"),
system: require("./system"),
ignore: require("./ignore"),
amd: require("./amd"),
umd: require("./umd")
};
amdStrict: require("./amd-strict"),
umdStrict: require("./umd-strict"),
common: require("./common"),
system: require("./system"),
ignore: require("./ignore"),
amd: require("./amd"),
umd: require("./umd")
};

@@ -6,8 +6,8 @@ "use strict";

var DefaultFormatter = require("./_default");
var AMDFormatter = require("./amd");
var util = require("../../util");
var last = require("lodash/array/last");
var each = require("lodash/collection/each");
var map = require("lodash/collection/map");
var t = require("../../types");
var AMDFormatter = require("./amd");
var util = require("../../util");
var last = require("lodash/array/last");
var each = require("lodash/collection/each");
var map = require("lodash/collection/map");
var t = require("../../types");

@@ -33,13 +33,9 @@ function SystemFormatter(file) {

var leftIdentifier = this.scope.generateUidIdentifier("key");
var valIdentifier = t.memberExpression(objectIdentifier, leftIdentifier, true);
var valIdentifier = t.memberExpression(objectIdentifier, leftIdentifier, true);
var left = t.variableDeclaration("var", [
t.variableDeclarator(leftIdentifier)
]);
var left = t.variableDeclaration("var", [t.variableDeclarator(leftIdentifier)]);
var right = objectIdentifier;
var block = t.blockStatement([
t.expressionStatement(this.buildExportCall(leftIdentifier, valIdentifier))
]);
var block = t.blockStatement([t.expressionStatement(this.buildExportCall(leftIdentifier, valIdentifier))]);

@@ -73,3 +69,3 @@ return this._addImportSource(t.forInStatement(left, right, block), node);

var runnerSettersVisitor = {
enter: function (node, parent, scope, state) {
enter: function enter(node, parent, scope, state) {
if (node._importSource === state.source) {

@@ -79,5 +75,3 @@ if (t.isVariableDeclaration(node)) {

state.hoistDeclarators.push(t.variableDeclarator(declar.id));
state.nodes.push(t.expressionStatement(
t.assignmentExpression("=", declar.id, declar.init)
));
state.nodes.push(t.expressionStatement(t.assignmentExpression("=", declar.id, declar.init)));
});

@@ -98,4 +92,4 @@ } else {

var state = {
source: source,
nodes: [],
source: source,
nodes: [],
hoistDeclarators: hoistDeclarators

@@ -111,3 +105,3 @@ };

var hoistVariablesVisitor = {
enter: function (node, parent, scope, hoistDeclarators) {
enter: function enter(node, parent, scope, hoistDeclarators) {
if (t.isFunction(node)) {

@@ -119,3 +113,4 @@ // nothing inside is accessible

if (t.isVariableDeclaration(node)) {
if (node.kind !== "var" && !t.isProgram(parent)) { // let, const
if (node.kind !== "var" && !t.isProgram(parent)) {
// let, const
// can't be accessed

@@ -158,3 +153,3 @@ return;

var hoistFunctionsVisitor = {
enter: function (node, parent, scope, handlerBody) {
enter: function enter(node, parent, scope, handlerBody) {
if (t.isFunction(node)) this.skip();

@@ -204,2 +199,2 @@

program.body = [runner];
};
};
"use strict";
module.exports = require("./_strict")(require("./umd"));
module.exports = require("./_strict")(require("./umd"));

@@ -6,5 +6,5 @@ "use strict";

var AMDFormatter = require("./amd");
var util = require("../../util");
var t = require("../../types");
var values = require("lodash/object/values");
var util = require("../../util");
var t = require("../../types");
var values = require("lodash/object/values");

@@ -29,3 +29,3 @@ function UMDFormatter() {

var ids = values(this.ids);
var ids = values(this.ids);
var args = [t.identifier("exports")];

@@ -47,3 +47,3 @@ if (this.passModuleArg) args.push(t.identifier("module"));

var testExports = util.template("test-exports");
var testModule = util.template("test-module");
var testModule = util.template("test-module");
var commonTests = this.passModuleArg ? t.logicalExpression("&&", testExports, testModule) : testExports;

@@ -76,2 +76,2 @@

program.body = [t.expressionStatement(call)];
};
};

@@ -0,1 +1,3 @@

"use strict";
module.exports = TransformerPass;

@@ -12,5 +14,5 @@

this.transformer = transformer;
this.shouldRun = !transformer.check;
this.handlers = transformer.handlers;
this.file = file;
this.shouldRun = !transformer.check;
this.handlers = transformer.handlers;
this.file = file;
}

@@ -22,3 +24,3 @@

var opts = this.file.opts;
var key = transformer.key;
var key = transformer.key;

@@ -65,2 +67,2 @@ // internal

file.scope.traverse(file.ast, this.handlers, file);
};
};

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

var TransformerPass = require("./transformer-pass");
var isFunction = require("lodash/lang/isFunction");
var traverse = require("../traversal");
var isObject = require("lodash/lang/isObject");
var assign = require("lodash/object/assign");
var each = require("lodash/collection/each");
var isFunction = require("lodash/lang/isFunction");
var traverse = require("../traversal");
var isObject = require("lodash/lang/isObject");
var assign = require("lodash/object/assign");
var each = require("lodash/collection/each");

@@ -22,3 +22,3 @@ /**

var take = function (key) {
var take = function take(key) {
var val = transformer[key];

@@ -30,18 +30,18 @@ delete transformer[key];

this.manipulateOptions = take("manipulateOptions");
this.check = take("check");
this.post = take("post");
this.pre = take("pre");
this.check = take("check");
this.post = take("post");
this.pre = take("pre");
this.experimental = !!take("experimental");
this.playground = !!take("playground");
this.secondPass = !!take("secondPass");
this.optional = !!take("optional");
this.playground = !!take("playground");
this.secondPass = !!take("secondPass");
this.optional = !!take("optional");
this.handlers = this.normalize(transformer);
this.opts = opts || {};
this.key = key;
this.opts = opts || {};
this.key = key;
}
Transformer.prototype.normalize = function (transformer) {
var self = this;
var _this = this;

@@ -57,3 +57,3 @@ if (isFunction(transformer)) {

if (type[0] === "_") {
self[type] = fns;
_this[type] = fns;
return;

@@ -68,4 +68,4 @@ }

if (!fns.enter) fns.enter = function () { };
if (!fns.exit) fns.exit = function () { };
if (!fns.enter) fns.enter = function () {};
if (!fns.exit) fns.exit = function () {};

@@ -80,2 +80,2 @@ transformer[type] = fns;

return new TransformerPass(file, this);
};
};
"use strict";
var defineMap = require("../../helpers/define-map");
var t = require("../../../types");
var t = require("../../../types");

@@ -26,6 +26,3 @@ exports.check = function (node) {

return t.callExpression(
t.memberExpression(t.identifier("Object"), t.identifier("defineProperties")),
[node, defineMap.build(mutatorMap)]
);
};
return t.callExpression(t.memberExpression(t.identifier("Object"), t.identifier("defineProperties")), [node, defineMap.build(mutatorMap)]);
};

@@ -15,2 +15,2 @@ "use strict";

return node;
};
};

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

var visitor = {
enter: function (node, parent, scope, state) {
enter: function enter(node, parent, scope, state) {
if (!t.isReferencedIdentifier(node, parent)) return;

@@ -16,6 +16,3 @@

var assert = t.callExpression(
state.file.addHelper("temporal-assert-defined"),
[node, t.literal(node.name), state.file.addHelper("temporal-undefined")]
);
var assert = t.callExpression(state.file.addHelper("temporal-assert-defined"), [node, t.literal(node.name), state.file.addHelper("temporal-undefined")]);

@@ -35,5 +32,3 @@ this.skip();

exports.Loop =
exports.Program =
exports.BlockStatement = function (node, parent, scope, file) {
exports.Loop = exports.Program = exports.BlockStatement = function (node, parent, scope, file) {
var letRefs = node._letReferences;

@@ -44,6 +39,6 @@ if (!letRefs) return;

letRefs: letRefs,
file: file
file: file
};
scope.traverse(node, visitor, state);
};
};
"use strict";
var traverse = require("../../../traversal");
var object = require("../../../helpers/object");
var util = require("../../../util");
var t = require("../../../types");
var values = require("lodash/object/values");
var extend = require("lodash/object/extend");
var object = require("../../../helpers/object");
var util = require("../../../util");
var t = require("../../../types");
var values = require("lodash/object/values");
var extend = require("lodash/object/extend");

@@ -14,3 +14,3 @@ exports.check = function (node) {

var isLet = function (node, parent) {
var isLet = function isLet(node, parent) {
if (!t.isVariableDeclaration(node)) return false;

@@ -33,11 +33,11 @@ if (node._let) return true;

var isLetInitable = function (node, parent) {
var isLetInitable = function isLetInitable(node, parent) {
return !t.isFor(parent) || !t.isFor(parent, { left: node });
};
var isVar = function (node, parent) {
var isVar = function isVar(node, parent) {
return t.isVariableDeclaration(node, { kind: "var" }) && !isLet(node, parent);
};
var standardizeLets = function (declars) {
var standardizeLets = function standardizeLets(declars) {
for (var i = 0; i < declars.length; i++) {

@@ -80,4 +80,3 @@ delete declars[i]._let;

exports.Program =
exports.BlockStatement = function (block, parent, scope, file) {
exports.Program = exports.BlockStatement = function (block, parent, scope, file) {
if (!t.isLoop(parent)) {

@@ -101,11 +100,11 @@ var blockScoping = new BlockScoping(false, block, parent, scope, file);

this.loopParent = loopParent;
this.parent = parent;
this.scope = scope;
this.block = block;
this.file = file;
this.parent = parent;
this.scope = scope;
this.block = block;
this.file = file;
this.outsideLetReferences = object();
this.hasLetReferences = false;
this.letReferences = block._letReferences = object();
this.body = [];
this.hasLetReferences = false;
this.letReferences = block._letReferences = object();
this.body = [];
}

@@ -168,4 +167,4 @@

var hasRemaps = false;
var letRefs = this.letReferences;
var scope = this.scope;
var letRefs = this.letReferences;
var scope = this.scope;

@@ -254,3 +253,3 @@ // alright, so since we aren't wrapping this block in a closure

var call = t.callExpression(fn, params);
var ret = this.scope.generateUidIdentifier("ret");
var ret = this.scope.generateUidIdentifier("ret");

@@ -275,3 +274,3 @@ // handle generators

var letReferenceFunctionVisitor = {
enter: function (node, parent, scope, state) {
enter: function enter(node, parent, scope, state) {
// not a direct reference

@@ -292,3 +291,3 @@ if (!t.isReferencedIdentifier(node, parent)) return;

var letReferenceBlockVisitor = {
enter: function (node, parent, scope, state) {
enter: function enter(node, parent, scope, state) {
if (t.isFunction(node)) {

@@ -343,3 +342,3 @@ scope.traverse(node, letReferenceFunctionVisitor, state);

letReferences: this.letReferences,
closurify: false
closurify: false
};

@@ -354,3 +353,3 @@

var loopNodeTo = function (node) {
var loopNodeTo = function loopNodeTo(node) {
if (t.isBreakStatement(node)) {

@@ -364,3 +363,3 @@ return "break";

var loopVisitor = {
enter: function (node, parent, scope, state) {
enter: function enter(node, parent, scope, state) {
var replace;

@@ -404,5 +403,3 @@

state.hasReturn = true;
replace = t.objectExpression([
t.property("init", t.identifier("v"), node.argument || t.identifier("undefined"))
]);
replace = t.objectExpression([t.property("init", t.identifier("v"), node.argument || t.identifier("undefined"))]);
}

@@ -418,3 +415,3 @@

var loopLabelVisitor = {
enter: function (node, parent, scope, state) {
enter: function enter(node, parent, scope, state) {
if (t.isLabeledStatement(node)) {

@@ -438,7 +435,7 @@ state.innerLabels.push(node.label.name);

hasBreakContinue: false,
ignoreLabeless: false,
innerLabels: [],
hasReturn: false,
isLoop: !!this.loopParent,
map: {}
ignoreLabeless: false,
innerLabels: [],
hasReturn: false,
isLoop: !!this.loopParent,
map: {}
};

@@ -453,3 +450,3 @@

var hoistVarDeclarationsVisitor = {
enter: function (node, parent, scope, self) {
enter: function enter(node, parent, scope, self) {
if (t.isForStatement(node)) {

@@ -532,5 +529,3 @@ if (isVar(node.init, node)) {

body.push(t.variableDeclaration("var", [
t.variableDeclarator(ret, call)
]));
body.push(t.variableDeclaration("var", [t.variableDeclarator(ret, call)]));

@@ -551,4 +546,3 @@ var loopParent = this.loopParent;

if (!loopParent) {
throw new Error("Has no loop parent but we're trying to reassign breaks " +
"and continues, something is going wrong here.");
throw new Error("Has no loop parent but we're trying to reassign breaks " + "and continues, something is going wrong here.");
}

@@ -566,6 +560,3 @@

var single = cases[0];
body.push(this.file.attachAuxiliaryComment(t.ifStatement(
t.binaryExpression("===", ret, single.test),
single.consequent[0]
)));
body.push(this.file.attachAuxiliaryComment(t.ifStatement(t.binaryExpression("===", ret, single.test), single.consequent[0])));
} else {

@@ -579,2 +570,2 @@ body.push(this.file.attachAuxiliaryComment(t.switchStatement(ret, cases)));

}
};
};
"use strict";
var ReplaceSupers = require("../../helpers/replace-supers");
var nameMethod = require("../../helpers/name-method");
var defineMap = require("../../helpers/define-map");
var messages = require("../../../messages");
var util = require("../../../util");
var t = require("../../../types");
var nameMethod = require("../../helpers/name-method");
var defineMap = require("../../helpers/define-map");
var messages = require("../../../messages");
var util = require("../../../util");
var t = require("../../../types");

@@ -43,16 +43,16 @@ exports.check = t.isClass;

this.isStatement = isStatement;
this.scope = scope;
this.node = node;
this.file = file;
this.scope = scope;
this.node = node;
this.file = file;
this.hasInstanceMutators = false;
this.hasStaticMutators = false;
this.hasStaticMutators = false;
this.instanceMutatorMap = {};
this.staticMutatorMap = {};
this.hasConstructor = false;
this.className = node.id || scope.generateUidIdentifier("class");
this.superName = node.superClass || t.identifier("Function");
this.hasSuper = !!node.superClass;
this.isLoose = file.isLoose("es6.classes");
this.staticMutatorMap = {};
this.hasConstructor = false;
this.className = node.id || scope.generateUidIdentifier("class");
this.superName = node.superClass || t.identifier("Function");
this.hasSuper = !!node.superClass;
this.isLoose = file.isLoose("es6.classes");
}

@@ -70,3 +70,3 @@

var classBody = this.node.body.body;
var file = this.file;
var file = this.file;

@@ -77,8 +77,3 @@ //

var constructorBody = t.blockStatement([
t.expressionStatement(t.callExpression(file.addHelper("class-call-check"), [
t.thisExpression(),
className
]))
]);
var constructorBody = t.blockStatement([t.expressionStatement(t.callExpression(file.addHelper("class-call-check"), [t.thisExpression(), className]))]);

@@ -99,5 +94,3 @@ var constructor;

constructor = t.functionExpression(constructorName, [], constructorBody);
body.push(t.variableDeclaration("var", [
t.variableDeclarator(className, constructor)
]));
body.push(t.variableDeclaration("var", [t.variableDeclarator(className, constructor)]));
}

@@ -135,12 +128,7 @@ this.constructor = constructor;

body.push(t.returnStatement(className));
init = t.callExpression(
t.functionExpression(null, closureParams, t.blockStatement(body)),
closureArgs
);
init = t.callExpression(t.functionExpression(null, closureParams, t.blockStatement(body)), closureArgs);
}
if (this.isStatement) {
return t.variableDeclaration("let", [
t.variableDeclarator(className, init)
]);
return t.variableDeclaration("let", [t.variableDeclarator(className, init)]);
} else {

@@ -157,6 +145,6 @@ return init;

var constructor = this.constructor;
var className = this.className;
var superName = this.superName;
var classBody = this.node.body.body;
var body = this.body;
var className = this.className;
var superName = this.superName;
var classBody = this.node.body.body;
var body = this.body;

@@ -168,12 +156,12 @@ for (var i = 0; i < classBody.length; i++) {

methodNode: node,
className: this.className,
superName: this.superName,
isStatic: node.static,
isLoose: this.isLoose,
scope: this.scope,
file: this.file
className: this.className,
superName: this.superName,
isStatic: node["static"],
isLoose: this.isLoose,
scope: this.scope,
file: this.file
}, true);
replaceSupers.replace();
if ((!node.computed && t.isIdentifier(node.key, { name: "constructor" })) || t.isLiteral(node.key, { value: "constructor" })) {
if (!node.computed && t.isIdentifier(node.key, { name: "constructor" }) || t.isLiteral(node.key, { value: "constructor" })) {
this.pushConstructor(node);

@@ -218,5 +206,3 @@ } else {

body.push(t.expressionStatement(
t.callExpression(this.file.addHelper("prototype-properties"), args)
));
body.push(t.expressionStatement(t.callExpression(this.file.addHelper("prototype-properties"), args)));
}

@@ -243,3 +229,3 @@ };

var className = this.className;
if (!node.static) className = t.memberExpression(className, t.identifier("prototype"));
if (!node["static"]) className = t.memberExpression(className, t.identifier("prototype"));
methodName = t.memberExpression(className, methodName, node.computed);

@@ -257,3 +243,3 @@

var mutatorMap = this.instanceMutatorMap;
if (node.static) {
if (node["static"]) {
this.hasStaticMutators = true;

@@ -280,12 +266,8 @@ mutatorMap = this.staticMutatorMap;

if (node.static) {
if (node["static"]) {
key = t.memberExpression(this.className, node.key);
this.body.push(
t.expressionStatement(t.assignmentExpression("=", key, node.value))
);
this.body.push(t.expressionStatement(t.assignmentExpression("=", key, node.value)));
} else {
key = t.memberExpression(t.thisExpression(), node.key);
this.constructor.body.body.unshift(
t.expressionStatement(t.assignmentExpression("=", key, node.value))
);
this.constructor.body.body.unshift(t.expressionStatement(t.assignmentExpression("=", key, node.value)));
}

@@ -306,3 +288,3 @@ };

var construct = this.constructor;
var fn = method.value;
var fn = method.value;

@@ -315,4 +297,4 @@ this.hasConstructor = true;

construct._ignoreUserWhitespace = true;
construct.params = fn.params;
construct.body.body = construct.body.body.concat(fn.body.body);
};
construct.params = fn.params;
construct.body.body = construct.body.body.concat(fn.body.body);
};
"use strict";
var messages = require("../../../messages");
var t = require("../../../types");
var t = require("../../../types");

@@ -11,3 +11,3 @@ exports.check = function (node) {

var visitor = {
enter: function (node, parent, scope, state) {
enter: function enter(node, parent, scope, state) {
if (t.isAssignmentExpression(node) || t.isUpdateExpression(node)) {

@@ -45,3 +45,3 @@ var ids = t.getBindingIdentifiers(node);

constants: scope.getAllBindingsOfKind("const"),
file: file
file: file
});

@@ -52,2 +52,2 @@ };

if (node.kind === "const") node.kind = "let";
};
};
"use strict";
var messages = require("../../../messages");
var t = require("../../../types");
var t = require("../../../types");

@@ -10,7 +10,7 @@ exports.check = t.isPattern;

this.blockHoist = opts.blockHoist;
this.operator = opts.operator;
this.nodes = opts.nodes;
this.scope = opts.scope;
this.file = opts.file;
this.kind = opts.kind;
this.operator = opts.operator;
this.nodes = opts.nodes;
this.scope = opts.scope;
this.file = opts.file;
this.kind = opts.kind;
}

@@ -27,5 +27,3 @@

} else {
node = t.variableDeclaration(this.kind, [
t.variableDeclarator(id, init)
]);
node = t.variableDeclaration(this.kind, [t.variableDeclarator(id, init)]);
}

@@ -39,5 +37,3 @@

DestructuringTransformer.prototype.buildVariableDeclaration = function (id, init) {
var declar = t.variableDeclaration("var", [
t.variableDeclarator(id, init)
]);
var declar = t.variableDeclaration("var", [t.variableDeclarator(id, init)]);
declar._blockHoist = this.blockHoist;

@@ -59,6 +55,4 @@ return declar;

DestructuringTransformer.prototype.get = function () {
DestructuringTransformer.prototype.get = function () {};
};
DestructuringTransformer.prototype.pushAssignmentPattern = function (pattern, valueRef) {

@@ -70,5 +64,3 @@ // we need to assign the current value of the assignment to avoid evaluating

var declar = t.variableDeclaration("var", [
t.variableDeclarator(tempValueRef, valueRef)
]);
var declar = t.variableDeclaration("var", [t.variableDeclarator(tempValueRef, valueRef)]);
declar._blockHoist = this.blockHoist;

@@ -79,10 +71,3 @@ this.nodes.push(declar);

this.nodes.push(this.buildVariableAssignment(
pattern.left,
t.conditionalExpression(
t.binaryExpression("===", tempValueRef, t.identifier("undefined")),
pattern.right,
tempValueRef
)
));
this.nodes.push(this.buildVariableAssignment(pattern.left, t.conditionalExpression(t.binaryExpression("===", tempValueRef, t.identifier("undefined")), pattern.right, tempValueRef)));
};

@@ -122,3 +107,3 @@

var pattern = prop.value;
var objRef = t.memberExpression(propRef, prop.key, prop.computed);
var objRef = t.memberExpression(propRef, prop.key, prop.computed);

@@ -136,5 +121,3 @@ if (t.isPattern(pattern)) {

if (!pattern.properties.length) {
this.nodes.push(t.expressionStatement(
t.callExpression(this.file.addHelper("object-destructuring-empty"), [objRef])
));
this.nodes.push(t.expressionStatement(t.callExpression(this.file.addHelper("object-destructuring-empty"), [objRef])));
}

@@ -164,3 +147,3 @@

var hasRest = function (pattern) {
var hasRest = function hasRest(pattern) {
for (var i = 0; i < pattern.elements.length; i++) {

@@ -280,4 +263,3 @@ if (t.isRestElement(pattern.elements[i])) {

exports.ForInStatement =
exports.ForOfStatement = function (node, parent, scope, file) {
exports.ForInStatement = exports.ForOfStatement = function (node, parent, scope, file) {
var left = node.left;

@@ -290,11 +272,7 @@

node.left = t.variableDeclaration("var", [
t.variableDeclarator(temp)
]);
node.left = t.variableDeclaration("var", [t.variableDeclarator(temp)]);
t.ensureBlock(node);
node.body.body.unshift(t.variableDeclaration("var", [
t.variableDeclarator(left, temp)
]));
node.body.body.unshift(t.variableDeclaration("var", [t.variableDeclarator(left, temp)]));

@@ -310,5 +288,3 @@ return;

var key = scope.generateUidIdentifier("ref");
node.left = t.variableDeclaration(left.kind, [
t.variableDeclarator(key, null)
]);
node.left = t.variableDeclaration(left.kind, [t.variableDeclarator(key, null)]);

@@ -345,7 +321,6 @@ var nodes = [];

blockHoist: node.params.length - i,
nodes: nodes,
scope: scope,
file: file,
kind: "var",
});
nodes: nodes,
scope: scope,
file: file,
kind: "var" });
destructuring.init(pattern, ref);

@@ -395,5 +370,3 @@

var ref = scope.generateUidIdentifier("ref");
nodes.push(t.variableDeclaration("var", [
t.variableDeclarator(ref, expr.right)
]));
nodes.push(t.variableDeclaration("var", [t.variableDeclarator(ref, expr.right)]));

@@ -436,3 +409,3 @@ var destructuring = new DestructuringTransformer({

var variableDeclarationHasPattern = function (node) {
var variableDeclarationHasPattern = function variableDeclarationHasPattern(node) {
for (var i = 0; i < node.declarations.length; i++) {

@@ -457,3 +430,3 @@ if (t.isPattern(node.declarations[i].id)) {

var patternId = declar.init;
var pattern = declar.id;
var pattern = declar.id;

@@ -463,4 +436,4 @@ var destructuring = new DestructuringTransformer({

scope: scope,
kind: node.kind,
file: file
kind: node.kind,
file: file
});

@@ -502,2 +475,2 @@

return nodes;
};
};
"use strict";
var messages = require("../../../messages");
var util = require("../../../util");
var t = require("../../../types");
var util = require("../../../util");
var t = require("../../../types");

@@ -13,6 +13,6 @@ exports.check = t.isForOfStatement;

var build = callback(node, parent, scope, file);
var build = callback(node, parent, scope, file);
var declar = build.declar;
var loop = build.loop;
var block = loop.body;
var loop = build.loop;
var block = loop.body;

@@ -42,3 +42,3 @@ // inherit comments from the original loop

var breakVisitor = {
enter: function (node, parent, scope, state) {
enter: function enter(node, parent, scope, state) {
if (t.isLoop(node)) {

@@ -55,5 +55,3 @@ state.ignoreLabeless = true;

var ret = t.expressionStatement(
t.callExpression(t.memberExpression(state.iteratorKey, t.identifier("return")), [])
);
var ret = t.expressionStatement(t.callExpression(t.memberExpression(state.iteratorKey, t.identifier("return")), []));
ret = state.wrapReturn(ret);

@@ -67,3 +65,3 @@

var loose = function (node, parent, scope, file) {
var loose = function loose(node, parent, scope, file) {
var left = node.left;

@@ -78,5 +76,3 @@ var declar, id;

id = scope.generateUidIdentifier("ref");
declar = t.variableDeclaration(left.kind, [
t.variableDeclarator(left.declarations[0].id, id)
]);
declar = t.variableDeclaration(left.kind, [t.variableDeclarator(left.declarations[0].id, id)]);
} else {

@@ -87,10 +83,10 @@ throw file.errorWithNode(left, messages.get("unknownForHead", left.type));

var iteratorKey = scope.generateUidIdentifier("iterator");
var isArrayKey = scope.generateUidIdentifier("isArray");
var isArrayKey = scope.generateUidIdentifier("isArray");
var loop = util.template("for-of-loose", {
LOOP_OBJECT: iteratorKey,
IS_ARRAY: isArrayKey,
OBJECT: node.right,
INDEX: scope.generateUidIdentifier("i"),
ID: id
LOOP_OBJECT: iteratorKey,
IS_ARRAY: isArrayKey,
OBJECT: node.right,
INDEX: scope.generateUidIdentifier("i"),
ID: id
});

@@ -108,12 +104,6 @@

iteratorKey: iteratorKey,
wrapReturn: function (node) {
return t.ifStatement(
t.logicalExpression(
"&&",
t.unaryExpression("!", isArrayKey, true),
t.memberExpression(iteratorKey, t.identifier("return")
)
), node);
wrapReturn: function wrapReturn(node) {
return t.ifStatement(t.logicalExpression("&&", t.unaryExpression("!", isArrayKey, true), t.memberExpression(iteratorKey, t.identifier("return"))), node);
},
label: t.isLabeledStatement(parent) && parent.label.name
label: t.isLabeledStatement(parent) && parent.label.name
});

@@ -125,11 +115,11 @@

declar: declar,
loop: loop
loop: loop
};
};
var spec = function (node, parent, scope, file) {
var spec = function spec(node, parent, scope, file) {
var left = node.left;
var declar;
var stepKey = scope.generateUidIdentifier("step");
var stepKey = scope.generateUidIdentifier("step");
var stepValue = t.memberExpression(stepKey, t.identifier("value"));

@@ -142,5 +132,3 @@

// for (var i of test)
declar = t.variableDeclaration(left.kind, [
t.variableDeclarator(left.declarations[0].id, stepValue)
]);
declar = t.variableDeclaration(left.kind, [t.variableDeclarator(left.declarations[0].id, stepValue)]);
} else {

@@ -156,4 +144,4 @@ throw file.errorWithNode(left, messages.get("unknownForHead", left.type));

ITERATOR_KEY: iteratorKey,
STEP_KEY: stepKey,
OBJECT: node.right
STEP_KEY: stepKey,
OBJECT: node.right
});

@@ -165,6 +153,6 @@

iteratorKey: iteratorKey,
wrapReturn: function (node) {
wrapReturn: function wrapReturn(node) {
return t.ifStatement(t.memberExpression(iteratorKey, t.identifier("return")), node);
},
label: t.isLabeledStatement(parent) && parent.label.name
label: t.isLabeledStatement(parent) && parent.label.name
});

@@ -176,4 +164,4 @@

declar: declar,
loop: loop
loop: loop
};
};
};

@@ -58,2 +58,2 @@ "use strict";

return nodes;
};
};
"use strict";
var ReplaceSupers = require("../../helpers/replace-supers");
var t = require("../../../types");
var t = require("../../../types");

@@ -18,7 +18,7 @@ exports.check = function (node) {

topLevelThisReference: thisExpr,
methodNode: node,
className: thisExpr,
isStatic: true,
scope: scope,
file: file
methodNode: node,
className: thisExpr,
isStatic: true,
scope: scope,
file: file
});

@@ -29,8 +29,4 @@

if (replaceSupers.hasSuper) {
value.body.body.unshift(
t.variableDeclaration("var", [
t.variableDeclarator(thisExpr, t.thisExpression())
])
);
value.body.body.unshift(t.variableDeclaration("var", [t.variableDeclarator(thisExpr, t.thisExpression())]));
}
};
};
"use strict";
var util = require("../../../util");
var t = require("../../../types");
var t = require("../../../types");

@@ -10,3 +10,3 @@ exports.check = function (node) {

var hasDefaults = function (node) {
var hasDefaults = function hasDefaults(node) {
for (var i = 0; i < node.params.length; i++) {

@@ -19,3 +19,3 @@ if (!t.isIdentifier(node.params[i])) return true;

var iifeVisitor = {
enter: function (node, parent, scope, state) {
enter: function enter(node, parent, scope, state) {
if (!t.isReferencedIdentifier(node, parent)) return;

@@ -44,8 +44,8 @@ if (!state.scope.hasOwnBinding(node.name)) return;

var pushDefNode = function (left, right, i) {
var pushDefNode = function pushDefNode(left, right, i) {
var defNode = util.template("default-parameter", {
VARIABLE_NAME: left,
DEFAULT_VALUE: right,
ARGUMENT_KEY: t.literal(i),
ARGUMENTS: argsIdentifier
ARGUMENT_KEY: t.literal(i),
ARGUMENTS: argsIdentifier
}, true);

@@ -76,3 +76,3 @@ file.checkNode(defNode);

var left = param.left;
var left = param.left;
var right = param.right;

@@ -108,2 +108,2 @@

}
};
};
"use strict";
var util = require("../../../util");
var t = require("../../../types");
var t = require("../../../types");
exports.check = t.isRestElement;
var hasRest = function (node) {
var hasRest = function hasRest(node) {
return t.isRestElement(node.params[node.params.length - 1]);

@@ -40,7 +40,3 @@ };

// cause an error
arrLen = t.conditionalExpression(
t.binaryExpression(">", len, start),
t.binaryExpression("-", len, start),
t.literal(0)
);
arrLen = t.conditionalExpression(t.binaryExpression(">", len, start), t.binaryExpression("-", len, start), t.literal(0));
}

@@ -54,5 +50,3 @@

// let the destructuring transformer handle this
var restDeclar = t.variableDeclaration("var", [
t.variableDeclarator(pattern, rest)
]);
var restDeclar = t.variableDeclaration("var", [t.variableDeclarator(pattern, rest)]);

@@ -74,6 +68,5 @@ // retain evaluation position

KEY: key,
LEN: len,
});
LEN: len });
loop._blockHoist = node.params.length + 1;
node.body.body.unshift(loop);
};
};

@@ -38,5 +38,3 @@ "use strict";

body.unshift(t.variableDeclaration("var", [
t.variableDeclarator(objId, t.objectExpression(initProps))
]));
body.unshift(t.variableDeclaration("var", [t.variableDeclarator(objId, t.objectExpression(initProps))]));

@@ -48,17 +46,11 @@ body.push(t.returnStatement(objId));

var loose = function (node, body, objId) {
var loose = function loose(node, body, objId) {
for (var i = 0; i < node.properties.length; i++) {
var prop = node.properties[i];
body.push(t.expressionStatement(
t.assignmentExpression(
"=",
t.memberExpression(objId, prop.key, prop.computed || t.isLiteral(prop.key)),
prop.value
)
));
body.push(t.expressionStatement(t.assignmentExpression("=", t.memberExpression(objId, prop.key, prop.computed || t.isLiteral(prop.key)), prop.value)));
}
};
var spec = function (node, body, objId, initProps, file) {
var spec = function spec(node, body, objId, initProps, file) {
var props = node.properties;

@@ -109,7 +101,3 @@ var prop, key;

// { [Symbol.iterator]: "foo" }
bodyNode = t.assignmentExpression(
"=",
t.memberExpression(objId, key, true),
prop.value
);
bodyNode = t.assignmentExpression("=", t.memberExpression(objId, key, true), prop.value);
} else {

@@ -132,2 +120,2 @@ bodyNode = t.callExpression(file.addHelper("define-property"), [objId, key, prop.value]);

}
};
};
"use strict";
var clone = require("lodash/lang/clone");
var t = require("../../../types");
var t = require("../../../types");

@@ -19,2 +19,2 @@ exports.check = function (node) {

}
};
};
"use strict";
var includes = require("lodash/collection/includes");
var t = require("../../../types");
var t = require("../../../types");
exports.check = t.isSpreadElement;
var getSpreadLiteral = function (spread, scope) {
var getSpreadLiteral = function getSpreadLiteral(spread, scope) {
return scope.toArray(spread.argument, true);
};
var hasSpread = function (nodes) {
var hasSpread = function hasSpread(nodes) {
for (var i = 0; i < nodes.length; i++) {

@@ -21,3 +21,3 @@ if (t.isSpreadElement(nodes[i])) {

var build = function (props, scope) {
var build = function build(props, scope) {
var nodes = [];

@@ -27,3 +27,3 @@

var push = function () {
var push = function push() {
if (!_props.length) return;

@@ -125,12 +125,6 @@ nodes.push(t.arrayExpression(_props));

if (nativeType) {
return t.newExpression(
t.callExpression(
t.memberExpression(file.addHelper("bind"), t.identifier("apply")),
[node.callee, args]
),
[]
);
return t.newExpression(t.callExpression(t.memberExpression(file.addHelper("bind"), t.identifier("apply")), [node.callee, args]), []);
} else {
return t.callExpression(file.addHelper("apply-constructor"), [node.callee, args]);
}
};
};
"use strict";
var reduceRight = require("lodash/collection/reduceRight");
var messages = require("../../../messages");
var flatten = require("lodash/array/flatten");
var util = require("../../../util");
var map = require("lodash/collection/map");
var t = require("../../../types");
var messages = require("../../../messages");
var flatten = require("lodash/array/flatten");
var util = require("../../../util");
var map = require("lodash/collection/map");
var t = require("../../../types");

@@ -16,11 +16,11 @@ function returnBlock(expr) {

this.hasTailRecursion = false;
this.needsArguments = false;
this.setsArguments = false;
this.needsThis = false;
this.ownerId = node.id;
this.vars = [];
this.needsArguments = false;
this.setsArguments = false;
this.needsThis = false;
this.ownerId = node.id;
this.vars = [];
this.scope = scope;
this.file = file;
this.node = node;
this.file = file;
this.node = node;
}

@@ -58,6 +58,3 @@

if (!param._isDefaultPlaceholder) {
this.paramDecls.push(t.variableDeclarator(
param,
params[i] = this.scope.generateUidIdentifier("x")
));
this.paramDecls.push(t.variableDeclarator(param, params[i] = this.scope.generateUidIdentifier("x")));
}

@@ -79,3 +76,3 @@ }

var scope = this.scope;
var node = this.node;
var node = this.node;

@@ -122,12 +119,10 @@ // only tail recursion can be optimized as for now, so we can skip anonymous

body.unshift(t.expressionStatement(
t.assignmentExpression("=", this.getAgainId(), t.literal(false)))
);
body.unshift(t.expressionStatement(t.assignmentExpression("=", this.getAgainId(), t.literal(false))));
node.body = util.template("tail-call-body", {
AGAIN_ID: this.getAgainId(),
THIS_ID: this.thisId,
ARGUMENTS_ID: this.argumentsId,
FUNCTION_ID: this.getFunctionId(),
BLOCK: node.body
AGAIN_ID: this.getAgainId(),
THIS_ID: this.thisId,
ARGUMENTS_ID: this.argumentsId,
FUNCTION_ID: this.getFunctionId(),
BLOCK: node.body
});

@@ -193,7 +188,3 @@

var leftId = this.getLeftId();
var testExpr = t.assignmentExpression(
"=",
leftId,
node.left
);
var testExpr = t.assignmentExpression("=", leftId, node.left);

@@ -226,3 +217,5 @@ if (node.operator === "&&") {

TailCallTransformer.prototype.subTransformCallExpression = function (node) {
var callee = node.callee, thisBinding, args;
var callee = node.callee,
thisBinding,
args;

@@ -259,7 +252,3 @@ if (t.isMemberExpression(callee, { computed: false }) && t.isIdentifier(callee.property)) {

if (!t.isThisExpression(thisBinding)) {
body.push(t.expressionStatement(t.assignmentExpression(
"=",
this.getThisId(),
thisBinding || t.identifier("undefined")
)));
body.push(t.expressionStatement(t.assignmentExpression("=", this.getThisId(), thisBinding || t.identifier("undefined"))));
}

@@ -274,7 +263,3 @@

body.push(t.expressionStatement(t.assignmentExpression(
"=",
argumentsId,
args
)));
body.push(t.expressionStatement(t.assignmentExpression("=", argumentsId, args)));

@@ -297,7 +282,3 @@ var i, param;

if (!param._isDefaultPlaceholder) {
body.push(t.expressionStatement(t.assignmentExpression(
"=",
param,
t.memberExpression(argumentsId, t.literal(i), true)
)));
body.push(t.expressionStatement(t.assignmentExpression("=", param, t.memberExpression(argumentsId, t.literal(i), true))));
}

@@ -307,5 +288,3 @@ }

body.push(t.expressionStatement(
t.assignmentExpression("=", this.getAgainId(), t.literal(true))
));
body.push(t.expressionStatement(t.assignmentExpression("=", this.getAgainId(), t.literal(true))));
body.push(t.continueStatement(this.getFunctionId()));

@@ -318,3 +297,3 @@

var firstPass = {
enter: function (node, parent, scope, state) {
enter: function enter(node, parent, scope, state) {
if (t.isIfStatement(node)) {

@@ -349,3 +328,3 @@ if (t.isReturnStatement(node.alternate)) {

var secondPass = {
enter: function (node, parent, scope, state) {
enter: function enter(node, parent, scope, state) {
if (t.isThisExpression(node)) {

@@ -360,5 +339,3 @@ state.needsThis = true;

if (t.isFunctionDeclaration(node)) {
node = t.variableDeclaration("var", [
t.variableDeclarator(node.id, t.toExpression(node))
]);
node = t.variableDeclaration("var", [t.variableDeclarator(node.id, t.toExpression(node))]);
node._blockHoist = 2;

@@ -373,3 +350,3 @@ return node;

var thirdPass = {
enter: function (node, parent, scope, state) {
enter: function enter(node, parent, scope, state) {
if (!t.isExpressionStatement(node)) return;

@@ -393,2 +370,2 @@

tailCall.run();
};
};

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

var buildBinaryExpression = function (left, right) {
var buildBinaryExpression = function buildBinaryExpression(left, right) {
return t.binaryExpression("+", left, right);

@@ -67,2 +67,2 @@ };

}
};
};
"use strict";
var rewritePattern = require("regexpu/rewrite-pattern");
var pull = require("lodash/array/pull");
var t = require("../../../types");
var pull = require("lodash/array/pull");
var t = require("../../../types");

@@ -20,3 +20,3 @@ exports.check = function (node) {

regex.pattern = rewritePattern(regex.pattern, regex.flags);
regex.flags = flags.join("");
};
regex.flags = flags.join("");
};

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

var util = require("../../../util");
var t = require("../../../types");
var t = require("../../../types");
exports.experimental = true;
var container = function (parent, call, ret, file) {
var container = function container(parent, call, ret, file) {
if (t.isExpressionStatement(parent) && !file.isConsequenceExpressionStatement(parent)) {

@@ -41,10 +41,6 @@ // we don't need to worry about return values

if (node.operator !== "=") {
value = t.binaryExpression(
node.operator[0],
util.template("abstract-expression-get", {
PROPERTY: node.property,
OBJECT: node.object
}),
value
);
value = t.binaryExpression(node.operator[0], util.template("abstract-expression-get", {
PROPERTY: node.property,
OBJECT: node.object
}), value);
}

@@ -54,11 +50,8 @@

PROPERTY: left.property,
OBJECT: left.object,
VALUE: value
OBJECT: left.object,
VALUE: value
});
if (temp) {
call = t.sequenceExpression([
t.assignmentExpression("=", temp, node.right),
call
]);
call = t.sequenceExpression([t.assignmentExpression("=", temp, node.right), call]);
}

@@ -76,3 +69,3 @@

PROPERTY: arg.property,
OBJECT: arg.object
OBJECT: arg.object
});

@@ -91,3 +84,3 @@

PROPERTY: callee.property,
OBJECT: temp || callee.object
OBJECT: temp || callee.object
});

@@ -98,6 +91,3 @@

if (temp) {
return t.sequenceExpression([
t.assignmentExpression("=", temp, callee.object),
call
]);
return t.sequenceExpression([t.assignmentExpression("=", temp, callee.object), call]);
} else {

@@ -111,3 +101,3 @@ return call;

PROPERTY: node.property,
OBJECT: node.object
OBJECT: node.object
});

@@ -120,2 +110,2 @@ };

}));
};
};
"use strict";
var buildComprehension = require("../../helpers/build-comprehension");
var traverse = require("../../../traversal");
var util = require("../../../util");
var t = require("../../../types");
var traverse = require("../../../traversal");
var util = require("../../../util");
var t = require("../../../types");

@@ -16,3 +16,3 @@ exports.experimental = true;

var generator = function (node) {
var generator = function generator(node) {
var body = [];

@@ -29,3 +29,3 @@ var container = t.functionExpression(null, [], t.blockStatement(body), true);

var array = function (node, parent, scope, file) {
var array = function array(node, parent, scope, file) {
var uid = scope.generateUidBasedOnNode(parent, file);

@@ -39,3 +39,3 @@

var block = container.callee.body;
var body = block.body;
var body = block.body;

@@ -52,3 +52,3 @@ if (traverse.hasType(node, scope, "YieldExpression", t.FUNCTION_TYPES)) {

STATEMENT: node.body,
KEY: uid
KEY: uid
}, true);

@@ -59,2 +59,2 @@ }));

return container;
};
};

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

var build = require("../../helpers/build-binary-assignment-operator-transformer");
var t = require("../../../types");
var t = require("../../../types");

@@ -16,5 +16,5 @@ var MATH_POW = t.memberExpression(t.identifier("Math"), t.identifier("pow"));

build: function (left, right) {
build: function build(left, right) {
return t.callExpression(MATH_POW, [left, right]);
}
});
});

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

var hasSpread = function (node) {
var hasSpread = function hasSpread(node) {
for (var i = 0; i < node.properties.length; i++) {

@@ -29,3 +29,3 @@ if (t.isSpreadProperty(node.properties[i])) {

var push = function () {
var push = function push() {
if (!props.length) return;

@@ -53,2 +53,2 @@ args.push(t.objectExpression(props));

return t.callExpression(file.addHelper("extends"), args);
};
};

@@ -0,78 +1,80 @@

"use strict";
module.exports = {
useStrict: require("./other/use-strict"),
useStrict: require("./other/use-strict"),
// this goes at the start so we only transform the original user code
"spec.functionName": require("./spec/function-name"),
"spec.functionName": require("./spec/function-name"),
"validation.undeclaredVariableCheck": require("./validation/undeclared-variable-check"),
"validation.noForInOfAssignment": require("./validation/no-for-in-of-assignment"),
"validation.setters": require("./validation/setters"),
"validation.react": require("./validation/react"),
"spec.blockScopedFunctions": require("./spec/block-scoped-functions"),
"validation.undeclaredVariableCheck": require("./validation/undeclared-variable-check"),
"validation.noForInOfAssignment": require("./validation/no-for-in-of-assignment"),
"validation.setters": require("./validation/setters"),
"validation.react": require("./validation/react"),
"spec.blockScopedFunctions": require("./spec/block-scoped-functions"),
// needs to be before `_aliasFunction`
"es6.arrowFunctions": require("./es6/arrow-functions"),
"es6.arrowFunctions": require("./es6/arrow-functions"),
"playground.malletOperator": require("./playground/mallet-operator"),
"playground.methodBinding": require("./playground/method-binding"),
"playground.memoizationOperator": require("./playground/memoization-operator"),
"playground.objectGetterMemoization": require("./playground/object-getter-memoization"),
"playground.malletOperator": require("./playground/mallet-operator"),
"playground.methodBinding": require("./playground/method-binding"),
"playground.memoizationOperator": require("./playground/memoization-operator"),
"playground.objectGetterMemoization": require("./playground/object-getter-memoization"),
reactCompat: require("./other/react-compat"),
flow: require("./other/flow"),
react: require("./other/react"),
reactCompat: require("./other/react-compat"),
flow: require("./other/flow"),
react: require("./other/react"),
_modules: require("./internal/modules"),
_modules: require("./internal/modules"),
// needs to be before `regenerator` due to generator comprehensions
// needs to be before `_aliasFunction`
"es7.comprehensions": require("./es7/comprehensions"),
"es7.comprehensions": require("./es7/comprehensions"),
"es6.classes": require("./es6/classes"),
"es6.classes": require("./es6/classes"),
asyncToGenerator: require("./other/async-to-generator"),
bluebirdCoroutines: require("./other/bluebird-coroutines"),
asyncToGenerator: require("./other/async-to-generator"),
bluebirdCoroutines: require("./other/bluebird-coroutines"),
"es6.objectSuper": require("./es6/object-super"),
"es7.objectRestSpread": require("./es7/object-rest-spread"),
"es7.exponentiationOperator": require("./es7/exponentiation-operator"),
"es6.templateLiterals": require("./es6/template-literals"),
"es6.objectSuper": require("./es6/object-super"),
"es7.objectRestSpread": require("./es7/object-rest-spread"),
"es7.exponentiationOperator": require("./es7/exponentiation-operator"),
"es6.templateLiterals": require("./es6/template-literals"),
"es5.properties.mutators": require("./es5/properties.mutators"),
"es6.properties.shorthand": require("./es6/properties.shorthand"),
"es5.properties.mutators": require("./es5/properties.mutators"),
"es6.properties.shorthand": require("./es6/properties.shorthand"),
// needs to be before `_aliasFunction` due to define property closure
"es6.properties.computed": require("./es6/properties.computed"),
"es6.properties.computed": require("./es6/properties.computed"),
"es6.forOf": require("./es6/for-of"),
"es6.forOf": require("./es6/for-of"),
"es6.unicodeRegex": require("./es6/unicode-regex"),
"es7.abstractReferences": require("./es7/abstract-references"),
"es6.unicodeRegex": require("./es6/unicode-regex"),
"es7.abstractReferences": require("./es7/abstract-references"),
"es6.constants": require("./es6/constants"),
"es6.constants": require("./es6/constants"),
// needs to be before `es6.parameters.default` as default parameters will destroy the rest param
"es6.parameters.rest": require("./es6/parameters.rest"),
"es6.parameters.rest": require("./es6/parameters.rest"),
// needs to be after `es6.parameters.rest` as we use `toArray` and avoid turning an already known array into one
"es6.spread": require("./es6/spread"),
"es6.spread": require("./es6/spread"),
// needs to be before `es6.blockScoping` as default parameters have a TDZ
"es6.parameters.default": require("./es6/parameters.default"),
"es6.parameters.default": require("./es6/parameters.default"),
// needs to be before `es6.blockScoping` as let variables may be produced
"es6.destructuring": require("./es6/destructuring"),
"es6.destructuring": require("./es6/destructuring"),
// needs to be before `_aliasFunction` due to block scopes sometimes being wrapped in a
// closure
"es6.blockScoping": require("./es6/block-scoping"),
"es6.blockScoping": require("./es6/block-scoping"),
// needs to be after `es6.blockScoping` due to needing `letReferences` set on blocks
"es6.blockScopingTDZ": require("./es6/block-scoping-tdz"),
"es6.blockScopingTDZ": require("./es6/block-scoping-tdz"),
// needs to be after `es6.parameters.*` and `es6.blockScoping` due to needing pure
// identifiers in parameters and variable declarators
"es6.tailCall": require("./es6/tail-call"),
"es6.tailCall": require("./es6/tail-call"),
regenerator: require("./other/regenerator"),
regenerator: require("./other/regenerator"),

@@ -82,30 +84,30 @@ // needs to be after `regenerator` due to needing `regeneratorRuntime` references

// needs to be before `es6.modules` due to dynamic imports
runtime: require("./other/runtime"),
runtime: require("./other/runtime"),
// needs to be before `_blockHoist` due to function hoisting etc
"es6.modules": require("./es6/modules"),
"es6.modules": require("./es6/modules"),
_blockHoist: require("./internal/block-hoist"),
_blockHoist: require("./internal/block-hoist"),
"spec.protoToAssign": require("./spec/proto-to-assign"),
"spec.protoToAssign": require("./spec/proto-to-assign"),
_declarations: require("./internal/declarations"),
_declarations: require("./internal/declarations"),
_aliasFunctions: require("./internal/alias-functions"),
_aliasFunctions: require("./internal/alias-functions"),
"spec.typeofSymbol": require("./spec/typeof-symbol"),
"spec.undefinedToVoid": require("./spec/undefined-to-void"),
"spec.typeofSymbol": require("./spec/typeof-symbol"),
"spec.undefinedToVoid": require("./spec/undefined-to-void"),
_useStrict: require("./internal/use-strict"),
_moduleFormatter: require("./internal/module-formatter"),
_useStrict: require("./internal/use-strict"),
_moduleFormatter: require("./internal/module-formatter"),
"es3.propertyLiterals": require("./es3/property-literals"),
"es3.memberExpressionLiterals": require("./es3/member-expression-literals"),
"es3.propertyLiterals": require("./es3/property-literals"),
"es3.memberExpressionLiterals": require("./es3/member-expression-literals"),
"minification.removeDebugger": require("./minification/remove-debugger"),
"minification.removeConsoleCalls": require("./minification/remove-console-calls"),
"minification.deadCodeElimination": require("./minification/dead-code-elimination"),
"minification.renameLocalVariables": require("./minification/rename-local-variables"),
"minification.removeDebugger": require("./minification/remove-debugger"),
"minification.removeConsoleCalls": require("./minification/remove-console-calls"),
"minification.deadCodeElimination": require("./minification/dead-code-elimination"),
"minification.renameLocalVariables": require("./minification/rename-local-variables"),
_cleanUp: require("./internal/cleanup")
};
_cleanUp: require("./internal/cleanup")
};

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

var functionChildrenVisitor = {
enter: function (node, parent, scope, state) {
enter: function enter(node, parent, scope, state) {
if (t.isFunction(node) && !node._aliasFunction) {

@@ -29,3 +29,3 @@ return this.skip();

var functionVisitor = {
enter: function (node, parent, scope, state) {
enter: function enter(node, parent, scope, state) {
if (!node._aliasFunction) {

@@ -47,3 +47,3 @@ if (t.isFunction(node)) {

var go = function (getBody, node, scope) {
var go = function go(getBody, node, scope) {
var argumentsId;

@@ -53,6 +53,6 @@ var thisId;

var state = {
getArgumentsId: function () {
getArgumentsId: function getArgumentsId() {
return argumentsId = argumentsId || scope.generateUidIdentifier("arguments");
},
getThisId: function () {
getThisId: function getThisId() {
return thisId = thisId || scope.generateUidIdentifier("this");

@@ -68,7 +68,5 @@ }

var pushDeclaration = function (id, init) {
var pushDeclaration = function pushDeclaration(id, init) {
body = body || getBody();
body.unshift(t.variableDeclaration("var", [
t.variableDeclarator(id, init)
]));
body.unshift(t.variableDeclaration("var", [t.variableDeclarator(id, init)]));
};

@@ -91,4 +89,3 @@

exports.FunctionDeclaration =
exports.FunctionExpression = function (node, parent, scope) {
exports.FunctionDeclaration = exports.FunctionExpression = function (node, parent, scope) {
go(function () {

@@ -98,2 +95,2 @@ t.ensureBlock(node);

}, node, scope);
};
};

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

var flatten = require("lodash/array/flatten");
var values = require("lodash/object/values");
var values = require("lodash/object/values");

@@ -15,5 +15,4 @@ // Priority:

exports.BlockStatement =
exports.Program = {
exit: function (node) {
exports.BlockStatement = exports.Program = {
exit: function exit(node) {
var hasChange = false;

@@ -35,2 +34,2 @@ for (var i = 0; i < node.body.length; i++) {

}
};
};

@@ -0,1 +1,3 @@

"use strict";
exports.SequenceExpression = function (node) {

@@ -5,2 +7,2 @@ if (node.expressions.length === 1) {

}
};
};
"use strict";
var useStrict = require("../../helpers/use-strict");
var t = require("../../../types");
var t = require("../../../types");
exports.secondPass = true;
exports.BlockStatement =
exports.Program = function (node, parent, scope, file) {
exports.BlockStatement = exports.Program = function (node, parent, scope, file) {
if (!node._declarations) return;

@@ -36,2 +35,2 @@

});
};
};

@@ -11,3 +11,13 @@ "use strict";

var resolveModuleSource = function (node, parent, scope, file) {
var resolveModuleSource = (function (_resolveModuleSource) {
var _resolveModuleSourceWrapper = function resolveModuleSource() {
return _resolveModuleSource.apply(this, arguments);
};
_resolveModuleSourceWrapper.toString = function () {
return _resolveModuleSource.toString();
};
return _resolveModuleSourceWrapper;
})(function (node, parent, scope, file) {
var resolveModuleSource = file.opts.resolveModuleSource;

@@ -17,3 +27,3 @@ if (node.source && resolveModuleSource) {

}
};
});

@@ -34,3 +44,3 @@ exports.check = function (node) {

if (node.default) {
if (node["default"]) {
if (t.isClassDeclaration(declar)) {

@@ -41,5 +51,3 @@ node.declaration = declar.id;

var temp = scope.generateUidIdentifier("default");
declar = t.variableDeclaration("var", [
t.variableDeclarator(temp, declar)
]);
declar = t.variableDeclaration("var", [t.variableDeclarator(temp, declar)]);
node.declaration = temp;

@@ -54,3 +62,3 @@ return [declar, node];

if (t.isFunctionDeclaration(declar)) {
node.specifiers = [t.importSpecifier(declar.id, declar.id)];
node.specifiers = [t.importSpecifier(declar.id, declar.id)];
node.declaration = null;

@@ -61,2 +69,2 @@ node._blockHoist = 2;

}
};
};

@@ -0,1 +1,3 @@

"use strict";
var t = require("../../../types");

@@ -14,3 +16,3 @@

var expr = node.expression;
if (t.isLiteral(expr) || (t.isIdentifier(node) && t.hasBinding(node.name))) {
if (t.isLiteral(expr) || t.isIdentifier(node) && t.hasBinding(node.name)) {
this.remove();

@@ -21,3 +23,3 @@ }

exports.IfStatement = {
exit: function (node) {
exit: function exit(node) {
// todo: in scenarios where we can just return the consequent or

@@ -28,4 +30,4 @@ // alternate we should drop the block statement if it contains no

var consequent = node.consequent;
var alternate = node.alternate;
var test = node.test;
var alternate = node.alternate;
var test = node.test;

@@ -75,6 +77,6 @@ // we can check if a test will be truthy 100% and if so then we can inline

node.consequent = node.alternate;
node.alternate = null;
node.test = t.unaryExpression("!", test, true);
node.alternate = null;
node.test = t.unaryExpression("!", test, true);
}
}
};
};

@@ -0,1 +1,3 @@

"use strict";
var t = require("../../../types");

@@ -9,2 +11,2 @@

}
};
};

@@ -0,1 +1,3 @@

"use strict";
//var t = require("../../../types");

@@ -5,6 +7,6 @@

exports.Scopable = function () {
//for (var name in scope.bindings) {
// scope.rename(name, scope.generateUidIdentifier("a").name);
//}
};
exports.Scopable = function () {};
//for (var name in scope.bindings) {
// scope.rename(name, scope.generateUidIdentifier("a").name);
//}
"use strict";
var remapAsyncToGenerator = require("../../helpers/remap-async-to-generator");
var bluebirdCoroutines = require("./bluebird-coroutines");
var bluebirdCoroutines = require("./bluebird-coroutines");

@@ -14,2 +14,2 @@ exports.optional = true;

return remapAsyncToGenerator(node, file.addHelper("async-to-generator"), scope);
};
};
"use strict";
var remapAsyncToGenerator = require("../../helpers/remap-async-to-generator");
var t = require("../../../types");
var t = require("../../../types");

@@ -16,7 +16,3 @@ exports.manipulateOptions = function (opts) {

return remapAsyncToGenerator(
node,
t.memberExpression(file.addImport("bluebird", null, true), t.identifier("coroutine")),
scope
);
};
return remapAsyncToGenerator(node, t.memberExpression(file.addImport("bluebird", null, true), t.identifier("coroutine")), scope);
};

@@ -0,1 +1,3 @@

"use strict";
var t = require("../../../types");

@@ -13,2 +15,2 @@

if (t.isTypeAlias(node.declaration)) this.remove();
};
};
"use strict";
var react = require("../../helpers/react");
var t = require("../../../types");
var t = require("../../../types");

@@ -13,18 +13,11 @@ exports.manipulateOptions = function (opts) {

require("../../helpers/build-react-transformer")(exports, {
pre: function (state) {
pre: function pre(state) {
state.callee = state.tagExpr;
},
post: function (state) {
post: function post(state) {
if (react.isCompatTag(state.tagName)) {
state.call = t.callExpression(
t.memberExpression(
t.memberExpression(t.identifier("React"), t.identifier("DOM")),
state.tagExpr,
t.isLiteral(state.tagExpr)
),
state.args
);
state.call = t.callExpression(t.memberExpression(t.memberExpression(t.identifier("React"), t.identifier("DOM")), state.tagExpr, t.isLiteral(state.tagExpr)), state.args);
}
}
});
});
"use strict";
var react = require("../../helpers/react");
var t = require("../../../types");
var t = require("../../../types");

@@ -30,5 +30,5 @@ var JSX_ANNOTATION_REGEX = /^\*\s*@jsx\s+([^\s]+)/;

require("../../helpers/build-react-transformer")(exports, {
pre: function (state) {
pre: function pre(state) {
var tagName = state.tagName;
var args = state.args;
var args = state.args;
if (react.isCompatTag(tagName)) {

@@ -41,5 +41,5 @@ args.push(t.literal(tagName));

post: function (state, file) {
post: function post(state, file) {
state.callee = file.get("jsxIdentifier");
}
});
});
"use strict";
var regenerator = require("regenerator-babel");
var t = require("../../../types");
var t = require("../../../types");

@@ -11,6 +11,6 @@ exports.check = function (node) {

exports.Program = {
enter: function (ast) {
enter: function enter(ast) {
regenerator.transform(ast);
this.stop();
}
};
};
"use strict";
var includes = require("lodash/collection/includes");
var util = require("../../../util");
var core = require("core-js/library");
var has = require("lodash/object/has");
var t = require("../../../types");
var util = require("../../../util");
var core = require("core-js/library");
var has = require("lodash/object/has");
var t = require("../../../types");
var isSymboliterator = t.buildMatchMemberExpression("Symbol.iterator");
var coreHas = function (node) {
var coreHas = function coreHas(node) {
return node.name !== "_" && has(core, node.name);
};
var ALIASABLE_CONSTRUCTORS = [
"Symbol",
"Promise",
"Map",
"WeakMap",
"Set",
"WeakSet"
];
var ALIASABLE_CONSTRUCTORS = ["Symbol", "Promise", "Map", "WeakMap", "Set", "WeakSet"];
var astVisitor = {
enter: function (node, parent, scope, file) {
enter: function enter(node, parent, scope, file) {
var prop;

@@ -56,3 +49,3 @@

CORE_ID: file.get("coreIdentifier"),
VALUE: callee.object
VALUE: callee.object
});

@@ -69,3 +62,3 @@ } else if (t.isBinaryExpression(node)) {

CORE_ID: file.get("coreIdentifier"),
VALUE: node.right
VALUE: node.right
});

@@ -104,2 +97,2 @@ }

}
};
};
"use strict";
var messages = require("../../../messages");
var t = require("../../../types");
var t = require("../../../types");

@@ -13,4 +13,3 @@ exports.Program = function (program) {

exports.FunctionDeclaration =
exports.FunctionExpression = function () {
exports.FunctionDeclaration = exports.FunctionExpression = function () {
this.skip();

@@ -27,2 +26,2 @@ };

}
};
};
"use strict";
var messages = require("../../../messages");
var build = require("../../helpers/build-conditional-assignment-operator-transformer");
var t = require("../../../types");
var build = require("../../helpers/build-conditional-assignment-operator-transformer");
var t = require("../../../types");

@@ -10,3 +10,13 @@ exports.playground = true;

build(exports, {
is: function (node, file) {
is: (function (_is) {
var _isWrapper = function is() {
return _is.apply(this, arguments);
};
_isWrapper.toString = function () {
return _is.toString();
};
return _isWrapper;
})(function (node, file) {
var is = t.isAssignmentExpression(node) && node.operator === "||=";

@@ -20,7 +30,7 @@ if (is) {

}
},
}),
build: function (node) {
build: function build(node) {
return t.unaryExpression("!", node, true);
}
});
});
"use strict";
var build = require("../../helpers/build-conditional-assignment-operator-transformer");
var t = require("../../../types");
var t = require("../../../types");

@@ -9,18 +9,21 @@ exports.playground = true;

build(exports, {
is: function (node) {
is: (function (_is) {
var _isWrapper = function is() {
return _is.apply(this, arguments);
};
_isWrapper.toString = function () {
return _is.toString();
};
return _isWrapper;
})(function (node) {
var is = t.isAssignmentExpression(node) && node.operator === "?=";
if (is) t.assertMemberExpression(node.left);
return is;
},
}),
build: function (node, file) {
return t.unaryExpression(
"!",
t.callExpression(
t.memberExpression(file.addHelper("has-own"), t.identifier("call")),
[node.object, node.property]
),
true
);
build: function build(node, file) {
return t.unaryExpression("!", t.callExpression(t.memberExpression(file.addHelper("has-own"), t.identifier("call")), [node.object, node.property]), true);
}
});
});

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

var object = node.object;
var prop = node.property;
var prop = node.property;

@@ -15,12 +15,6 @@ var temp = scope.generateTempBasedOnNode(node.object);

var call = t.callExpression(
t.memberExpression(t.memberExpression(object, prop), t.identifier("bind")),
[object].concat(node.arguments)
);
var call = t.callExpression(t.memberExpression(t.memberExpression(object, prop), t.identifier("bind")), [object].concat(node.arguments));
if (temp) {
return t.sequenceExpression([
t.assignmentExpression("=", temp, node.object),
call
]);
return t.sequenceExpression([t.assignmentExpression("=", temp, node.object), call]);
} else {

@@ -32,7 +26,5 @@ return call;

exports.BindFunctionExpression = function (node, parent, scope) {
var buildCall = function (args) {
var buildCall = function buildCall(args) {
var param = scope.generateUidIdentifier("val");
return t.functionExpression(null, [param], t.blockStatement([
t.returnStatement(t.callExpression(t.memberExpression(param, node.callee), args))
]));
return t.functionExpression(null, [param], t.blockStatement([t.returnStatement(t.callExpression(t.memberExpression(param, node.callee), args))]));
};

@@ -42,8 +34,5 @@

return t.sequenceExpression([
t.assignmentExpression("=", temp, t.arrayExpression(node.arguments)),
buildCall(node.arguments.map(function (node, i) {
return t.memberExpression(temp, t.literal(i), true);
}))
]);
};
return t.sequenceExpression([t.assignmentExpression("=", temp, t.arrayExpression(node.arguments)), buildCall(node.arguments.map(function (node, i) {
return t.memberExpression(temp, t.literal(i), true);
}))]);
};

@@ -8,11 +8,7 @@ "use strict";

var visitor = {
enter: function (node, parent, scope, state) {
enter: function enter(node, parent, scope, state) {
if (t.isFunction(node)) return this.skip();
if (t.isReturnStatement(node) && node.argument) {
node.argument = t.memberExpression(t.callExpression(state.file.addHelper("define-property"), [
t.thisExpression(),
state.key,
node.argument
]), state.key, true);
node.argument = t.memberExpression(t.callExpression(state.file.addHelper("define-property"), [t.thisExpression(), state.key, node.argument]), state.key, true);
}

@@ -22,4 +18,3 @@ }

exports.Property =
exports.MethodDefinition = function (node, parent, scope, file) {
exports.Property = exports.MethodDefinition = function (node, parent, scope, file) {
if (node.kind !== "memo") return;

@@ -38,3 +33,3 @@ node.kind = "get";

var state = {
key: key,
key: key,
file: file

@@ -46,2 +41,2 @@ };

return node;
};
};

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

exports.BlockStatement = function (node, parent, scope, file) {
if ((t.isFunction(parent) && parent.body === node) || t.isExportDeclaration(parent)) {
if (t.isFunction(parent) && parent.body === node || t.isExportDeclaration(parent)) {
return;

@@ -15,5 +15,3 @@ }

var declar = t.variableDeclaration("let", [
t.variableDeclarator(func.id, t.toExpression(func))
]);
var declar = t.variableDeclaration("let", [t.variableDeclarator(func.id, t.toExpression(func))]);

@@ -30,2 +28,2 @@ // hoist it up above everything else

}
};
};

@@ -5,2 +5,2 @@ "use strict";

exports.FunctionExpression = nameMethod.bare;
exports.FunctionExpression = nameMethod.bare;
"use strict";
var t = require("../../../types");
var t = require("../../../types");
var pull = require("lodash/array/pull");
var isProtoKey = function (node) {
var isProtoKey = function isProtoKey(node) {
return t.isLiteral(t.toComputedKey(node, node.key), { value: "__proto__" });
};
var isProtoAssignmentExpression = function (node) {
var isProtoAssignmentExpression = function isProtoAssignmentExpression(node) {
var left = node.left;

@@ -15,3 +15,3 @@ return t.isMemberExpression(left) && t.isLiteral(t.toComputedKey(left, left.property), { value: "__proto__" });

var buildDefaultsCallExpression = function (expr, ref, file) {
var buildDefaultsCallExpression = function buildDefaultsCallExpression(expr, ref, file) {
return t.expressionStatement(t.callExpression(file.addHelper("defaults"), [ref, expr.right]));

@@ -27,4 +27,4 @@ };

var nodes = [];
var left = node.left.object;
var temp = scope.generateTempBasedOnNode(node.left.object);
var left = node.left.object;
var temp = scope.generateTempBasedOnNode(node.left.object);

@@ -64,2 +64,2 @@ nodes.push(t.expressionStatement(t.assignmentExpression("=", temp, left)));

}
};
};

@@ -14,7 +14,3 @@ "use strict";

var undefLiteral = t.literal("undefined");
return t.conditionalExpression(
t.binaryExpression("===", t.unaryExpression("typeof", node.argument), undefLiteral),
undefLiteral,
call
);
return t.conditionalExpression(t.binaryExpression("===", t.unaryExpression("typeof", node.argument), undefLiteral), undefLiteral, call);
} else {

@@ -24,2 +20,2 @@ return call;

}
};
};
"use strict";
var messages = require("../../../messages");
var t = require("../../../types");
var t = require("../../../types");
exports.check = t.isFor;
exports.ForInStatement =
exports.ForOfStatement = function (node, parent, scope, file) {
exports.ForInStatement = exports.ForOfStatement = function (node, parent, scope, file) {
var left = node.left;

@@ -15,2 +14,2 @@ if (t.isVariableDeclaration(left)) {

}
};
};

@@ -0,8 +1,10 @@

"use strict";
var messages = require("../../../messages");
var t = require("../../../types");
var t = require("../../../types");
// check if the input Literal `source` is an alternate casing of "react"
var check = function (source, file) {
var check = function check(source, file) {
if (t.isLiteral(source)) {
var name = source.value;
var name = source.value;
var lower = name.toLowerCase();

@@ -22,5 +24,4 @@

exports.ImportDeclaration =
exports.ExportDeclaration = function (node, parent, scope, file) {
exports.ImportDeclaration = exports.ExportDeclaration = function (node, parent, scope, file) {
check(node.source, file);
};
};

@@ -9,7 +9,6 @@ "use strict";

exports.MethodDefinition =
exports.Property = function (node, parent, scope, file) {
exports.MethodDefinition = exports.Property = function (node, parent, scope, file) {
if (node.kind === "set" && node.value.params.length !== 1) {
throw file.errorWithNode(node.value, messages.get("settersInvalidParamLength"));
}
};
};
"use strict";
var levenshtein = require("leven");
var messages = require("../../../messages");
var t = require("../../../types");
var messages = require("../../../messages");
var t = require("../../../types");

@@ -40,2 +40,2 @@ exports.optional = true;

throw file.errorWithNode(node, msg, ReferenceError);
};
};

@@ -6,12 +6,12 @@ "use strict";

var TraversalPath = require("./path");
var flatten = require("lodash/array/flatten");
var compact = require("lodash/array/compact");
var flatten = require("lodash/array/flatten");
var compact = require("lodash/array/compact");
function TraversalContext(scope, opts, state, parentPath) {
this.shouldFlatten = false;
this.parentPath = parentPath;
this.parentPath = parentPath;
this.scope = scope;
this.state = state;
this.opts = opts;
this.opts = opts;
}

@@ -55,2 +55,2 @@

}
};
};

@@ -6,4 +6,4 @@ "use strict";

var TraversalContext = require("./context");
var includes = require("lodash/collection/includes");
var t = require("../types");
var includes = require("lodash/collection/includes");
var t = require("../types");

@@ -20,4 +20,4 @@ function traverse(parent, opts, scope, state) {

if (!opts) opts = {};
if (!opts.enter) opts.enter = function () { };
if (!opts.exit) opts.exit = function () { };
if (!opts.enter) opts.enter = function () {};
if (!opts.exit) opts.exit = function () {};

@@ -113,3 +113,3 @@ // array of nodes

var state = {
has: false,
has: false,
type: type

@@ -124,2 +124,2 @@ };

return state.has;
};
};

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

var includes = require("lodash/collection/includes");
var Scope = require("./scope");
var t = require("../types");
var Scope = require("./scope");
var t = require("../types");
function TraversalPath(context, parent, container, key) {
this.shouldRemove = false;
this.shouldSkip = false;
this.shouldStop = false;
this.shouldSkip = false;
this.shouldStop = false;
this.parentPath = context.parentPath;
this.context = context;
this.state = this.context.state;
this.opts = this.context.opts;
this.context = context;
this.state = this.context.state;
this.opts = this.context.opts;
this.container = container;
this.key = key;
this.key = key;
this.parent = parent;
this.state = context.state;
this.state = context.state;

@@ -47,3 +47,3 @@ this.setScope();

this.shouldRemove = true;
this.shouldSkip = true;
this.shouldSkip = true;
};

@@ -65,7 +65,7 @@

Object.defineProperty(TraversalPath.prototype, "node", {
get: function () {
get: function get() {
return this.container[this.key];
},
set: function (replacement) {
set: function set(replacement) {
var isArray = Array.isArray(replacement);

@@ -110,3 +110,3 @@

var opts = this.opts;
var fn = opts[key] || opts;
var fn = opts[key] || opts;
if (opts[node.type]) fn = opts[node.type][key] || fn;

@@ -159,2 +159,2 @@

return t.isReferencedIdentifier(this.node);
};
};

@@ -9,8 +9,8 @@ "use strict";

var messages = require("../messages");
var globals = require("globals");
var flatten = require("lodash/array/flatten");
var extend = require("lodash/object/extend");
var object = require("../helpers/object");
var each = require("lodash/collection/each");
var t = require("../types");
var globals = require("globals");
var flatten = require("lodash/array/flatten");
var extend = require("lodash/object/extend");
var object = require("../helpers/object");
var each = require("lodash/collection/each");
var t = require("../types");

@@ -29,6 +29,6 @@ /**

this.parent = parent;
this.file = parent ? parent.file : file;
this.file = parent ? parent.file : file;
this.parentBlock = parentBlock;
this.block = block;
this.block = block;

@@ -123,3 +123,13 @@ this.crawl();

var add = function (node) {
var add = (function (_add) {
var _addWrapper = function add() {
return _add.apply(this, arguments);
};
_addWrapper.toString = function () {
return _add.toString();
};
return _addWrapper;
})(function (node) {
if (t.isMemberExpression(node)) {

@@ -135,3 +145,3 @@ add(node.object);

}
};
});

@@ -188,3 +198,3 @@ add(node);

scope.traverse(scope.block, {
enter: function (node, parent, scope) {
enter: function enter(node, parent, scope) {
if (t.isReferencedIdentifier(node, parent) && node.name === oldName) {

@@ -362,8 +372,8 @@ node.name = newName;

typeAnnotationInferred: typeInfo.inferred,
typeAnnotation: typeInfo.annotation,
reassigned: false,
identifier: id,
scope: this,
node: node,
kind: kind
typeAnnotation: typeInfo.annotation,
reassigned: false,
identifier: id,
scope: this,
node: node,
kind: kind
};

@@ -381,3 +391,3 @@ }

var functionVariableVisitor = {
enter: function (node, parent, scope, state) {
enter: function enter(node, parent, scope, state) {
if (t.isFor(node)) {

@@ -423,3 +433,3 @@ each(t.FOR_INIT_KEYS, function (key) {

var programReferenceVisitor = {
enter: function (node, parent, scope, state) {
enter: function enter(node, parent, scope, state) {
if (t.isReferencedIdentifier(node, parent) && !scope.hasBinding(node.name)) {

@@ -429,3 +439,3 @@ state.addGlobal(node);

state.addGlobal(node);
} else if (t.isAssignmentExpression(node) || t.isUpdateExpression(node) || (t.isUnaryExpression(node) && node.operator === "delete")) {
} else if (t.isAssignmentExpression(node) || t.isUpdateExpression(node) || t.isUnaryExpression(node) && node.operator === "delete") {
scope.registerBindingReassignment(node);

@@ -437,3 +447,3 @@ }

var blockVariableVisitor = {
enter: function (node, parent, scope, state) {
enter: function enter(node, parent, scope, state) {
if (t.isFunctionDeclaration(node) || t.isBlockScoped(node)) {

@@ -448,3 +458,3 @@ state.registerDeclaration(node);

Scope.prototype.crawl = function () {
var block = this.block;
var block = this.block;
var i;

@@ -462,3 +472,3 @@

bindings: object(),
globals: object()
globals: object()
};

@@ -521,3 +531,3 @@

blockId: block.id,
scope: this
scope: this
});

@@ -659,2 +669,2 @@ }

return this.parent && this.parent.hasBinding(name);
};
};
"use strict";
var toFastProperties = require("../helpers/to-fast-properties");
var isString = require("lodash/lang/isString");
var compact = require("lodash/array/compact");
var esutils = require("esutils");
var object = require("../helpers/object");
var each = require("lodash/collection/each");
var uniq = require("lodash/array/uniq");
var isString = require("lodash/lang/isString");
var compact = require("lodash/array/compact");
var esutils = require("esutils");
var object = require("../helpers/object");
var each = require("lodash/collection/each");
var uniq = require("lodash/array/uniq");

@@ -35,7 +35,7 @@ var t = exports;

t.STATEMENT_OR_BLOCK_KEYS = ["consequent", "body"];
t.NATIVE_TYPE_NAMES = ["Array", "Object", "Number", "Boolean", "Date", "Array", "String"];
t.FOR_INIT_KEYS = ["left", "init"];
t.NATIVE_TYPE_NAMES = ["Array", "Object", "Number", "Boolean", "Date", "Array", "String"];
t.FOR_INIT_KEYS = ["left", "init"];
t.VISITOR_KEYS = require("./visitor-keys");
t.ALIAS_KEYS = require("./alias-keys");
t.ALIAS_KEYS = require("./alias-keys");

@@ -177,3 +177,3 @@ t.FLIPPED_ALIAS_KEYS = {};

exprs.push(node);
} if (t.isExpressionStatement(node)) {
}if (t.isExpressionStatement(node)) {
exprs.push(node.expression);

@@ -231,3 +231,3 @@ } else if (t.isVariableDeclaration(node)) {

t.appendToMemberExpression = function (member, append, computed) {
member.object = t.memberExpression(member.object, member.property, member.computed);
member.object = t.memberExpression(member.object, member.property, member.computed);
member.property = append;

@@ -586,3 +586,3 @@ member.computed = !!computed;

var search = [].concat(node);
var ids = object();
var ids = object();

@@ -697,3 +697,3 @@ while (search.length) {

each(t.COMMENT_KEYS, function (key) {
child[key] = uniq(compact([].concat(child[key], parent[key])));
child[key] = uniq(compact([].concat(child[key], parent[key])));
});

@@ -713,7 +713,7 @@ return child;

child._declarations = parent._declarations;
child._scopeInfo = parent._scopeInfo;
child.range = parent.range;
child.start = parent.start;
child.loc = parent.loc;
child.end = parent.end;
child._scopeInfo = parent._scopeInfo;
child.range = parent.range;
child.start = parent.start;
child.loc = parent.loc;
child.end = parent.end;
t.inheritsComments(child, parent);

@@ -733,3 +733,3 @@ return child;

var add = function (node) {
var add = function add(node) {
nodes = nodes.concat(t.getLastStatements(node));

@@ -771,3 +771,3 @@ };

t.getSpecifierId = function (specifier) {
if (specifier.default) {
if (specifier["default"]) {
return t.identifier("default");

@@ -787,3 +787,3 @@ } else {

t.isSpecifierDefault = function (specifier) {
return specifier.default || t.isIdentifier(specifier.id) && specifier.id.name === "default";
return specifier["default"] || t.isIdentifier(specifier.id) && specifier.id.name === "default";
};

@@ -814,2 +814,2 @@

toFastProperties(t);
toFastProperties(t.VISITOR_KEYS);
toFastProperties(t.VISITOR_KEYS);

@@ -5,16 +5,17 @@ "use strict";

var cloneDeep = require("lodash/lang/cloneDeep");
var contains = require("lodash/collection/contains");
var traverse = require("./traversal");
var isString = require("lodash/lang/isString");
var isRegExp = require("lodash/lang/isRegExp");
var isEmpty = require("lodash/lang/isEmpty");
var parse = require("./helpers/parse");
var debug = require("debug/node");
var path = require("path");
var util = require("util");
var each = require("lodash/collection/each");
var has = require("lodash/object/has");
var fs = require("fs");
var t = require("./types");
var cloneDeep = require("lodash/lang/cloneDeep");
var isBoolean = require("lodash/lang/isBoolean");
var contains = require("lodash/collection/contains");
var traverse = require("./traversal");
var isString = require("lodash/lang/isString");
var isRegExp = require("lodash/lang/isRegExp");
var isEmpty = require("lodash/lang/isEmpty");
var parse = require("./helpers/parse");
var debug = require("debug/node");
var path = require("path");
var util = require("util");
var each = require("lodash/collection/each");
var has = require("lodash/object/has");
var fs = require("fs");
var t = require("./types");

@@ -55,2 +56,3 @@ exports.inherits = util.inherits;

if (!val) return [];
if (isBoolean(val)) return [val];
if (isString(val)) return exports.list(val);

@@ -68,3 +70,3 @@ if (Array.isArray(val)) return val;

var templateVisitor = {
enter: function (node, parent, scope, nodes) {
enter: function enter(node, parent, scope, nodes) {
if (t.isExpressionStatement(node)) {

@@ -111,3 +113,3 @@ node = node.expression;

var loadTemplates = function () {
var loadTemplates = function loadTemplates() {
var templates = {};

@@ -117,5 +119,3 @@

if (!fs.existsSync(templatesLoc)) {
throw new Error("no templates directory - this is most likely the " +
"result of a broken `npm publish`. Please report to " +
"https://github.com/babel/babel/issues");
throw new Error("no templates directory - this is most likely the " + "result of a broken `npm publish`. Please report to " + "https://github.com/babel/babel/issues");
}

@@ -126,4 +126,4 @@

var key = path.basename(name, path.extname(name));
var loc = templatesLoc + "/" + name;
var key = path.basename(name, path.extname(name));
var loc = templatesLoc + "/" + name;
var code = fs.readFileSync(loc, "utf8");

@@ -143,2 +143,2 @@

exports.templates = loadTemplates();
}
}
{
"name": "babel",
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
"version": "4.5.0",
"version": "4.5.1",
"author": "Sebastian McKenzie <sebmck@gmail.com>",

@@ -70,2 +70,3 @@ "homepage": "https://babeljs.io/",

"devDependencies": {
"babel": "4.5.0",
"browserify": "^8.1.3",

@@ -75,3 +76,2 @@ "chai": "^2.0.0",

"istanbul": "^0.3.5",
"jscs": "^1.11.3",
"jshint": "^2.6.0",

@@ -78,0 +78,0 @@ "jshint-stylish": "^1.0.0",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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