babel-normalize-comments
Version:
Merge comments together into a normalized string
29 lines (18 loc) • 564 B
Markdown
into a normalized string
Preserves indentation in many different comment styles
```
yarn add babel-normalize-comments
```
```
const babylon = require('babylon');
const { normalizeComments, normalizeComment } = require('babel-normalize-comments');
let ast = babylon.parse(code);
// normalize an array of comment nodes
normalizeComments(ast.comments);
// normalize a single comment node
normalizeComment(ast.comments[0]);
```
See [test.js](test.js) for examples of input and output.
> Merge comments together