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.6.1 to 4.6.3

16

bin/babel/dir.js

@@ -34,2 +34,10 @@ var outputFileSync = require("output-file-sync");

var handleFile = function (src, filename) {
if (util.canCompile(filename)) {
write(src, filename);
} else if (commander.copyFiles) {
outputFileSync(path.join(commander.outDir, filename), fs.readFileSync(src));
}
};
var handle = function (filename) {

@@ -45,7 +53,3 @@ if (!fs.existsSync(filename)) return;

var src = path.join(dirname, filename);
if (util.canCompile(filename)) {
write(src, filename);
} else if (commander.copyFiles) {
outputFileSync(path.join(commander.outDir, filename), fs.readFileSync(src));
}
handleFile(src, filename);
});

@@ -70,3 +74,3 @@ } else {

try {
if (util.canCompile(filename)) write(filename, relative);
handleFile(filename, relative);
} catch (err) {

@@ -73,0 +77,0 @@ console.error(err.stack);

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

@@ -13,11 +15,21 @@

print(node.typeParameters);
if (node.superClass) {
this.push(" extends ");
print(node.superClass);
print(node.superTypeParameters);
}
if (node["implements"]) {
this.push(" implements ");
print.join(node["implements"], { separator: ", " });
}
this.space();
print(node.body);
};
}
exports.ClassExpression = ClassDeclaration;
function ClassBody(node, print) {

@@ -24,0 +36,0 @@ if (node.body.length === 0) {

"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 () {};
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
// todo: implement these once we have a `--keep-types` option
exports.AnyTypeAnnotation = AnyTypeAnnotation;
exports.ArrayTypeAnnotation = ArrayTypeAnnotation;
exports.BooleanTypeAnnotation = BooleanTypeAnnotation;
exports.ClassProperty = ClassProperty;
exports.DeclareClass = DeclareClass;
exports.DeclareFunction = DeclareFunction;
exports.DeclareModule = DeclareModule;
exports.DeclareVariable = DeclareVariable;
exports.FunctionTypeAnnotation = FunctionTypeAnnotation;
exports.FunctionTypeParam = FunctionTypeParam;
exports.InterfaceExtends = InterfaceExtends;
exports._interfaceish = _interfaceish;
exports.InterfaceDeclaration = InterfaceDeclaration;
exports.IntersectionTypeAnnotation = IntersectionTypeAnnotation;
exports.NullableTypeAnnotation = NullableTypeAnnotation;
exports.NumberTypeAnnotation = NumberTypeAnnotation;
exports.StringLiteralTypeAnnotation = StringLiteralTypeAnnotation;
exports.StringTypeAnnotation = StringTypeAnnotation;
exports.TupleTypeAnnotation = TupleTypeAnnotation;
exports.TypeofTypeAnnotation = TypeofTypeAnnotation;
exports.TypeAlias = TypeAlias;
exports.TypeAnnotation = TypeAnnotation;
exports.TypeParameterInstantiation = TypeParameterInstantiation;
exports.ObjectTypeAnnotation = ObjectTypeAnnotation;
exports.ObjectTypeCallProperty = ObjectTypeCallProperty;
exports.ObjectTypeIndexer = ObjectTypeIndexer;
exports.ObjectTypeProperty = ObjectTypeProperty;
exports.QualifiedTypeIdentifier = QualifiedTypeIdentifier;
exports.UnionTypeAnnotation = UnionTypeAnnotation;
exports.TypeCastExpression = TypeCastExpression;
exports.VoidTypeAnnotation = VoidTypeAnnotation;
var t = _interopRequire(require("../../types"));
function AnyTypeAnnotation() {
this.push("any");
}
function ArrayTypeAnnotation(node, print) {
print(node.elementType);
this.push("[");
this.push("]");
}
function BooleanTypeAnnotation(node) {
this.push("bool");
}
function ClassProperty(node, print) {
if (node["static"]) this.push("static ");
print(node.key);
print(node.typeAnnotation);
this.semicolon();
}
function DeclareClass(node, print) {
this.push("declare class ");
this._interfaceish(node, print);
}
function DeclareFunction(node, print) {
this.push("declare function ");
print(node.id);
print(node.id.typeAnnotation.typeAnnotation);
this.semicolon();
}
function DeclareModule(node, print) {
this.push("declare module ");
print(node.id);
this.space();
print(node.body);
}
function DeclareVariable(node, print) {
this.push("declare var ");
print(node.id);
print(node.id.typeAnnotation);
this.semicolon();
}
function FunctionTypeAnnotation(node, print, parent) {
print(node.typeParameters);
this.push("(");
print.list(node.params);
if (node.rest) {
if (node.params.length) {
this.push(",");
this.space();
}
this.push("...");
print(node.rest);
}
this.push(")");
// this node type is overloaded, not sure why but it makes it EXTREMELY annoying
if (parent.type === "ObjectTypeProperty" || parent.type === "ObjectTypeCallProperty" || parent.type === "DeclareFunction") {
this.push(":");
} else {
this.space();
this.push("=>");
}
this.space();
print(node.returnType);
}
function FunctionTypeParam(node, print) {
print(node.name);
if (node.optional) this.push("?");
this.push(":");
this.space();
print(node.typeAnnotation);
}
function InterfaceExtends(node, print) {
print(node.id);
print(node.typeParameters);
}
exports.ClassImplements = InterfaceExtends;
exports.GenericTypeAnnotation = InterfaceExtends;
function _interfaceish(node, print) {
print(node.id);
print(node.typeParameters);
if (node["extends"].length) {
this.push(" extends ");
print.join(node["extends"], { separator: ", " });
}
this.space();
print(node.body);
}
function InterfaceDeclaration(node, print) {
this.push("interface ");
this._interfaceish(node, print);
}
function IntersectionTypeAnnotation(node, print) {
print.join(node.types, { separator: " & " });
}
function NullableTypeAnnotation(node, print) {
this.push("?");
print(node.typeAnnotation);
}
function NumberTypeAnnotation() {
this.push("number");
}
function StringLiteralTypeAnnotation(node) {
this._stringLiteral(node.value);
}
function StringTypeAnnotation() {
this.push("string");
}
function TupleTypeAnnotation(node, print) {
this.push("[");
print.join(node.types, { separator: ", " });
this.push("]");
}
function TypeofTypeAnnotation(node, print) {
this.push("typeof ");
print(node.argument);
}
function TypeAlias(node, print) {
this.push("type ");
print(node.id);
print(node.typeParameters);
this.space();
this.push("=");
this.space();
print(node.right);
this.semicolon();
}
function TypeAnnotation(node, print) {
this.push(":");
this.space();
if (node.optional) this.push("?");
print(node.typeAnnotation);
}
function TypeParameterInstantiation(node, print) {
this.push("<");
print.join(node.params, { separator: ", " });
this.push(">");
}
exports.TypeParameterDeclaration = TypeParameterInstantiation;
function ObjectTypeAnnotation(node, print) {
this.push("{");
var props = node.properties.concat(node.callProperties, node.indexers);
if (props.length) {
this.space();
print.list(props, { indent: true, separator: "; " });
this.space();
}
this.push("}");
}
function ObjectTypeCallProperty(node, print) {
if (node["static"]) this.push("static ");
print(node.value);
}
function ObjectTypeIndexer(node, print) {
if (node["static"]) this.push("static ");
this.push("[");
print(node.id);
this.push(":");
this.space();
print(node.key);
this.push("]");
this.push(":");
this.space();
print(node.value);
}
function ObjectTypeProperty(node, print) {
if (node["static"]) this.push("static ");
print(node.key);
if (node.optional) this.push("?");
if (!t.isFunctionTypeAnnotation(node.value)) {
this.push(":");
this.space();
}
print(node.value);
}
function QualifiedTypeIdentifier(node, print) {
print(node.qualification);
this.push(".");
print(node.id);
}
function UnionTypeAnnotation(node, print) {
print.join(node.types, { separator: " | " });
}
function TypeCastExpression(node, print) {
this.push("(");
print(node.expression);
print(node.typeAnnotation);
this.push(")");
}
function VoidTypeAnnotation(node) {
this.push("void");
}
exports.__esModule = true;

@@ -12,5 +12,17 @@ "use strict";

function _params(node, print) {
var _this = this;
print(node.typeParameters);
this.push("(");
print.list(node.params);
print.list(node.params, {
iterator: function (node) {
if (node.optional) _this.push("?");
print(node.typeAnnotation);
}
});
this.push(")");
if (node.returnType) {
print(node.returnType);
}
}

@@ -17,0 +29,0 @@

@@ -235,4 +235,5 @@ "use strict";

function VariableDeclarator(node, print) {
print(node.id);
print(node.id.typeAnnotation);
if (node.init) {
print(node.id);
this.space();

@@ -242,4 +243,2 @@ this.push("=");

print(node.init);
} else {
print(node.id);
}

@@ -246,0 +245,0 @@ }

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

exports.Literal = Literal;
exports._stringLiteral = _stringLiteral;

@@ -94,10 +95,3 @@ var each = _interopRequire(require("lodash/collection/each"));

if (type === "string") {
val = JSON.stringify(val);
// escape illegal js but valid json unicode characters
val = val.replace(/[\u000A\u000D\u2028\u2029]/g, function (c) {
return "\\u" + ("0000" + c.charCodeAt(0).toString(16)).slice(-4);
});
this.push(val);
this._stringLiteral(val);
} else if (type === "number") {

@@ -114,2 +108,13 @@ this.push(val + "");

function _stringLiteral(val) {
val = JSON.stringify(val);
// escape illegal js but valid json unicode characters
val = val.replace(/[\u000A\u000D\u2028\u2029]/g, function (c) {
return "\\u" + ("0000" + c.charCodeAt(0).toString(16)).slice(-4);
});
this.push(val);
}
exports.__esModule = true;

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

if (!node) return "";
if (!node) return;

@@ -154,0 +154,0 @@ if (parent && parent._compact) {

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

exports.NullableTypeAnnotation = NullableTypeAnnotation;
exports.UpdateExpression = UpdateExpression;

@@ -15,2 +16,3 @@ exports.ObjectExpression = ObjectExpression;

exports.FunctionExpression = FunctionExpression;
exports.ConditionalExpression = ConditionalExpression;

@@ -29,2 +31,8 @@ var each = _interopRequire(require("lodash/collection/each"));

function NullableTypeAnnotation(node, parent) {
return t.isArrayTypeAnnotation(parent);
}
exports.FunctionTypeAnnotation = NullableTypeAnnotation;
function UpdateExpression(node, parent) {

@@ -142,3 +150,3 @@ if (t.isMemberExpression(parent) && parent.object === node) {

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

@@ -167,3 +175,5 @@ return true;

return false;
};
}
exports.AssignmentExpression = ConditionalExpression;
exports.__esModule = true;

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

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

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

});
};
}

