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.5 to 4.6.6

.npmignore

6

CHANGELOG.md

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

## 4.6.6
* **Bug Fix**
* Fix incorrect method call in `utility.deadCodeElimination` transformer.
* Fix `es6.blockScopingTDZ` transformer duplicating binding nodes.
## 4.6.5

@@ -18,0 +24,0 @@

1

CONTRIBUTING.md

@@ -56,3 +56,2 @@ # Contributing

* **General**
* No ES6 syntax features or methods, exclusively ES5.
* Max of five arguments for functions

@@ -59,0 +58,0 @@ * Max depth of four nested blocks

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

var cacheKey = filename + ":" + JSON.stringify(opts);
var cacheKey = "" + filename + ":" + JSON.stringify(opts);

@@ -66,0 +66,0 @@ if (cache) {

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

} catch (err) {
err.message = file + ": " + err.message;
err.message = "" + file + ": " + err.message;
throw err;

@@ -37,0 +37,0 @@ }

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

exports.ExpressionStatement = ExpressionStatement;
exports.AssignmentExpression = AssignmentExpression;
exports.MemberExpression = MemberExpression;

@@ -130,3 +131,3 @@

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

@@ -138,4 +139,8 @@ print(node.left);

print(node.right);
};
}
exports.BinaryExpression = AssignmentExpression;
exports.LogicalExpression = AssignmentExpression;
exports.AssignmentPattern = AssignmentExpression;
var SCIENTIFIC_NOTATION = /e/i;

@@ -142,0 +147,0 @@

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

exports._method = _method;
exports.FunctionExpression = FunctionExpression;
exports.ArrowFunctionExpression = ArrowFunctionExpression;

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

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

@@ -74,4 +75,6 @@ this.push("function");

print(node.body);
};
}
exports.FunctionDeclaration = FunctionExpression;
function ArrowFunctionExpression(node, print) {

@@ -78,0 +81,0 @@ if (node.async) this.push("async ");

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

} else {
return exports.ExportSpecifier.apply(this, arguments);
return ExportSpecifier.apply(this, arguments);
}

@@ -23,0 +23,0 @@ }

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

exports.Identifier = Identifier;
exports.RestElement = RestElement;
exports.VirtualPropertyExpression = VirtualPropertyExpression;
exports.ObjectExpression = ObjectExpression;
exports.Property = Property;
exports.ArrayExpression = ArrayExpression;
exports.Literal = Literal;

@@ -18,7 +21,10 @@ exports._stringLiteral = _stringLiteral;

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

@@ -30,3 +36,3 @@ print(node.object);

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

