ast-types
Advanced tools
Comparing version 0.2.6 to 0.2.7
@@ -202,3 +202,3 @@ var types = require("../lib/types"); | ||
.bases("Node") // Want to be able to visit Property Nodes. | ||
.build("kind", "key", "val") | ||
.build("kind", "key", "value") | ||
.field("kind", or("init", "get", "set")) | ||
@@ -251,2 +251,3 @@ .field("key", or(def("Literal"), def("Identifier"))) | ||
.field("operator", AssignmentOperator) | ||
// TODO Shouldn't this be def("Pattern")? | ||
.field("left", def("Expression")) | ||
@@ -253,0 +254,0 @@ .field("right", def("Expression")); |
@@ -50,8 +50,18 @@ var assert = require("assert"); | ||
var result = this.check(value, deep); | ||
assert.ok( | ||
result, | ||
JSON.stringify(value) + " does not match type " + this); | ||
assert.ok(result, shallowStringify(value) + " does not match type " + this); | ||
return result; | ||
}; | ||
function shallowStringify(value) { | ||
if (isObject.check(value)) | ||
return "{" + Object.keys(value).map(function(key) { | ||
return key + ": " + value[key]; | ||
}).join(", ") + "}"; | ||
if (isArray.check(value)) | ||
return "[" + value.map(shallowStringify).join(", ") + "]"; | ||
return JSON.stringify(value); | ||
} | ||
Tp.toString = function() { | ||
@@ -432,3 +442,3 @@ var name = this.name; | ||
type.check(value), | ||
JSON.stringify(value) + | ||
shallowStringify(value) + | ||
" does not match field " + field + | ||
@@ -435,0 +445,0 @@ " of type " + typeName); |
@@ -21,3 +21,3 @@ { | ||
], | ||
"version": "0.2.6", | ||
"version": "0.2.7", | ||
"homepage": "http://github.com/benjamn/ast-types", | ||
@@ -24,0 +24,0 @@ "repository": { |
373931
10552