Skip to content

Commit b52e1d8

Browse files
committed
tweak README
1 parent 6f7039a commit b52e1d8

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

README.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,28 @@ If the nodes of the input AST have `loc` properties (e.g. the AST was generated
3535

3636
## Options
3737

38-
You can optionally pass information that will be used while generating the output (note that the AST is assumed to come from a single file):
38+
You can pass the following options:
3939

4040
```js
4141
const { code, map } = print(ast, {
42+
// Populate the `sources` field of the resulting sourcemap
43+
// (note that the AST is assumed to come from a single file)
4244
sourceMapSource: 'input.js',
45+
46+
// Populate the `sourcesContent` field of the resulting sourcemap
4347
sourceMapContent: fs.readFileSync('input.js', 'utf-8'),
44-
indent: ' ', // default '\t'
45-
quotes: 'single' // or 'double', default 'single'
48+
49+
// String to use for indentation — defaults to '\t'
50+
indent: ' ',
51+
52+
// Whether to wrap strings in single or double quotes — defaults to 'single'.
53+
// This only applies to string literals with no `raw` value, which generally
54+
// means the AST node was generated programmatically, rather than parsed
55+
// from an original source
56+
quotes: 'single'
4657
});
4758
```
4859

49-
The `quotes` option is only used for string literals where no raw value was provided. In most cases this means that the ast node was added by manipulating the ast. This avoid's unnecessarily transforming the provided source code.
50-
5160
## TypeScript
5261

5362
`esrap` can also print TypeScript nodes, assuming they match the ESTree-like [`@typescript-eslint/types`](https://www.npmjs.com/package/@typescript-eslint/types).

0 commit comments

Comments
 (0)