@@ -45,4 +51,6 @@

}
};
}
exports.ObjectPattern = ObjectExpression;
function Property(node, print) {

@@ -67,3 +75,3 @@ if (node.method || node.kind === "get" || node.kind === "set") {

exports.ArrayExpression = exports.ArrayPattern = function (node, print) {
function ArrayExpression(node, print) {
var _this = this;

@@ -92,4 +100,6 @@

this.push("]");
};
}
exports.ArrayPattern = ArrayExpression;
function Literal(node) {

@@ -96,0 +106,0 @@ var val = node.value;

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

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) + "^";
}

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

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

err._babel = true;
var message = opts.filename + ": " + err.message;
var message = "" + opts.filename + ": " + err.message;

@@ -45,0 +45,0 @@ var loc = err.loc;

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

function get(key) {
var msg = exports.messages[key];
if (!msg) throw new ReferenceError("Unknown message `" + key + "`");
var msg = messages[key];
if (!msg) throw new ReferenceError("Unknown message " + JSON.stringify(key));

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

}
args = exports.parseArgs(args);
args = parseArgs(args);

@@ -43,0 +43,0 @@ return msg.replace(/\$(\d+)/g, function (str, i) {

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

})(function (node, scope) {
if (Array.isArray(node)) {
for (var i = 0; i < node.length; i++) {
this.checkNode(node[i], scope);
}
return;
}
var stack = this.transformerStack;

@@ -467,3 +474,3 @@ if (!scope) scope = this.scope;

// add back shebang
result.code = this.shebang + "\n" + result.code;
result.code = "" + this.shebang + "\n" + result.code;
}

@@ -470,0 +477,0 @@

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

var useStrictNode;
if (exports.has(node)) {
if (has(node)) {
useStrictNode = node.body.shift();

@@ -20,0 +20,0 @@ }

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

var state = {
scope.traverse(node, visitor, {
letRefs: letRefs,
file: file
};
scope.traverse(node, visitor, state);
});
}

@@ -46,0 +44,0 @@

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

loopText = loopText + "|" + node.label.name;
loopText = "" + loopText + "|" + node.label.name;
} else {

@@ -214,0 +214,0 @@ // we shouldn't be transforming these statements because

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

// we have no constructor, we have a super, and the super doesn't appear to be falsy
if (!this.hasConstructor && this.hasSuper && t.evaluateTruthy(superName) !== false) {
if (!this.hasConstructor && this.hasSuper && t.evaluateTruthy(superName, this.scope) !== false) {
var helperName = "class-super-constructor-call";

@@ -194,0 +194,0 @@ if (this.isLoose) helperName += "-loose";

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

var hasDestructuringTransformer = false;
var hasDestructuring = false;

@@ -74,3 +74,3 @@ node.params = node.params.map(function (pattern, i) {

hasDestructuringTransformer = true;
hasDestructuring = true;
var ref = scope.generateUidIdentifier("ref");

@@ -83,3 +83,4 @@

file: file,
kind: "var" });
kind: "let"
});
destructuring.init(pattern, ref);

@@ -90,4 +91,5 @@

if (!hasDestructuringTransformer) return;
if (!hasDestructuring) return;
file.checkNode(nodes);
t.ensureBlock(node);

@@ -94,0 +96,0 @@

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

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

@@ -130,0 +129,0 @@ var declar;

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

if (file.transformers["es6.blockScopingTDZ"].canRun()) {
if (file.transformers["es6.blockScopingTDZ"].canRun() && t.isIdentifier(param)) {
pushDefNode(param, t.identifier("undefined"), i);

@@ -76,0 +76,0 @@ }

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

exports.Function = function (node, parent, scope) {
exports.Function = function (node, parent, scope, file) {
if (!hasRest(node)) return;

@@ -82,6 +82,8 @@

rest = scope.generateUidIdentifier("ref");
var declar = t.variableDeclaration("var", pattern.elements.map(function (elem, index) {
var declar = t.variableDeclaration("let", pattern.elements.map(function (elem, index) {
var accessExpr = t.memberExpression(rest, t.literal(index), true);
return t.variableDeclarator(elem, accessExpr);
}));
file.checkNode(declar);
node.body.body.unshift(declar);

@@ -88,0 +90,0 @@ }

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

function ConditionalExpression(node) {
var evaluateTest = t.evaluateTruthy(node.test);
function ConditionalExpression(node, parent, scope) {
var evaluateTest = t.evaluateTruthy(node.test, scope);
if (evaluateTest === true) {

@@ -39,3 +39,3 @@ return node.consequent;

var IfStatement = exports.IfStatement = {
exit: function exit(node) {
exit: function exit(node, parent, scope) {
var consequent = node.consequent;

@@ -45,3 +45,3 @@ var alternate = node.alternate;

var evaluateTest = t.evaluateTruthy(test);
var evaluateTest = t.evaluateTruthy(test, scope);

@@ -89,3 +89,3 @@ // we can check if a test will be truthy 100% and if so then we can inline

if (t.blockStatement(consequent) && !consequent.body.length && t.isBlockStatement(alternate) && alternate.body.length) {
if (t.isBlockStatement(consequent) && !consequent.body.length && t.isBlockStatement(alternate) && alternate.body.length) {
node.consequent = node.alternate;

@@ -92,0 +92,0 @@ node.alternate = null;

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

exports.Expression = Expression;
exports.Identifier = Identifier;

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

function Expression(node) {
var res = t.evaluate(node);
function Expression(node, parent, scope) {
var res = t.evaluate(node, scope);
if (res.confident) return t.valueToNode(res.value);
}
exports.__esModule = true;
function Identifier() {}
exports.__esModule = true;
// override Expression

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

for (var i = 0; i < declars.length; i++) {
this.registerBinding(declars[i], declar.kind);
this.registerBinding(declar.kind, declars[i]);
}

@@ -670,2 +670,32 @@ };

Scope.prototype.getOwnImmutableBindingValue = function getOwnImmutableBindingValue(name) {
return this._immutableBindingInfoToValue(this.getOwnBindingInfo(name));
};
Scope.prototype.getImmutableBindingValue = function getImmutableBindingValue(name) {
return this._immutableBindingInfoToValue(this.getBindingInfo(name));
};
Scope.prototype._immutableBindingInfoToValue = function _immutableBindingInfoToValue(info) {
if (!info) return;
// can't guarantee this value is the same
if (info.reassigned) return;
var node = info.node;
if (t.isVariableDeclarator(node)) {
if (t.isIdentifier(node.id)) {
node = node.init;
} else {
// otherwise it's probably a destructuring like:
// var { foo } = "foo";
return;
}
}
if (t.isImmutable(node)) {
return node;
}
};
// has

@@ -672,0 +702,0 @@

@@ -826,2 +826,31 @@ "use strict";

/**
* Description
*
* @param {Node} node
* @returns {Boolean}
*/
t.isImmutable = function (node) {
if (t.isLiteral(node)) {
if (node.regex) {
// regexes are mutable
return false;
} else {
// immutable!
return true;
}
} else if (t.isIdentifier(node)) {
if (node.name === "undefined") {
// immutable!
return true;
} else {
// no idea...
return false;
}
}
return false;
};
/**
* Walk the input `node` and statically evaluate if it's truthy.

@@ -843,7 +872,8 @@ *

* @param {Node} node
* @param {Scope} scope
* @returns {Boolean}
*/
t.evaluateTruthy = function (node) {
var res = t.evaluate(node);
t.evaluateTruthy = function (node, scope) {
var res = t.evaluate(node, scope);
if (res.confident) return !!res.value;

@@ -866,6 +896,7 @@ };

* @param {Node} node
* @param {Scope} scope
* @returns {Object}
*/
t.evaluate = function (node) {
t.evaluate = function (node, scope) {
var confident = true;

@@ -901,4 +932,8 @@

if (t.isIdentifier(node, { name: "undefined" })) {
return undefined;
if (t.isIdentifier(node)) {
if (node.name === "undefined") {
return undefined;
} else {
return evaluate(scope.getImmutableBindingValue(node.name));
}
}

@@ -905,0 +940,0 @@

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

function canCompile(filename, altExts) {
var exts = altExts || exports.canCompile.EXTENSIONS;
var exts = altExts || canCompile.EXTENSIONS;
var ext = path.extname(filename);

@@ -82,3 +82,3 @@ return contains(exts, ext);

if (isBoolean(val)) return [val];
if (isString(val)) return exports.list(val);
if (isString(val)) return list(val);
if (Array.isArray(val)) return val;

@@ -85,0 +85,0 @@ throw new TypeError("illegal type for arrayify");

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

@@ -6,0 +6,0 @@ "homepage": "https://babeljs.io/",

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