@@ -54,0 +54,0 @@ var File = (function () {

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

var react = _interopRequire(require("./react"));
var react = _interopRequireWildcard(require("./react"));

@@ -21,0 +21,0 @@ var t = _interopRequire(require("../../types"));

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

exports.push = push;
exports.build = build;
var cloneDeep = _interopRequire(require("lodash/lang/cloneDeep"));

@@ -18,3 +21,3 @@

exports.push = function (mutatorMap, key, kind, computed, value) {
function push(mutatorMap, key, kind, computed, value) {
var alias;

@@ -45,5 +48,5 @@

map[kind] = value;
};
}
exports.build = function (mutatorMap) {
function build(mutatorMap) {
var objExpr = t.objectExpression([]);

@@ -85,2 +88,4 @@

return objExpr;
};
}
exports.__esModule = true;

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

exports.property = property;
exports.bare = bare;
var getFunctionArity = _interopRequire(require("./get-function-arity"));

@@ -92,3 +95,3 @@

exports.property = function (node, file, scope) {
function property(node, file, scope) {
var key = t.toComputedKey(node, node.key);

@@ -103,5 +106,5 @@ if (!t.isLiteral(key)) return node; // we can't set a function id with this

node.value = wrap(state, method, id, scope);
};
}
exports.bare = function (node, parent, scope) {
function bare(node, parent, scope) {
// has an `id` so we don't need to infer one

@@ -128,4 +131,6 @@ if (node.id) return;

return wrap(state, node, id, scope);
};
}
exports.__esModule = true;
// otherwise it's defined somewhere in scope like:

@@ -132,0 +137,0 @@ //

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

exports.isCreateClass = isCreateClass;
exports.isCompatTag = isCompatTag;
var t = _interopRequire(require("../../types"));

@@ -10,3 +13,3 @@

exports.isCreateClass = function (node) {
function isCreateClass(node) {
if (!node || !t.isCallExpression(node)) return false;

@@ -26,8 +29,10 @@

return true;
};
}
exports.isReactComponent = t.buildMatchMemberExpression("React.Component");
var isReactComponent = exports.isReactComponent = t.buildMatchMemberExpression("React.Component");
exports.isCompatTag = function (tagName) {
function isCompatTag(tagName) {
return tagName && /^[a-z]|\-/.test(tagName);
};
}
exports.__esModule = true;

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

exports.has = has;
exports.wrap = wrap;
var t = _interopRequire(require("../../types"));
exports.has = function (node) {
function has(node) {
var first = node.body[0];
return t.isExpressionStatement(first) && t.isLiteral(first.expression, { value: "use strict" });
};
}
exports.wrap = function (node, callback) {
function wrap(node, callback) {
var useStrictNode;

@@ -24,2 +27,4 @@ if (exports.has(node)) {

}
};
}
exports.__esModule = true;

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

var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { "default": obj }; };
exports.check = check;
exports.ObjectExpression = ObjectExpression;
var defineMap = _interopRequire(require("../../helpers/define-map"));
var defineMap = _interopRequireWildcard(require("../../helpers/define-map"));

@@ -11,0 +13,0 @@ var t = _interopRequire(require("../../../types"));

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

exports.check = t.isArrowFunctionExpression;
var check = exports.check = t.isArrowFunctionExpression;

@@ -12,0 +12,0 @@ function ArrowFunctionExpression(node) {

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

exports.BlockStatement = BlockStatement;
var t = _interopRequire(require("../../../types"));

@@ -31,5 +33,5 @@

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

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

scope.traverse(node, visitor, state);
};
}
exports.Program = BlockStatement;
exports.Loop = BlockStatement;
exports.__esModule = true;

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

