21
21
* [ ` Options ` ] ( #options )
22
22
* [ ` Plugin ` ] ( #plugin )
23
23
* [ ` Value ` ] ( #value )
24
- * [ ` Version ` ] ( #version )
24
+ * [ ` Version ` ] ( #version-1 )
25
25
* [ Types] ( #types )
26
26
* [ Compatibility] ( #compatibility )
27
27
* [ Contribute] ( #contribute )
@@ -45,7 +45,7 @@ It turns the tree into a string of JavaScript.
45
45
## Install
46
46
47
47
This package is [ ESM only] [ esm ] .
48
- In Node.js (version 14.14+ or 16.0+), install with [ npm] [ ] :
48
+ In Node.js (version 14.14+ and 16.0+), install with [ npm] [ ] :
49
49
50
50
``` sh
51
51
npm install esast-util-from-js
@@ -54,14 +54,14 @@ npm install esast-util-from-js
54
54
In Deno with [ ` esm.sh ` ] [ esmsh ] :
55
55
56
56
``` js
57
- import {fromJs } from " https://esm.sh/esast-util-from-js@1"
57
+ import {fromJs } from ' https://esm.sh/esast-util-from-js@1'
58
58
```
59
59
60
60
In browsers with [ ` esm.sh ` ] [ esmsh ] :
61
61
62
62
``` html
63
63
<script type =" module" >
64
- import {fromJs } from " https://esm.sh/esast-util-from-js@1?bundle"
64
+ import {fromJs } from ' https://esm.sh/esast-util-from-js@1?bundle'
65
65
</script >
66
66
```
67
67
@@ -117,12 +117,12 @@ Yields:
117
117
118
118
## API
119
119
120
- This package exports the identifier ` fromJs ` .
120
+ This package exports the identifier [ ` fromJs ` ] [ fromjs ] .
121
121
There is no default export.
122
122
123
123
### ` fromJs(value[, options]) `
124
124
125
- Parse a JavaScript ( ` string ` or ` Buffer ` in UTF-8) to an esast ( [ ` Node ` ] [ node ] ) .
125
+ Parse JavaScript to an esast.
126
126
127
127
###### Parameters
128
128
@@ -133,13 +133,15 @@ Parse a JavaScript (`string` or `Buffer` in UTF-8) to an esast ([`Node`][node]).
133
133
134
134
###### Returns
135
135
136
- Tree (` Program ` ).
136
+ Tree ([ ` Node ` ] [ node ] ).
137
137
138
138
### ` Options `
139
139
140
140
Configuration (TypeScript type).
141
141
142
- ###### ` options.version `
142
+ ##### Fields
143
+
144
+ ###### ` version `
143
145
144
146
JavaScript version ([ ` Version ` ] [ version ] , default: ` 'latest' ` ).
145
147
@@ -150,34 +152,34 @@ When a number, must be a year in the range `2015` and `2022` (both including).
150
152
> breaking semver.
151
153
> Pass an actual year to lock that down.
152
154
153
- ###### ` options. module`
155
+ ###### ` module `
154
156
155
157
Whether this is a module (ESM) or a script (` boolean ` , default: ` false ` ).
156
158
157
- ###### ` options. allowReturnOutsideFunction`
159
+ ###### ` allowReturnOutsideFunction `
158
160
159
161
Whether a return statement is allowed in the top scope (` boolean ` , default:
160
162
` false ` ).
161
163
162
- ###### ` options. allowImportExportEverywhere`
164
+ ###### ` allowImportExportEverywhere `
163
165
164
166
Whether import/export statements are allowed in the every scope (` boolean ` ,
165
167
default: ` false ` ).
166
168
167
- ###### ` options. allowAwaitOutsideFunction`
169
+ ###### ` allowAwaitOutsideFunction `
168
170
169
171
Whether ` await ` is allowed in the top scope (` boolean ` , default: depends).
170
172
Defaults to ` version >= 2022 ` .
171
173
172
- ###### ` options. allowSuperOutsideMethod`
174
+ ###### ` allowSuperOutsideMethod `
173
175
174
176
Whether ` super ` is allowed outside methods (` boolean ` , default: ` false ` ).
175
177
176
- ###### ` options. allowHashBang`
178
+ ###### ` allowHashBang `
177
179
178
180
Whether a shell hasbang is allowed (` boolean ` , default: ` false ` ).
179
181
180
- ###### ` options. plugins`
182
+ ###### ` plugins `
181
183
182
184
List of acorn plugins ([ ` Array<Plugin> ` ] [ plugin ] , default: ` [] ` ).
183
185
Examples are [ ` acorn-jsx ` ] [ acorn-jsx ] and [ ` acorn-stage3 ` ] [ acorn-stage3 ] .
@@ -217,7 +219,8 @@ type Version = 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 'latest'
217
219
## Types
218
220
219
221
This package is fully typed with [TypeScript][].
220
- It exports the additional types ` Options ` , ` Plugin ` , ` Value ` , and ` Version ` .
222
+ It exports the additional types [ ` Options ` ][options], [ ` Plugin ` ][plugin],
223
+ [ ` Value ` ][value], and [ ` Version ` ][version].
221
224
222
225
## Compatibility
223
226
@@ -306,10 +309,12 @@ abide by its terms.
306
309
307
310
[estree-util-to-js]: https://github.com/syntax-tree/estree-util-to-js
308
311
312
+ [fromjs]: #fromjsvalue-options
313
+
309
314
[options]: #options
310
315
311
316
[plugin]: #plugin
312
317
313
318
[value]: #value
314
319
315
- [version]: #version
320
+ [version]: #version-1
0 commit comments