1.14.0 • Published 2 months ago

asty-astq v1.14.0

Weekly downloads
28
License
MIT
Repository
github
Last release
2 months ago

ASTy-ASTq

Abstract Syntax Tree With Integrated Query Engine

github (author stars) github (author followers) npm (project release) npm (project downloads)

Installation

$ npm install asty-astq

About

ASTy-ASTq, as its name implies, is a combination of the Abstract Syntax Tree (AST) Data Structure library ASTy and the Abstract Syntax Tree (AST) Query Engine Library ASTq. Technically ASTy-ASTq is a super-class of ASTy while it internally integrates ASTq so that each ASTy node has additional compile, execute and query methods available. The methods have the folowing signatures (in TypeScript notation):

compile(
    selector: String,
    trace?: Boolean
): ASTYQuery
execute(
    query: ASTQQuery,
    params?: { [name: String]: [value: Any] },
    trace?: Boolean
): ASTYNode[]
query(
    selector: String,
    params?: { [name: String]: [value: Any] },
    trace?: Boolean
): ASTYNode[]

In other words, the following ASTy-ASTq usage...

var ASTY = require("asty-astq")

var asty = new ASTY()
var node = asty.create("Foo")

var nodes = node.query("Foo", {}, true)

...is technically equivalent to the underlying ASTy plus ASTq usage onto which ASTy-ASTq maps itself:

var ASTY = require("asty")

var asty = new ASTY()
var node = asty.create("Foo")

var ASTQ = require("astq")
var astq = new ASTQ()
astq.adapter({
    taste:            function (/* node */) { return true           },
    getParentNode:    function (node)       { return node.parent()  },
    getChildNodes:    function (node)       { return node.childs()  },
    getNodeType:      function (node)       { return node.type()    },
    getNodeAttrNames: function (node)       { return node.attrs()   },
    getNodeAttrValue: function (node, attr) { return node.get(attr) }
})
var nodes = astq.query(node, "Foo", {}, true)

License

Copyright © 2014-2023 Dr. Ralf S. Engelschall (http://engelschall.com/)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

1.14.0

2 months ago

1.13.7

8 months ago

1.13.6

2 years ago

1.13.5

2 years ago

1.13.4

3 years ago

1.13.3

3 years ago

1.13.2

3 years ago

1.13.1

3 years ago

1.13.0

4 years ago

1.12.3

4 years ago

1.12.2

5 years ago

1.12.1

5 years ago

1.12.0

5 years ago

1.11.0

5 years ago

1.10.0

5 years ago

1.9.5

5 years ago

1.9.4

6 years ago

1.9.3

6 years ago

1.9.2

6 years ago

1.9.1

6 years ago

1.9.0

6 years ago

1.8.9

6 years ago

1.8.8

6 years ago

1.8.7

6 years ago

1.8.6

6 years ago

1.8.5

6 years ago

1.8.4

6 years ago

1.8.3

6 years ago

1.8.2

6 years ago

1.8.1

6 years ago

1.8.0

6 years ago

1.7.2

6 years ago

1.7.1

6 years ago

1.7.0

6 years ago

1.6.8

6 years ago

1.6.7

6 years ago

1.6.6

6 years ago

1.6.5

6 years ago

1.6.4

6 years ago

1.6.3

7 years ago

1.6.2

7 years ago

1.6.1

7 years ago

1.6.0

7 years ago

1.5.0

8 years ago

1.4.5

8 years ago

1.4.4

8 years ago

1.4.3

8 years ago

1.4.2

8 years ago

1.4.1

8 years ago

1.4.0

8 years ago

1.3.6

9 years ago

1.3.5

9 years ago

1.3.4

9 years ago

1.3.3

9 years ago

1.3.2

9 years ago

1.3.1

9 years ago

1.3.0

9 years ago

1.2.5

9 years ago

1.2.4

9 years ago

1.2.3

9 years ago

1.2.2

9 years ago

1.2.1

9 years ago

1.2.0

9 years ago

1.1.0

9 years ago

1.0.8

9 years ago

1.0.7

9 years ago

1.0.6

9 years ago

1.0.5

9 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago