Socket
Socket
Sign inDemoInstall

ast-types

Package Overview
Dependencies
10
Maintainers
1
Versions
172
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.9 to 0.2.10

19

def/es6.js

@@ -61,7 +61,6 @@ var types = require("../lib/types");

.bases("Declaration")
.build("kind", "key", "value", "static")
.build("kind", "key", "value")
.field("kind", or("init", "get", "set", ""))
.field("key", or(def("Literal"), def("Identifier")))
.field("value", def("Function"))
.field("static", builtin.boolean, defaults.false);
.field("value", def("Function"));

@@ -73,6 +72,18 @@ def("SpreadElement")

var ClassBodyElement = or(
def("MethodDefinition"),
def("VariableDeclarator"),
def("ClassPropertyDefinition")
);
def("ClassPropertyDefinition") // static property
.bases("Declaration")
.build("definition")
// Yes, Virginia, circular definitions are permitted.
.field("definition", ClassBodyElement);
def("ClassBody")
.bases("Declaration")
.build("body")
.field("body", [def("MethodDefinition")]);
.field("body", [ClassBodyElement]);

@@ -79,0 +90,0 @@ def("ClassDeclaration")

@@ -13,3 +13,7 @@ var types = require("../lib/types");

.field("name", def("XJSIdentifier"))
.field("value", or(def("XJSExpression"), null));
.field("value", or(
def("Literal"), // attr="value"
def("XJSExpression"), // attr={value}
null // attr= or just attr
), defaults.null);

@@ -31,7 +35,8 @@ def("XJSIdentifier")

.field("openingElement", def("XJSOpeningElement"))
.field("closingElement", or(def("XJSClosingElement"), null))
.field("closingElement", or(def("XJSClosingElement"), null), defaults.null)
.field("children", [or(
def("XJSElement"),
def("XJSExpression"),
def("XJSText")
def("XJSText"),
def("Literal") // TODO Esprima should return XJSText instead.
)], defaults.emptyArray)

@@ -38,0 +43,0 @@ .field("name", def("XJSIdentifier"), function() {

@@ -290,7 +290,8 @@ var assert = require("assert");

var type = field.type;
var child = value[name];
// If the value has a property with this name, check the type of
// the child value.
if (value.hasOwnProperty(name))
return type.check(value[name], deep);
// If a property with this name is defined on value, simply check
// the type of the child value.
if (!isUndefined.check(child))
return type.check(child, deep);

@@ -310,3 +311,3 @@ // If there is no default function for this field, treat the

// result returned by the default function.
var child = field.defaultFn.call(value);
child = field.defaultFn.call(value);
var result = type.check(child, deep);

@@ -313,0 +314,0 @@ if (result) {

@@ -21,3 +21,3 @@ {

],
"version": "0.2.9",
"version": "0.2.10",
"homepage": "http://github.com/benjamn/ast-types",

@@ -24,0 +24,0 @@ "repository": {

@@ -107,6 +107,6 @@ var types = require("../main");

function validateProgram(file) {
file = path.join(__dirname, "..", file);
var fullPath = path.join(__dirname, "..", file);
exports["test " + file] = function(t, assert) {
fs.readFile(file, "utf8", function(err, code) {
fs.readFile(fullPath, "utf8", function(err, code) {
if (err) throw err;

@@ -113,0 +113,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc