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

astq

Package Overview
Dependencies
Maintainers
1
Versions
94
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

astq - npm Package Compare versions

Comparing version 2.4.0 to 2.5.0

src/astq-adapter-json.js

2

package.json
{
"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

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