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

ast-types

Package Overview
Dependencies
Maintainers
1
Versions
172
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ast-types - npm Package Compare versions

Comparing version 0.3.33 to 0.3.34

24

def/core.js

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

.field("params", [def("Pattern")])
.field("body", or(def("BlockStatement"), def("Expression")))
.field("generator", isBoolean, defaults["false"])
.field("expression", isBoolean, defaults["false"])
.field("defaults", [def("Expression")], defaults.emptyArray)
.field("rest", or(def("Identifier"), null), defaults["null"])
.field("async", isBoolean, defaults["false"]);
.field("body", or(def("BlockStatement"), def("Expression")));

@@ -172,3 +167,3 @@ def("Statement").bases("Node");

.bases("Function", "Declaration")
.build("id", "params", "body", "generator", "expression")
.build("id", "params", "body")
.field("id", def("Identifier"));

@@ -178,3 +173,3 @@

.bases("Function", "Expression")
.build("id", "params", "body", "generator", "expression");
.build("id", "params", "body");

@@ -204,3 +199,3 @@ def("VariableDeclaration")

.build("elements")
.field("elements", [or(def("Expression"), def("SpreadElement"), null)]);
.field("elements", [or(def("Expression"), null)]);

@@ -210,3 +205,3 @@ def("ObjectExpression")

.build("properties")
.field("properties", [or(def("Property"), def("SpreadProperty"))]);
.field("properties", [def("Property")]);

@@ -219,6 +214,3 @@ // TODO Not in the Mozilla Parser API, but used by Esprima.

.field("key", or(def("Literal"), def("Identifier")))
.field("value", def("Expression"))
// Esprima extensions not mentioned in the Mozilla Parser API:
.field("method", isBoolean, defaults["false"])
.field("shorthand", isBoolean, defaults["false"]);
.field("value", def("Expression"));

@@ -304,3 +296,3 @@ def("SequenceExpression")

// TODO Report this nonsense.
.field("arguments", [or(def("Expression"), def("SpreadElement"))]);
.field("arguments", [def("Expression")]);

@@ -312,3 +304,3 @@ def("CallExpression")

// See comment for NewExpression above.
.field("arguments", [or(def("Expression"), def("SpreadElement"))]);
.field("arguments", [def("Expression")]);

@@ -315,0 +307,0 @@ def("MemberExpression")

@@ -11,2 +11,15 @@ require("./core");

def("Function")
.field("generator", isBoolean, defaults["false"])
.field("expression", isBoolean, defaults["false"])
.field("defaults", [def("Expression")], defaults.emptyArray)
// TODO This could be represented as a SpreadElementPattern in .params.
.field("rest", or(def("Identifier"), null), defaults["null"]);
def("FunctionDeclaration")
.build("id", "params", "body", "generator", "expression");
def("FunctionExpression")
.build("id", "params", "body", "generator", "expression");
// TODO The Parser API calls this ArrowExpression, but Esprima uses

@@ -22,3 +35,3 @@ // ArrowFunctionExpression.

// liberty of enforcing that. TODO Report this.
.field("generator", false, defaults["false"]);
.field("generator", false);

@@ -29,3 +42,3 @@ def("YieldExpression")

.field("argument", or(def("Expression"), null))
.field("delegate", isBoolean, false);
.field("delegate", isBoolean, defaults["false"]);

@@ -70,2 +83,7 @@ def("GeneratorExpression")

def("Property")
// Esprima extensions not mentioned in the Mozilla Parser API:
.field("method", isBoolean, defaults["false"])
.field("shorthand", isBoolean, defaults["false"]);
def("MethodDefinition")

@@ -83,2 +101,16 @@ .bases("Declaration")

