Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 9 additions & 16 deletions npm/oxc-parser/README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,22 @@
# The JavaScript Oxidation Compiler

See index.d.ts for `parseSync` and `parseAsync` API.

## ESM
See `index.d.ts` for `parseSync` and `parseAsync` API.

```javascript
import assert from 'assert';
import oxc from 'oxc-parser';

function test(ret) {
const program = JSON.parse(ret.program);
assert(program.body.length == 1);
assert(ret.errors.length == 0);
}

const sourceText = "let foo: Foo = 'foo';";
const options = {
sourceFilename: 'text.tsx', // the extension is used to determine which dialect to parse
};
// Filename extension is used to determine which
// dialect to parse source as
const options = { sourceFilename: 'text.tsx' };

test(oxc.parseSync(sourceText, options));
test(await oxc.parseAsync(sourceText, options));

async function main() {
test(await oxc.parseAsync(sourceText, options));
function test(ret) {
const program = JSON.parse(ret.program);
assert(program.body.length == 1);
assert(ret.errors.length == 0);
}

main();
```