Comparing version 1.4.4 to 1.4.5
{ | ||
"name": "astq", | ||
"version": "1.4.4", | ||
"version": "1.4.5", | ||
"description": "Abstract Syntax Tree (AST) Query Engine", | ||
@@ -5,0 +5,0 @@ "main": "lib/astq.browser.js", |
{ | ||
"name": "astq", | ||
"version": "1.4.4", | ||
"version": "1.4.5", | ||
"description": "Abstract Syntax Tree (AST) Query Engine", | ||
@@ -24,6 +24,6 @@ "keywords": [ "abstract", "syntax", "tree", "query", "engine", "adaptable" ], | ||
"pegjs": "~0.8.0", | ||
"pegjs-otf": "~1.0.5", | ||
"pegjs-util": "~1.0.4", | ||
"asty": "~1.1.4", | ||
"cache-lru": "~1.0.5" | ||
"pegjs-otf": "~1.0.6", | ||
"pegjs-util": "~1.0.5", | ||
"asty": "~1.1.5", | ||
"cache-lru": "~1.0.6" | ||
}, | ||
@@ -39,6 +39,6 @@ "devDependencies": { | ||
"grunt-eslint": "~13.0.0", | ||
"babel-eslint": "~3.1.8", | ||
"babel-eslint": "~3.1.9", | ||
"mocha": "~2.2.5", | ||
"chai": "~2.3.0", | ||
"babelify": "~6.1.1", | ||
"babelify": "~6.1.2", | ||
"minifyify": "~7.0.0", | ||
@@ -45,0 +45,0 @@ "browserify-header": "~0.9.2", |
@@ -236,2 +236,36 @@ | ||
Example | ||
------- | ||
``` | ||
$ cat sample.js | ||
const acorn = require("acorn") | ||
const ASTQ = require("astq") | ||
let source = ` | ||
class Foo { | ||
foo () { | ||
const bar = "quux" | ||
let baz = 42 | ||
} | ||
} | ||
` | ||
let ast = acorn.parse(source, { ecmaVersion: 6 }) | ||
let astq = new ASTQ() | ||
astq.query(ast, ` | ||
// VariableDeclarator [ | ||
/:id Identifier [ @name ] | ||
&& /:init Literal [ @value ] | ||
] | ||
`).forEach(function (node) { | ||
console.log(`${node.id.name}: ${node.init.value}`) | ||
}) | ||
$ babel-node sample.js | ||
bar: quux | ||
baz: 42 | ||
``` | ||
Implementation Notice | ||
@@ -238,0 +272,0 @@ --------------------- |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
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
498004
6906
310
Updatedasty@~1.1.5
Updatedcache-lru@~1.0.6
Updatedpegjs-otf@~1.0.6
Updatedpegjs-util@~1.0.5