ast-types
Advanced tools
Comparing version 0.3.8 to 0.3.9
@@ -33,3 +33,3 @@ var assert = require("assert"); | ||
var result = check.call(self, value, deep); | ||
if (!result && objToStr.call(deep) === funObjStr) | ||
if (!result && deep && objToStr.call(deep) === funObjStr) | ||
deep(self, value); | ||
@@ -294,6 +294,9 @@ return result; | ||
Dp.isSupertypeOf = function(that) { | ||
assert.ok(that instanceof Def, that + " is not a Def"); | ||
assert.strictEqual(this.finalized, true); | ||
assert.strictEqual(that.finalized, true); | ||
return that.allSupertypes.hasOwnProperty(this.typeName); | ||
if (that instanceof Def) { | ||
assert.strictEqual(this.finalized, true); | ||
assert.strictEqual(that.finalized, true); | ||
return that.allSupertypes.hasOwnProperty(this.typeName); | ||
} else { | ||
assert.ok(false, that + " is not a Def"); | ||
} | ||
}; | ||
@@ -326,8 +329,17 @@ | ||
var vDef = Def.fromValue(value); | ||
if (!vDef) { | ||
// If we couldn't infer the Def associated with the given value, | ||
// and we expected it to be a SourceLocation or a Position, it was | ||
// probably just missing a "type" field (because Esprima does not | ||
// assign a type property to such nodes). Be optimistic and let | ||
// this.checkAllFields make the final decision. | ||
if (this.typeName === "SourceLocation" || | ||
this.typeName === "Position") { | ||
return this.checkAllFields(value, deep); | ||
} | ||
// If we couldn't determine the Def associated with the given value, | ||
// it was probably just missing a "type" field, so be optimistic and | ||
// let this.checkAllFields make the final decision. | ||
if (!vDef) | ||
return this.checkAllFields(value, deep); | ||
// Calling this.checkAllFields for any other type of node is both | ||
// bad for performance and way too forgiving. | ||
return false; | ||
} | ||
@@ -334,0 +346,0 @@ // If checking deeply and vDef === this, then we only need to call |
@@ -21,3 +21,3 @@ { | ||
], | ||
"version": "0.3.8", | ||
"version": "0.3.9", | ||
"homepage": "http://github.com/benjamn/ast-types", | ||
@@ -24,0 +24,0 @@ "repository": { |
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
408971
11446