ast-types
Advanced tools
Comparing version 0.3.13 to 0.3.14
@@ -224,2 +224,5 @@ var assert = require("assert"); | ||
if (n.YieldExpression.check(node)) | ||
return isBinary(parent); | ||
return false; | ||
@@ -226,0 +229,0 @@ }; |
var assert = require("assert"); | ||
var types = require("./types"); | ||
var Node = types.namedTypes.Node; | ||
var isObject = types.builtInTypes.object; | ||
var isArray = types.builtInTypes.array; | ||
@@ -23,19 +24,22 @@ var NodePath = require("./node-path"); | ||
assert.ok(path instanceof NodePath); | ||
var value = path.value; | ||
if (isArray.check(path.value)) { | ||
if (isArray.check(value)) { | ||
path.each(traverse); | ||
return; | ||
} | ||
} else if (Node.check(path.value)) { | ||
var node = path.value; | ||
if (callback.call(path, node, traverse) === false) { | ||
if (Node.check(value)) { | ||
if (callback.call(path, value, traverse) === false) { | ||
return; | ||
} | ||
} else if (!isObject.check(value)) { | ||
return; | ||
} | ||
types.eachField(node, function(name, child) { | ||
var childPath = path.get(name); | ||
assert.strictEqual(childPath.value, child); | ||
traverse(childPath); | ||
}); | ||
} | ||
types.eachField(value, function(name, child) { | ||
var childPath = path.get(name); | ||
assert.strictEqual(childPath.value, child); | ||
traverse(childPath); | ||
}); | ||
} | ||
@@ -65,12 +69,16 @@ | ||
node.forEach(traverse); | ||
return; | ||
} | ||
} else if (Node.check(node)) { | ||
if (Node.check(node)) { | ||
if (callback.call(context, node, traverse) === false) { | ||
return; | ||
} | ||
} else if (!isObject.check(node)) { | ||
return; | ||
} | ||
types.eachField(node, function(name, child) { | ||
traverse(child); | ||
}); | ||
} | ||
types.eachField(node, function(name, child) { | ||
traverse(child); | ||
}); | ||
} | ||
@@ -77,0 +85,0 @@ |
@@ -21,3 +21,3 @@ { | ||
], | ||
"version": "0.3.13", | ||
"version": "0.3.14", | ||
"homepage": "http://github.com/benjamn/ast-types", | ||
@@ -24,0 +24,0 @@ "repository": { |
@@ -436,2 +436,15 @@ var types = require("../main"); | ||
var binaryYield = b.expressionStatement( | ||
b.logicalExpression( | ||
"&&", | ||
b.yieldExpression(b.identifier("a"), false), | ||
b.yieldExpression(b.identifier("b"), true) | ||
) | ||
); | ||
var byPath = new NodePath(binaryYield); | ||
assert.ok(!byPath.get("expression").needsParens()); | ||
assert.ok(byPath.get("expression", "left").needsParens()); | ||
assert.ok(byPath.get("expression", "right").needsParens()); | ||
t.finish(); | ||
@@ -438,0 +451,0 @@ }; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
415054
11614