exports.check = check;
exports.VariableDeclaration = VariableDeclaration;
exports.Loop = Loop;
exports.BlockStatement = BlockStatement;
var traverse = _interopRequire(require("../../../traversal"));

@@ -22,7 +27,3 @@

exports.check = function (node) {
return t.isVariableDeclaration(node) && (node.kind === "let" || node.kind === "const");
};
var isLet = function isLet(node, parent) {
function isLet(node, parent) {
if (!t.isVariableDeclaration(node)) return false;

@@ -44,19 +45,23 @@ if (node._let) return true;

return true;
};
}
var isLetInitable = function isLetInitable(node, parent) {
function isLetInitable(node, parent) {
return !t.isFor(parent) || !t.isFor(parent, { left: node });
};
}
var isVar = function isVar(node, parent) {
function isVar(node, parent) {
return t.isVariableDeclaration(node, { kind: "var" }) && !isLet(node, parent);
};
}
var standardizeLets = function standardizeLets(declars) {
function standardizeLets(declars) {
for (var i = 0; i < declars.length; i++) {
delete declars[i]._let;
}
};
}
exports.VariableDeclaration = function (node, parent, scope, file) {
function check(node) {
return t.isVariableDeclaration(node) && (node.kind === "let" || node.kind === "const");
}
function VariableDeclaration(node, parent, scope, file) {
if (!isLet(node, parent)) return;

@@ -81,5 +86,5 @@

}
};
}
exports.Loop = function (node, parent, scope, file) {
function Loop(node, parent, scope, file) {
var init = node.left || node.init;

@@ -92,5 +97,5 @@ if (isLet(init, node)) {

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

@@ -100,4 +105,6 @@ var blockScoping = new BlockScoping(false, block, parent, scope, file);

}
};
}
exports.Program = BlockStatement;
function replace(node, parent, scope, remaps) {

@@ -577,2 +584,4 @@ if (!t.isReferencedIdentifier(node, parent)) return;

return BlockScoping;
})();
})();
exports.__esModule = true;

