Comparing version 2.4.0 to 2.5.0
{ | ||
"name": "astq", | ||
"version": "2.4.0", | ||
"version": "2.5.0", | ||
"description": "Abstract Syntax Tree (AST) Query Engine", | ||
@@ -5,0 +5,0 @@ "keywords": [ "abstract", "syntax", "tree", "query", "engine", "adaptable" ], |
@@ -5,6 +5,6 @@ { | ||
"dependencies": { | ||
"acorn": "5.5.3", | ||
"parse5": "4.0.0", | ||
"acorn": "6.0.4", | ||
"parse5": "5.1.0", | ||
"xmldom": "0.1.27", | ||
"less": "3.0.1" | ||
"less": "3.9.0" | ||
}, | ||
@@ -11,0 +11,0 @@ "scripts": { |
@@ -25,3 +25,3 @@ | ||
`).forEach((node) => { | ||
console.log(`FOUND: variable: ${node.id.name}, value: ${node.init.value}`) | ||
console.log(`FOUND MOZAST: variable: ${node.id.name}, value: ${node.init.value}`) | ||
}) | ||
@@ -60,3 +60,3 @@ })(); | ||
let value = astq.query(node, `// "#text"`).map((node) => node.value).join("") | ||
console.log(`FOUND: tag: ${tag}, value: ${value}`) | ||
console.log(`FOUND PARSE5: tag: ${tag}, value: ${value}`) | ||
}) | ||
@@ -84,5 +84,25 @@ })(); | ||
`).forEach((node) => { | ||
console.log(`FOUND: ${node.nodeName}`) | ||
console.log(`FOUND XMLDOM: ${node.nodeName}`) | ||
}) | ||
})(); | ||
/* query JSON source-code */ | ||
(() => { | ||
let ast = { | ||
config: { | ||
foo: { enabled: true, body: "Foo" }, | ||
bar: { body: "Bar" }, | ||
quux: { enabled: true, body: "Quux" } | ||
} | ||
} | ||
let astq = new ASTQ() | ||
astq.adapter("json", true) | ||
astq.query(ast, ` | ||
// * /:foo * [ | ||
@enabled == true | ||
] | ||
`).forEach((node) => { | ||
console.log(`FOUND JSON: ${JSON.stringify(node)}`) | ||
}) | ||
})(); | ||
@@ -57,5 +57,4 @@ /* | ||
else { | ||
if (typeof node[type] === "undefined") | ||
throw new Error("no such axis named \"" + type + "\" for walking to child nodes") | ||
checkField(node, type) | ||
if (typeof node[type] !== "undefined") | ||
checkField(node, type) | ||
} | ||
@@ -62,0 +61,0 @@ return childs |
@@ -62,5 +62,4 @@ /* | ||
else { | ||
if (typeof node[type] === "undefined") | ||
throw new Error("no such axis named \"" + type + "\" for walking to child nodes") | ||
checkField(node, type) | ||
if (typeof node[type] !== "undefined") | ||
checkField(node, type) | ||
} | ||
@@ -67,0 +66,0 @@ return childs |
@@ -34,2 +34,3 @@ /* | ||
import ASTQAdapterGRAPHQL from "./astq-adapter-graphql.js" | ||
import ASTQAdapterJSON from "./astq-adapter-json.js" | ||
import ASTQAdapterASTY from "./astq-adapter-asty.js" | ||
@@ -51,2 +52,3 @@ import ASTQFuncs from "./astq-funcs.js" | ||
.register(ASTQAdapterGRAPHQL, false) | ||
.register(ASTQAdapterJSON, false) | ||
.register(ASTQAdapterASTY, false) | ||
@@ -79,6 +81,7 @@ | ||
if (typeof adapter === "string") { | ||
if (adapter === "mozast") adapter = ASTQAdapterMOZAST | ||
if (adapter === "mozast") adapter = ASTQAdapterMOZAST | ||
else if (adapter === "graphql") adapter = ASTQAdapterGRAPHQL | ||
else if (adapter === "xmldom") adapter = ASTQAdapterXMLDOM | ||
else if (adapter === "parse5") adapter = ASTQAdapterPARSE5 | ||
else if (adapter === "json") adapter = ASTQAdapterJSON | ||
else if (adapter === "asty") adapter = ASTQAdapterASTY | ||
@@ -85,0 +88,0 @@ else |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
384453
27
7653