@yuku-parser/wasm 0.5.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -0
- package/decode.js +693 -0
- package/index.d.ts +2034 -0
- package/index.js +60 -0
- package/package.json +43 -0
- package/yuku-parser.wasm +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# yuku-parser-wasm
|
|
2
|
+
|
|
3
|
+
The [`yuku-parser`](https://www.npmjs.com/package/yuku-parser) JavaScript/TypeScript
|
|
4
|
+
parser as a single WebAssembly module. Runs anywhere: browsers, bundlers, Deno,
|
|
5
|
+
Bun and Node. Same API and same AST as `yuku-parser`.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install yuku-parser-wasm
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
import { parse } from "yuku-parser-wasm";
|
|
17
|
+
|
|
18
|
+
const { program, comments, diagnostics } = parse("const x: number = 1", {
|
|
19
|
+
lang: "ts",
|
|
20
|
+
});
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
`parse(source, options?)` returns `{ program, comments, diagnostics, lineStarts,
|
|
24
|
+
locOf, locNear }`. Options:
|
|
25
|
+
|
|
26
|
+
| Option | Default | Description |
|
|
27
|
+
| ---------------------------- | ---------- | ----------------------------------------- |
|
|
28
|
+
| `lang` | `"js"` | `"js" \| "ts" \| "jsx" \| "tsx" \| "dts"` |
|
|
29
|
+
| `sourceType` | `"module"` | `"module" \| "script"` |
|
|
30
|
+
| `preserveParens` | `true` | Keep `ParenthesizedExpression` nodes |
|
|
31
|
+
| `allowReturnOutsideFunction` | `false` | Allow top-level `return` |
|
|
32
|
+
| `semanticErrors` | `false` | Also run semantic analysis |
|
|
33
|
+
| `attachComments` | `false` | Attach comments to their host node |
|
|
34
|
+
|
|
35
|
+
`langFromPath(path)` and `sourceTypeFromPath(path)` are also exported.
|