@@ -9,7 +9,10 @@ "use strict";

exports.ClassDeclaration = ClassDeclaration;
exports.ClassExpression = ClassExpression;
var ReplaceSupers = _interopRequire(require("../../helpers/replace-supers"));
var nameMethod = _interopRequire(require("../../helpers/name-method"));
var nameMethod = _interopRequireWildcard(require("../../helpers/name-method"));
var defineMap = _interopRequire(require("../../helpers/define-map"));
var defineMap = _interopRequireWildcard(require("../../helpers/define-map"));

@@ -22,9 +25,9 @@ var messages = _interopRequireWildcard(require("../../../messages"));

exports.check = t.isClass;
var check = exports.check = t.isClass;
exports.ClassDeclaration = function (node, parent, scope, file) {
function ClassDeclaration(node, parent, scope, file) {
return new ClassTransformer(node, file, scope, true).run();
};
}
exports.ClassExpression = function (node, parent, scope, file) {
function ClassExpression(node, parent, scope, file) {
if (!node.id) {

@@ -43,3 +46,3 @@ if (t.isProperty(parent) && parent.value === node && !parent.computed && t.isIdentifier(parent.key)) {

return new ClassTransformer(node, file, scope, false).run();
};
}

@@ -308,2 +311,4 @@ var ClassTransformer = (function () {

return ClassTransformer;
})();
})();
exports.__esModule = true;

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

exports.check = check;
exports.Scopable = Scopable;
exports.VariableDeclaration = VariableDeclaration;
var messages = _interopRequireWildcard(require("../../../messages"));

@@ -12,5 +16,5 @@

exports.check = function (node) {
function check(node) {
return t.isVariableDeclaration(node, { kind: "const" });
};
}

