Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/babel-utils/pretty-format-ast
Pretty format plugin to print ASTs prettier
https://github.com/babel-utils/pretty-format-ast
ast babel jest pretty-format pretty-printer
Last synced: 28 days ago
JSON representation
Pretty format plugin to print ASTs prettier
- Host: GitHub
- URL: https://github.com/babel-utils/pretty-format-ast
- Owner: babel-utils
- License: other
- Created: 2017-06-08T21:12:56.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-06-08T21:14:07.000Z (over 7 years ago)
- Last Synced: 2024-11-07T07:11:42.317Z (3 months ago)
- Topics: ast, babel, jest, pretty-format, pretty-printer
- Language: JavaScript
- Size: 26.4 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pretty-format-ast
> [Pretty format](https://github.com/facebook/jest/tree/master/packages/pretty-format) plugin to print ASTs prettier
### Installation
```sh
yarn add pretty-format pretty-format-ast
```### Usage
```js
const prettyFormat = require('pretty-format');
const prettyFormatAST = require('pretty-format-ast');prettyFormat(val, {
plugins: [prettyFormatAST],
})
``````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",
]
```