def("ArrayExpression")
.field("elements", [or(def("Expression"), def("SpreadElement"), null)]);
def("NewExpression")
.field("arguments", [or(def("Expression"), def("SpreadElement"))]);
def("CallExpression")
.field("arguments", [or(def("Expression"), def("SpreadElement"))]);
def("SpreadElementPattern")
.bases("Pattern")
.build("argument")
.field("argument", def("Pattern"));
var ClassBodyElement = or(

@@ -85,0 +117,0 @@ def("MethodDefinition"),

@@ -7,3 +7,7 @@ require("./core");

var isBoolean = builtin.boolean;
var defaults = require("../lib/shared").defaults;
def("Function")
.field("async", isBoolean, defaults["false"]);
def("SpreadProperty")

@@ -14,2 +18,16 @@ .bases("Node")

def("ObjectExpression")
.field("properties", [or(def("Property"), def("SpreadProperty"))]);
def("SpreadPropertyPattern")
.bases("Pattern")
.build("argument")
.field("argument", def("Pattern"));
def("ObjectPattern")
.field("properties", [or(
def("PropertyPattern"),
def("SpreadPropertyPattern")
)]);
def("AwaitExpression")

@@ -16,0 +34,0 @@ .bases("Expression")

@@ -13,3 +13,3 @@ require("./core");

.build("name", "value")
.field("name", def("XJSIdentifier"))
.field("name", or(def("XJSIdentifier"), def("XJSNamespacedName")))
.field("value", or(

@@ -23,5 +23,4 @@ def("Literal"), // attr="value"

.bases("Node")
.build("name", "namespace")
.field("name", isString)
.field("namespace", or(isString, null), defaults["null"]);
.build("name")
.field("name", isString);

@@ -31,4 +30,4 @@ def("XJSNamespacedName")

.build("namespace", "name")
.field("namespace", def("Identifier"))
.field("name", def("Identifier"));
.field("namespace", def("XJSIdentifier"))
.field("name", def("XJSIdentifier"));

@@ -38,6 +37,12 @@ def("XJSMemberExpression")

.build("object", "property")
.field("object", def("Identifier"))
.field("property", def("Identifier"))
.field("object", or(def("XJSIdentifier"), def("XJSMemberExpression")))
.field("property", def("XJSIdentifier"))
.field("computed", isBoolean, defaults.false);
var XJSElementName = or(
def("XJSIdentifier"),
def("XJSNamespacedName"),
def("XJSMemberExpression")
);
def("XJSSpreadAttribute")

@@ -48,2 +53,7 @@ .bases("Node")

var XJSAttributes = [or(
def("XJSAttribute"),
def("XJSSpreadAttribute")
)];
def("XJSExpressionContainer")

@@ -65,3 +75,3 @@ .bases("Expression")

)], defaults.emptyArray)
.field("name", def("XJSIdentifier"), function() {
.field("name", XJSElementName, function() {
// Little-known fact: the `this` object inside a default function

@@ -77,3 +87,3 @@ // is none other than the partially-built object itself, and any

})
.field("attributes", [def("XJSAttribute")], function() {
.field("attributes", XJSAttributes, function() {
return this.openingElement.attributes;

@@ -85,4 +95,4 @@ });

.build("name", "attributes", "selfClosing")
.field("name", def("XJSIdentifier"))
.field("attributes", [def("XJSAttribute")], defaults.emptyArray)
.field("name", XJSElementName)
.field("attributes", XJSAttributes, defaults.emptyArray)
.field("selfClosing", isBoolean, defaults["false"]);

@@ -93,3 +103,3 @@

.build("name")
.field("name", def("XJSIdentifier"));
.field("name", XJSElementName);

@@ -96,0 +106,0 @@ def("XJSText")

@@ -427,12 +427,25 @@ var assert = require("assert");

var self = this;
var buildParams = slice.call(arguments);
var typeName = self.typeName;
// Calling Def.prototype.build multiple times has the effect of merely
// redefining this property.
Object.defineProperty(self, "buildParams", {
value: slice.call(arguments),
writable: false,
enumerable: false,
configurable: true
});
assert.strictEqual(self.finalized, false);
isString.arrayOf().assert(buildParams);
isString.arrayOf().assert(self.buildParams);
if (self.buildable) {
// If this Def is already buildable, update self.buildParams and
// continue using the old builder function.
return self;
}
// Every buildable type will have its "type" field filled in
// automatically. This includes types that are not subtypes of Node,
// like SourceLocation, but that seems harmless (TODO?).
self.field("type", typeName, function() { return typeName });
self.field("type", self.typeName, function() { return self.typeName });

@@ -442,3 +455,3 @@ // Override Dp.buildable for this Def instance.

Object.defineProperty(builders, getBuilderName(typeName), {
Object.defineProperty(builders, getBuilderName(self.typeName), {
enumerable: true,

@@ -453,3 +466,3 @@

self.finalized,
"attempting to instantiate unfinalized type " + typeName);
"attempting to instantiate unfinalized type " + self.typeName);

@@ -475,4 +488,4 @@ function add(param, i) {

var message = "no value or default function given for field " +
JSON.stringify(param) + " of " + typeName + "(" +
buildParams.map(function(name) {
JSON.stringify(param) + " of " + self.typeName + "(" +
self.buildParams.map(function(name) {
return all[name];

@@ -487,3 +500,3 @@ }).join(", ") + ")";

" does not match field " + field +
" of type " + typeName);
" of type " + self.typeName);

@@ -495,3 +508,3 @@ // TODO Could attach getters and setters here to enforce

buildParams.forEach(function(param, i) {
self.buildParams.forEach(function(param, i) {
add(param, i);

@@ -505,3 +518,3 @@ });

// Make sure that the "type" field was filled automatically.
assert.strictEqual(built.type, typeName);
assert.strictEqual(built.type, self.typeName);

@@ -508,0 +521,0 @@ return built;

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

],
"version": "0.3.33",
"version": "0.3.34",
"homepage": "http://github.com/benjamn/ast-types",

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

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