Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/babel-utils/ast-pretty-print
A pretty printer for AST-like structures
https://github.com/babel-utils/ast-pretty-print
ast babel babel-util pretty-print
Last synced: 3 months ago
JSON representation
A pretty printer for AST-like structures
- Host: GitHub
- URL: https://github.com/babel-utils/ast-pretty-print
- Owner: babel-utils
- License: mit
- Created: 2017-05-15T05:15:08.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-09-08T08:42:27.000Z (about 7 years ago)
- Last Synced: 2024-04-23T20:12:06.786Z (7 months ago)
- Topics: ast, babel, babel-util, pretty-print
- Language: JavaScript
- Size: 13.7 KB
- Stars: 129
- Watchers: 5
- Forks: 10
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-list - ast-pretty-print - like structures | babel-utils | 127 | (JavaScript)
README
# ast-pretty-print
> A pretty printer for AST-like structures
- Super fast (useful for build tools)
- Concise output (useful for debugging)
- Consistent output (useful for snapshot testing)```js
import parser from 'parser';
import printAST from 'ast-pretty-print';let code = `...`;
let ast = parser.parse(code);
let printed = printAST(ast);console.log(printed);
``````js
Node "FunctionDeclaration"
__clone: [Function __clone]
async: false
body: Node "BlockStatement" (1:29, 1:31)
body: Array []
directives: Array []
expression: false
generator: false
id: Node "Identifier" (1:9, 1:10)
name: "a"
params: Array [
Node "Identifier" (1:11, 1:18)
name: "b"
typeAnnotation: Node "TypeAnnotation" (1:12, 1:18)
typeAnnotation: Node "StringLiteralTypeAnnotation" (1:14, 1:18)
extra: Object {
"raw": "\"hi\"",
"rawValue": "hi",
}
value: "hi",
Node "Identifier" (1:20, 1:21)
name: "c",
Node "RestElement" (1:23, 1:27)
argument: Node "Identifier" (1:26, 1:27)
name: "d",
]
```