@@ -48,3 +52,3 @@ var visitor = {

exports.Scopable = function (node, parent, scope, file) {
function Scopable(node, parent, scope, file) {
scope.traverse(node, visitor, {

@@ -54,6 +58,8 @@ constants: scope.getAllBindingsOfKind("const"),

});
};
}
exports.VariableDeclaration = function (node) {
function VariableDeclaration(node) {
if (node.kind === "const") node.kind = "let";
};
}
exports.__esModule = true;

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

exports.ForOfStatement = ForOfStatement;
exports.CatchClause = CatchClause;
exports.ExpressionStatement = ExpressionStatement;
exports.AssignmentExpression = AssignmentExpression;
exports.VariableDeclaration = VariableDeclaration;
var messages = _interopRequireWildcard(require("../../../messages"));

@@ -14,5 +20,5 @@

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

@@ -57,4 +63,6 @@

block.body = nodes.concat(block.body);
};
}
exports.ForInStatement = ForOfStatement;
exports.Function = function (node, parent, scope, file) {

@@ -90,3 +98,3 @@ var nodes = [];

exports.CatchClause = function (node, parent, scope, file) {
function CatchClause(node, parent, scope, file) {
var pattern = node.param;

@@ -111,5 +119,5 @@ if (!t.isPattern(pattern)) return;

return node;
};
}
exports.ExpressionStatement = function (node, parent, scope, file) {
function ExpressionStatement(node, parent, scope, file) {
var expr = node.expression;

@@ -134,5 +142,5 @@ if (expr.type !== "AssignmentExpression") return;

return nodes;
};
}
exports.AssignmentExpression = function (node, parent, scope, file) {
function AssignmentExpression(node, parent, scope, file) {
if (!t.isPattern(node.left)) return;

@@ -160,5 +168,5 @@

return t.toSequenceExpression(nodes, scope);
};
}
var variableDeclarationHasPattern = function variableDeclarationHasPattern(node) {
function variableDeclarationHasPattern(node) {
for (var i = 0; i < node.declarations.length; i++) {

@@ -170,5 +178,5 @@ if (t.isPattern(node.declarations[i].id)) {

return false;
};
}
exports.VariableDeclaration = function (node, parent, scope, file) {
function VariableDeclaration(node, parent, scope, file) {
if (t.isForInStatement(parent) || t.isForOfStatement(parent)) return;

@@ -227,4 +235,6 @@ if (!variableDeclarationHasPattern(node)) return;

return nodes;
};
}
;
var hasRest = function hasRest(pattern) {

@@ -478,2 +488,4 @@ for (var i = 0; i < pattern.elements.length; i++) {

return DestructuringTransformer;
})();
})();
exports.__esModule = true;

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

exports.ForOfStatement = ForOfStatement;
var messages = _interopRequireWildcard(require("../../../messages"));

@@ -14,5 +16,5 @@

exports.check = t.isForOfStatement;
var check = exports.check = t.isForOfStatement;
exports.ForOfStatement = function (node, parent, scope, file) {
function ForOfStatement(node, parent, scope, file) {
var callback = spec;

@@ -46,3 +48,3 @@ if (file.isLoose("es6.forOf")) callback = loose;

return build.node;
};
}

@@ -172,2 +174,3 @@ var breakVisitor = {

};
};
};
exports.__esModule = true;

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

exports.check = t.isRestElement;
var check = exports.check = t.isRestElement;

@@ -40,4 +40,3 @@ var memberExpressionOptimisationVisitor = {

if (isNumber(prop.value) || t.isUnaryExpression(prop) || t.isBinaryExpression(prop)) {
optimizeMemberExpression(node, parent, state.method.params.length);
state.hasShorthand = true;
state.candidates.push(this);
return;

@@ -47,7 +46,8 @@ }

state.longForm = true;
state.canOptimise = false;
this.stop();
}
};
function optimizeMemberExpression(node, parent, offset) {
function optimizeMemberExpression(parent, offset) {
var newExpr;

@@ -57,3 +57,2 @@ var prop = parent.property;

if (t.isLiteral(prop)) {
node.name = "arguments";
prop.value += offset;

@@ -63,3 +62,2 @@ prop.raw = String(prop.value);

// // UnaryExpression, BinaryExpression
node.name = "arguments";
newExpr = t.binaryExpression("+", prop, t.literal(offset));

@@ -99,6 +97,7 @@ parent.property = newExpr;

outerBinding: scope.getBindingIdentifier(rest.name),
hasShorthand: true,
longForm: false,
canOptimise: true,
candidates: [],
method: node,
name: rest.name };
name: rest.name
};

@@ -108,3 +107,10 @@ scope.traverse(node, memberExpressionOptimisationVisitor, state);

// we only have shorthands and there's no other references
if (!state.longForm && state.hasShorthand) return;
if (state.canOptimise && state.candidates.length) {
for (var i = 0; i < state.candidates.length; i++) {
var candidate = state.candidates[i];
candidate.node = argsId;
optimizeMemberExpression(candidate.parent, node.params.length);
}
return;
}

@@ -146,2 +152,3 @@ //

node.body.body.unshift(loop);
};
};
exports.__esModule = true;

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

exports.check = t.isSpreadElement;
function getSpreadLiteral(spread, scope) {

@@ -55,2 +53,4 @@ return scope.toArray(spread.argument, true);

var check = exports.check = t.isSpreadElement;
function ArrayExpression(node, parent, scope) {

@@ -57,0 +57,0 @@ var elements = node.elements;

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

exports.Program = Program;
exports.FunctionDeclaration = FunctionDeclaration;
var t = _interopRequire(require("../../../types"));

@@ -83,9 +86,11 @@

exports.Program = function (node, parent, scope) {
function Program(node, parent, scope) {
go(function () {
return node.body;
}, node, scope);
};
}
exports.FunctionDeclaration = exports.FunctionExpression = function (node, parent, scope) {
;
function FunctionDeclaration(node, parent, scope) {
go(function () {

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

}, node, scope);
};
}
exports.FunctionExpression = FunctionDeclaration;
exports.__esModule = true;

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

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

@@ -37,2 +37,5 @@ var hasChange = false;

}
};
};
exports.Program = BlockStatement;
exports.__esModule = true;
"use strict";
exports.SequenceExpression = SequenceExpression;
var SequenceExpression = exports.SequenceExpression = {
exit: function exit(node) {
if (node.expressions.length === 1) {
return node.expressions[0];
} else if (!node.expressions.length) {
this.remove();
}
}
};
function SequenceExpression(node) {
if (node.expressions.length === 1) {
return node.expressions[0];
var ExpressionStatement = exports.ExpressionStatement = {
exit: function exit(node) {
if (!node.expression) this.remove();
}
}
};
exports.__esModule = true;

@@ -5,4 +5,8 @@ "use strict";

var useStrict = _interopRequire(require("../../helpers/use-strict"));
var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { "default": obj }; };
exports.BlockStatement = BlockStatement;
var useStrict = _interopRequireWildcard(require("../../helpers/use-strict"));
var t = _interopRequire(require("../../../types"));

@@ -12,3 +16,3 @@

exports.BlockStatement = exports.Program = function (node, parent, scope, file) {
function BlockStatement(node, parent, scope, file) {
if (!node._declarations) return;

@@ -43,3 +47,5 @@

});
};
}
exports.Program = BlockStatement;
exports.__esModule = true;
"use strict";
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { "default": obj }; };
exports.Program = Program;
var useStrict = _interopRequire(require("../../helpers/use-strict"));
var useStrict = _interopRequireWildcard(require("../../helpers/use-strict"));

@@ -9,0 +9,0 @@ function Program(program, parent, scope, file) {

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

exports.Flow = Flow;
exports.ClassProperty = ClassProperty;
exports.Class = Class;
exports.TypeCastExpression = TypeCastExpression;

@@ -12,2 +15,15 @@ exports.ImportDeclaration = ImportDeclaration;

function Flow(node) {
this.remove();
}
function ClassProperty(node) {
node.typeAnnotation = null;
if (!node.value) this.remove();
}
function Class(node) {
node["implements"] = null;
}
function TypeCastExpression(node) {

@@ -14,0 +30,0 @@ return node.expression;

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

var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { "default": obj }; };
exports.manipulateOptions = manipulateOptions;
var react = _interopRequire(require("../../helpers/react"));
var react = _interopRequireWildcard(require("../../helpers/react"));

@@ -10,0 +12,0 @@ var t = _interopRequire(require("../../../types"));

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

var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { "default": obj }; };
exports.Program = Program;
var react = _interopRequire(require("../../helpers/react"));
var react = _interopRequireWildcard(require("../../helpers/react"));

@@ -10,0 +12,0 @@ var t = _interopRequire(require("../../../types"));

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

exports.Program = Program;
exports.FunctionExpression = FunctionExpression;
exports.ThisExpression = ThisExpression;

@@ -23,6 +24,8 @@ exports.CallExpression = CallExpression;

