Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-traverse

Package Overview
Dependencies
Maintainers
5
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-traverse - npm Package Compare versions

Comparing version 7.0.0-alpha.18 to 7.0.0-alpha.19

31

lib/context.js

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

var _path4 = require("./path");
var _path2 = require("./path");
var _path5 = _interopRequireDefault(_path4);
var _path3 = _interopRequireDefault(_path2);

@@ -49,4 +49,4 @@ var _babelTypes = require("babel-types");

var _key = _ref;
if (node[_key]) return true;
var key = _ref;
if (node[key]) return true;
}

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

TraversalContext.prototype.create = function create(node, obj, key, listKey) {
return _path5.default.get({
return _path3.default.get({
parentPath: this.parentPath,

@@ -123,11 +123,10 @@ parent: node,

var _path2 = _ref2;
var path = _ref2;
path.resync();
_path2.resync();
if (_path2.contexts.length === 0 || _path2.contexts[_path2.contexts.length - 1] !== this) {
_path2.pushContext(this);
if (path.contexts.length === 0 || path.contexts[path.contexts.length - 1] !== this) {
path.pushContext(this);
}
if (_path2.key === null) continue;
if (path.key === null) continue;

@@ -138,6 +137,6 @@ if (testing && queue.length >= 10000) {

if (visited.indexOf(_path2.node) >= 0) continue;
visited.push(_path2.node);
if (visited.indexOf(path.node) >= 0) continue;
visited.push(path.node);
if (_path2.visit()) {
if (path.visit()) {
stop = true;

@@ -167,5 +166,5 @@ break;

var _path3 = _ref3;
var _path = _ref3;
_path3.popContext();
_path.popContext();
}

@@ -172,0 +171,0 @@

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

var _key = _ref;
if (skipKeys && skipKeys[_key]) continue;
if (context.visit(node, _key)) return;
var key = _ref;
if (skipKeys && skipKeys[key]) continue;
if (context.visit(node, key)) return;
}

@@ -111,0 +111,0 @@ };

@@ -63,11 +63,10 @@ "use strict";

var _fn = _ref;
if (!_fn) continue;
var fn = _ref;
if (!fn) continue;
var node = this.node;
if (!node) return true;
var ret = fn.call(this.state, this, this.state);
var ret = _fn.call(this.state, this, this.state);
if (ret) {
throw new Error("Unexpected return value from visitor method " + _fn);
throw new Error("Unexpected return value from visitor method " + fn);
}

@@ -239,7 +238,4 @@

function requeue(pathToQueue) {
if (pathToQueue === void 0) {
pathToQueue = this;
}
function requeue() {
var pathToQueue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this;
if (pathToQueue.removed) return;

@@ -260,5 +256,4 @@ var contexts = this.contexts;

var _context = _ref2;
_context.maybeQueue(pathToQueue);
var context = _ref2;
context.maybeQueue(pathToQueue);
}

@@ -265,0 +260,0 @@ }

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

function arrowFunctionToExpression(_temp) {
var _ref = _temp === void 0 ? {} : _temp,
function arrowFunctionToExpression() {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
_ref$allowInsertArrow = _ref.allowInsertArrow,

@@ -89,11 +89,5 @@ allowInsertArrow = _ref$allowInsertArrow === undefined ? true : _ref$allowInsertArrow,

function hoistFunctionEnvironment(fnPath, specCompliant, allowInsertArrow) {
if (specCompliant === void 0) {
specCompliant = false;
}
if (allowInsertArrow === void 0) {
allowInsertArrow = true;
}
function hoistFunctionEnvironment(fnPath) {
var specCompliant = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var allowInsertArrow = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
var thisEnvFn = fnPath.findParent(function (p) {

@@ -100,0 +94,0 @@ return p.isFunction() && !p.isArrowFunctionExpression() || p.isProgram() || p.isClassProperty();

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

var value = _object.node.value;
var type = typeof value === "undefined" ? "undefined" : _typeof(value);
var type = _typeof(value);
if (type === "number" || type === "string") {

@@ -180,3 +179,3 @@ return value[_property.node.name];

case "typeof":
return _typeof(arg);
return typeof arg === "undefined" ? "undefined" : _typeof(arg);
}

@@ -201,9 +200,9 @@ }

var _elem = _ref;
_elem = _elem.evaluate();
var elem = _ref;
elem = elem.evaluate();
if (_elem.confident) {
arr.push(_elem.value);
if (elem.confident) {
arr.push(elem.value);
} else {
return deopt(_elem, state);
return deopt(elem, state);
}

@@ -231,13 +230,12 @@ }

var _prop = _ref2;
var prop = _ref2;
if (_prop.isObjectMethod() || _prop.isSpreadElement()) {
return deopt(_prop, state);
if (prop.isObjectMethod() || prop.isSpreadElement()) {
return deopt(prop, state);
}
var keyPath = _prop.get("key");
var keyPath = prop.get("key");
var key = keyPath;
if (_prop.node.computed) {
if (prop.node.computed) {
key = key.evaluate();

@@ -256,12 +254,12 @@

var valuePath = _prop.get("value");
var valuePath = prop.get("value");
var _value2 = valuePath.evaluate();
var _value = valuePath.evaluate();
if (!_value2.confident) {
if (!_value.confident) {
return deopt(valuePath, state);
}
_value2 = _value2.value;
obj[key] = _value2;
_value = _value.value;
obj[key] = _value;
}

@@ -414,7 +412,4 @@

function evaluateQuasis(path, quasis, state, raw) {
if (raw === void 0) {
raw = false;
}
function evaluateQuasis(path, quasis, state) {
var raw = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
var str = "";

@@ -436,5 +431,5 @@ var i = 0;

var _elem2 = _ref3;
var elem = _ref3;
if (!state.confident) break;
str += raw ? _elem2.value.raw : _elem2.value.cooked;
str += raw ? elem.value.raw : elem.value.cooked;
var expr = exprs[i++];

@@ -441,0 +436,0 @@ if (expr) str += String(evaluateCached(expr, state));

@@ -177,11 +177,5 @@ "use strict";

function getBindingIdentifierPaths(duplicates, outerOnly) {
if (duplicates === void 0) {
duplicates = false;
}
if (outerOnly === void 0) {
outerOnly = false;
}
function getBindingIdentifierPaths() {
var duplicates = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
var outerOnly = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var path = this;

@@ -188,0 +182,0 @@ var search = [].concat(path);

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

NodePath.prototype.buildCodeFrameError = function buildCodeFrameError(msg, Error) {
if (Error === void 0) {
Error = SyntaxError;
}
NodePath.prototype.buildCodeFrameError = function buildCodeFrameError(msg) {
var Error = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : SyntaxError;
return this.hub.file.buildCodeFrameError(this.node, msg, Error);

@@ -174,0 +171,0 @@ };

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

var id = this.get("id");
if (!id.isIdentifier()) return;
var init = this.get("init");
var type = init.getTypeAnnotation();
if (id.isIdentifier()) {
return this.get("init").getTypeAnnotation();
} else {
return;
if (type && type.type === "AnyTypeAnnotation") {
if (init.isCallExpression() && init.get("callee").isIdentifier({
name: "Array"
}) && !init.scope.hasBinding("Array", true)) {
type = ArrayExpression();
}
}
return type;
}

@@ -54,0 +61,0 @@

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

var _path2 = _ref;
var path = _ref;
if (_path2.key !== "callee" || !_path2.parentPath.isCallExpression()) {
if (path.key !== "callee" || !path.parentPath.isCallExpression()) {
return;

@@ -249,4 +249,4 @@ }

var _path3 = _ref2;
var childOfFunction = !!_path3.find(function (path) {
var _path = _ref2;
var childOfFunction = !!_path.find(function (path) {
return path.node === targetFuncPath.node;

@@ -256,3 +256,3 @@ });

var status = this._guessExecutionStatusRelativeTo(_path3);
var status = this._guessExecutionStatusRelativeTo(_path);

@@ -259,0 +259,0 @@ if (allStatus) {

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

var _context = _ref;
_context.maybeQueue(_path, true);
var context = _ref;
context.maybeQueue(_path, true);
}

@@ -183,3 +182,3 @@ }

msg = "has falsy node";
} else if (_typeof(node) !== "object") {
} else if ((typeof node === "undefined" ? "undefined" : _typeof(node)) !== "object") {
msg = "contains a non-object node";

@@ -193,3 +192,3 @@ } else if (!node.type) {

if (msg) {
var type = Array.isArray(node) ? "array" : _typeof(node);
var type = Array.isArray(node) ? "array" : typeof node === "undefined" ? "undefined" : _typeof(node);
throw new Error("Node list " + msg + " with the index of " + i + " and type of " + type);

@@ -235,9 +234,6 @@ }

function hoist(scope) {
if (scope === void 0) {
scope = this.scope;
}
function hoist() {
var scope = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.scope;
var hoister = new _hoister2.default(this, scope);
return hoister.run();
}

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

var _path = _ref;
if (!_path.isExpressionStatement()) continue;
var loop = _path.findParent(function (path) {
var path = _ref;
if (!path.isExpressionStatement()) continue;
var loop = path.findParent(function (path) {
return path.isLoop();

@@ -223,5 +222,5 @@ });

_path.get("expression").replaceWith(t.assignmentExpression("=", uid, _path.node.expression));
path.get("expression").replaceWith(t.assignmentExpression("=", uid, path.node.expression));
} else {
_path.replaceWith(t.returnStatement(_path.node.expression));
path.replaceWith(t.returnStatement(path.node.expression));
}

@@ -228,0 +227,0 @@ }

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

var _scope = _ref;
if (_scope.parent === parentScope && _scope.path === path) return _scope;
var scope = _ref;
if (scope.parent === parentScope && scope.path === path) return scope;
}

@@ -236,7 +236,4 @@

Scope.prototype.generateDeclaredUidIdentifier = function generateDeclaredUidIdentifier(name) {
if (name === void 0) {
name = "temp";
}
Scope.prototype.generateDeclaredUidIdentifier = function generateDeclaredUidIdentifier() {
var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "temp";
var id = this.generateUidIdentifier(name);

@@ -249,15 +246,9 @@ this.push({

Scope.prototype.generateUidIdentifier = function generateUidIdentifier(name) {
if (name === void 0) {
name = "temp";
}
Scope.prototype.generateUidIdentifier = function generateUidIdentifier() {
var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "temp";
return t.identifier(this.generateUid(name));
};
Scope.prototype.generateUid = function generateUid(name) {
if (name === void 0) {
name = "temp";
}
Scope.prototype.generateUid = function generateUid() {
var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "temp";
name = t.toIdentifier(name).replace(/^_+/, "").replace(/[0-9]+$/g, "");

@@ -367,5 +358,5 @@ var uid = void 0;

for (var _name in scope.bindings) {
var binding = scope.bindings[_name];
console.log(" -", _name, {
for (var name in scope.bindings) {
var binding = scope.bindings[name];
console.log(" -", name, {
constant: binding.constant,

@@ -473,4 +464,4 @@ references: binding.references,

for (var _name2 in ids) {
var binding = this.getBinding(_name2);
for (var name in ids) {
var binding = this.getBinding(name);
if (binding) binding.reassign(path);

@@ -480,7 +471,4 @@ }

Scope.prototype.registerBinding = function registerBinding(kind, path, bindingPath) {
if (bindingPath === void 0) {
bindingPath = path;
}
Scope.prototype.registerBinding = function registerBinding(kind, path) {
var bindingPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : path;
if (!kind) throw new ReferenceError("no `kind`");

@@ -503,4 +491,4 @@

var _declar2 = _ref2;
this.registerBinding(kind, _declar2);
var declar = _ref2;
this.registerBinding(kind, declar);
}

@@ -514,17 +502,17 @@

for (var _name3 in ids) {
var _arr8 = ids[_name3];
for (var name in ids) {
var _arr8 = ids[name];
for (var _i10 = 0; _i10 < _arr8.length; _i10++) {
var _id3 = _arr8[_i10];
var local = this.getOwnBinding(_name3);
var local = this.getOwnBinding(name);
if (local) {
if (local.identifier === _id3) continue;
this.checkBlockScopedCollisions(local, kind, _name3, _id3);
this.checkBlockScopedCollisions(local, kind, name, _id3);
}
if (local && local.path.isFlow()) local = null;
parent.references[_name3] = true;
this.bindings[_name3] = new _binding3.default({
parent.references[name] = true;
this.bindings[name] = new _binding3.default({
identifier: _id3,

@@ -599,4 +587,4 @@ existing: local,

var _method = _ref3;
if (!this.isPure(_method, constantsOnly)) return false;
var method = _ref3;
if (!this.isPure(method, constantsOnly)) return false;
}

@@ -729,4 +717,4 @@

var _param = _ref4;
this.registerBinding("param", _param);
var param = _ref4;
this.registerBinding("param", param);
}

@@ -762,15 +750,15 @@ }

var _path3 = _ref5;
var _path = _ref5;
var ids = _path3.getBindingIdentifiers();
var ids = _path.getBindingIdentifiers();
var programParent = void 0;
for (var _name4 in ids) {
if (_path3.scope.getBinding(_name4)) continue;
programParent = programParent || _path3.scope.getProgramParent();
programParent.addGlobal(ids[_name4]);
for (var name in ids) {
if (_path.scope.getBinding(name)) continue;
programParent = programParent || _path.scope.getProgramParent();
programParent.addGlobal(ids[name]);
}
_path3.scope.registerConstantViolation(_path3);
_path.scope.registerConstantViolation(_path);
}

@@ -790,10 +778,9 @@

var _ref8 = _ref6;
var ref = _ref6;
var binding = ref.scope.getBinding(ref.node.name);
var binding = _ref8.scope.getBinding(_ref8.node.name);
if (binding) {
binding.reference(_ref8);
binding.reference(ref);
} else {
_ref8.scope.getProgramParent().addGlobal(_ref8.node);
ref.scope.getProgramParent().addGlobal(ref.node);
}

@@ -814,5 +801,5 @@ }

var _path4 = _ref7;
var _path2 = _ref7;
_path4.scope.registerConstantViolation(_path4);
_path2.scope.registerConstantViolation(_path2);
}

@@ -915,5 +902,5 @@ };

do {
for (var _name5 in scope.bindings) {
var binding = scope.bindings[_name5];
if (binding.kind === kind) ids[_name5] = binding;
for (var name in scope.bindings) {
var binding = scope.bindings[name];
if (binding.kind === kind) ids[name] = binding;
}

@@ -920,0 +907,0 @@

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

var _part = _ref;
visitor[_part] = fns;
var part = _ref;
visitor[part] = fns;
}

@@ -123,4 +123,4 @@ }

var _alias = _ref2;
var existing = visitor[_alias];
var alias = _ref2;
var existing = visitor[alias];

@@ -130,3 +130,3 @@ if (existing) {

} else {
visitor[_alias] = (0, _clone2.default)(_fns2);
visitor[alias] = (0, _clone2.default)(_fns2);
}

@@ -164,3 +164,3 @@ }

if (_typeof(visitors) === "object") {
if ((typeof visitors === "undefined" ? "undefined" : _typeof(visitors)) === "object") {
for (var visitorKey in visitors) {

@@ -194,6 +194,6 @@ if (visitorKey === "enter" || visitorKey === "exit") {

var _fn = _ref3;
var fn = _ref3;
if (typeof _fn !== "function") {
throw new TypeError("Non-function found defined in " + path + " with type " + _typeof(_fn));
if (typeof fn !== "function") {
throw new TypeError("Non-function found defined in " + path + " with type " + (typeof fn === "undefined" ? "undefined" : _typeof(fn)));
}

@@ -203,7 +203,5 @@ }

function merge(visitors, states, wrapper) {
if (states === void 0) {
states = [];
}
function merge(visitors) {
var states = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
var wrapper = arguments[2];
var rootVisitor = {};

@@ -210,0 +208,0 @@

{
"name": "babel-traverse",
"version": "7.0.0-alpha.18",
"version": "7.0.0-alpha.19",
"description": "The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes",

@@ -11,7 +11,7 @@ "author": "Sebastian McKenzie <sebmck@gmail.com>",

"dependencies": {
"babel-code-frame": "7.0.0-alpha.18",
"babel-helper-function-name": "7.0.0-alpha.18",
"babel-messages": "7.0.0-alpha.18",
"babel-types": "7.0.0-alpha.18",
"babylon": "7.0.0-beta.18",
"babel-code-frame": "7.0.0-alpha.19",
"babel-helper-function-name": "7.0.0-alpha.19",
"babel-messages": "7.0.0-alpha.19",
"babel-types": "7.0.0-alpha.19",
"babylon": "7.0.0-beta.19",
"debug": "^2.2.0",

@@ -23,5 +23,5 @@ "globals": "^10.0.0",

"devDependencies": {
"babel-generator": "7.0.0-alpha.18",
"babel-helper-plugin-test-runner": "7.0.0-alpha.18"
"babel-generator": "7.0.0-alpha.19",
"babel-helper-plugin-test-runner": "7.0.0-alpha.19"
}
}
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