exports.FunctionDeclaration = exports.FunctionExpression = function () {
function FunctionExpression() {
this.skip();
};
}
exports.FunctionDeclaration = FunctionExpression;
function ThisExpression() {

@@ -29,0 +32,0 @@ return t.identifier("undefined");

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

exports.MethodDefinition = MethodDefinition;
var t = _interopRequire(require("../../../types"));

@@ -20,3 +22,3 @@

exports.Property = exports.MethodDefinition = function (node, parent, scope, file) {
function MethodDefinition(node, parent, scope, file) {
if (node.kind !== "memo") return;

@@ -42,3 +44,5 @@ node.kind = "get";

return node;
};
}
exports.Property = MethodDefinition;
exports.__esModule = true;

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

exports.ForOfStatement = ForOfStatement;
var messages = _interopRequireWildcard(require("../../../messages"));

@@ -16,3 +18,3 @@

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

@@ -23,3 +25,5 @@ if (t.isVariableDeclaration(left)) {

}
};
}
exports.ForInStatement = ForOfStatement;
exports.__esModule = true;

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

exports.check = check;
exports.Property = Property;

@@ -14,7 +15,9 @@ var messages = _interopRequireWildcard(require("../../../messages"));

exports.MethodDefinition = exports.Property = function (node, parent, scope, file) {
function Property(node, parent, scope, file) {
if (node.kind === "set" && node.value.params.length !== 1) {
throw file.errorWithNode(node.value, messages.get("settersInvalidParamLength"));
}
};
}
exports.MethodDefinition = Property;
exports.__esModule = true;

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

if (key === "body") {
if (key === "body" || key === "expressions") {
// we can safely compact this

@@ -59,0 +59,0 @@ node[key] = compact(node[key]);

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

for (var i = 0; i < aliases.length; i++) {
obj[aliases[i]] = fns;
var _obj = obj;
var _aliases$i = aliases[i];
if (!_obj[_aliases$i]) _obj[_aliases$i] = fns;
}

@@ -96,0 +98,0 @@ }

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

info.identifier.typeAnnotation = info.typeAnnotation = type;
info.typeAnnotation = type;
};

@@ -343,0 +343,0 @@

@@ -74,2 +74,35 @@ {

"AnyTypeAnnotation": ["Flow"],
"ArrayTypeAnnotation": ["Flow"],
"BooleanTypeAnnotation": ["Flow"],
"ClassImplements": ["Flow"],
"DeclareClass": ["Flow"],
"DeclareFunction": ["Flow"],
"DeclareModule": ["Flow"],
"DeclareVariable": ["Flow"],
"FunctionTypeAnnotation": ["Flow"],
"FunctionTypeParam": ["Flow"],
"GenericTypeAnnotation": ["Flow"],
"InterfaceExtends": ["Flow"],
"InterfaceDeclaration": ["Flow"],
"IntersectionTypeAnnotation": ["Flow"],
"NullableTypeAnnotation": ["Flow"],
"NumberTypeAnnotation": ["Flow"],
"StringLiteralTypeAnnotation": ["Flow"],
"StringTypeAnnotation": ["Flow"],
"TupleTypeAnnotation": ["Flow"],
"TypeofTypeAnnotation": ["Flow"],
"TypeAlias": ["Flow"],
"TypeAnnotation": ["Flow"],
"TypeCastExpression": ["Flow"],
"TypeParameterDeclaration": ["Flow"],
"TypeParameterInstantiation": ["Flow"],
"ObjectTypeAnnotation": ["Flow"],
"ObjectTypeCallProperty": ["Flow"],
"ObjectTypeIndexer": ["Flow"],
"ObjectTypeProperty": ["Flow"],
"QualifiedTypeIdentifier": ["Flow"],
"UnionTypeAnnotation": ["Flow"],
"VoidTypeAnnotation": ["Flow"],
"JSXAttribute": ["JSX"],

@@ -76,0 +109,0 @@ "JSXClosingElement": ["JSX"],

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

child.end = parent.end;
child.typeAnnotation = parent.typeAnnotation;
child.returnType = parent.returnType;
t.inheritsComments(child, parent);

@@ -726,0 +730,0 @@ return child;

{
"ArrayExpression": ["elements"],
"ArrayPattern": ["elements"],
"ArrowFunctionExpression": ["params", "defaults", "rest", "body"],
"ArrayPattern": ["elements", "typeAnnotation"],
"ArrowFunctionExpression": ["params", "defaults", "rest", "body", "returnType"],
"AssignmentExpression": ["left", "right"],

@@ -16,4 +16,4 @@ "AssignmentPattern": ["left", "right"],

"ClassBody": ["body"],
"ClassDeclaration": ["id", "body", "superClass"],
"ClassExpression": ["id", "body", "superClass"],
"ClassDeclaration": ["id", "body", "superClass", "typeParameters", "superTypeParameters", "implements"],
"ClassExpression": ["id", "body", "superClass", "typeParameters", "superTypeParameters", "implements"],
"ComprehensionBlock": ["left", "right", "body"],

@@ -34,5 +34,5 @@ "ComprehensionExpression": ["filter", "blocks", "body"],

"ForStatement": ["init", "test", "update", "body"],
"FunctionDeclaration": ["id", "params", "defaults", "rest", "body"],
"FunctionExpression": ["id", "params", "defaults", "rest", "body"],
"Identifier": [],
"FunctionDeclaration": ["id", "params", "defaults", "rest", "body", "returnType", "typeParameters"],
"FunctionExpression": ["id", "params", "defaults", "rest", "body", "returnType", "typeParameters"],
"Identifier": ["typeAnnotation"],
"IfStatement": ["test", "consequent", "alternate"],

@@ -49,7 +49,7 @@ "ImportBatchSpecifier": ["id"],

"ObjectExpression": ["properties"],
"ObjectPattern": ["properties"],
"ObjectPattern": ["properties", "typeAnnotation"],
"PrivateDeclaration": ["declarations"],
"Program": ["body"],
"Property": ["key", "value"],
"RestElement": ["argument"],
"RestElement": ["argument", "typeAnnotation"],
"ReturnStatement": ["argument"],

@@ -77,32 +77,33 @@ "SequenceExpression": ["expressions"],

"AnyTypeAnnotation": [],
"ArrayTypeAnnotation": [],
"ArrayTypeAnnotation": ["elementType"],
"BooleanTypeAnnotation": [],
"ClassProperty": ["key", "value"],
"DeclareClass": [],
"DeclareFunction": [],
"DeclareModule": [],
"DeclareVariable": [],
"FunctionTypeAnnotation": [],
"FunctionTypeParam": [],
"GenericTypeAnnotation": [],
"InterfaceExtends": [],
"InterfaceDeclaration": [],
"IntersectionTypeAnnotation": [],
"NullableTypeAnnotation": [],
"ClassImplements": ["id", "typeParameters"],
"ClassProperty": ["key", "value", "typeAnnotation"],
"DeclareClass": ["id", "typeParameters", "extends", "body"],
"DeclareFunction": ["id"],
"DeclareModule": ["id", "body"],
"DeclareVariable": ["id"],
"FunctionTypeAnnotation": ["typeParameters", "params", "rest", "returnType"],
"FunctionTypeParam": ["name", "typeAnnotation"],
"GenericTypeAnnotation": ["id", "typeParameters"],
"InterfaceExtends": ["id", "typeParameters"],
"InterfaceDeclaration": ["id", "typeParameters", "extends", "body"],
"IntersectionTypeAnnotation": ["types"],
"NullableTypeAnnotation": ["typeAnnotation"],
"NumberTypeAnnotation": [],
"StringLiteralTypeAnnotation": [],
"StringTypeAnnotation": [],
"TupleTypeAnnotation": [],
"TypeofTypeAnnotation": [],
"TypeAlias": [],
"TypeAnnotation": [],
"TupleTypeAnnotation": ["types"],
"TypeofTypeAnnotation": ["argument"],
"TypeAlias": ["id", "typeParameters", "right"],
"TypeAnnotation": ["typeAnnotation"],
"TypeCastExpression": ["expression"],
"TypeParameterDeclaration": [],
"TypeParameterInstantiation": [],
"ObjectTypeAnnotation": [],
"ObjectTypeCallProperty": [],
"ObjectTypeIndexer": [],
"ObjectTypeProperty": [],
"QualifiedTypeIdentifier": [],
"UnionTypeAnnotation": [],
"TypeParameterDeclaration": ["params"],
"TypeParameterInstantiation": ["params"],
"ObjectTypeAnnotation": ["key", "value"],
"ObjectTypeCallProperty": ["value"],
"ObjectTypeIndexer": ["id", "key", "value"],
"ObjectTypeProperty": ["key", "value"],
"QualifiedTypeIdentifier": ["id", "qualification"],
"UnionTypeAnnotation": ["types"],
"VoidTypeAnnotation": [],

@@ -109,0 +110,0 @@

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

exports.inherits = require("util").inherits;
var _util = require("util");
exports.inherits = _util.inherits;
exports.inspect = _util.inspect;
var debug = exports.debug = buildDebug("babel");

@@ -47,0 +50,0 @@

{
"name": "babel",
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
"version": "4.6.1",
"version": "4.6.3",
"author": "Sebastian McKenzie <sebmck@gmail.com>",

@@ -39,3 +39,3 @@ "homepage": "https://babeljs.io/",

"dependencies": {
"acorn-babel": "0.11.1-35",
"acorn-babel": "0.11.1-37",
"ast-types": "~0.6.1",

@@ -42,0 +42,0 @@ "chalk": "^1.0.0",

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