oxc/npm/oxc-parser
2024-11-26 14:38:47 +08:00
..
scripts chore(doc): replace main/master to tag/commit to make the url always accessible (#7298) 2024-11-16 21:00:30 +08:00
.gitignore feat(napi/parser)!: add typings to napi/parser (#6796) 2024-10-24 13:08:59 +00:00
CHANGELOG.md release(crates): v0.35.0 (#7110) 2024-11-04 17:40:05 +08:00
package.json release(crates): v0.38.0 (#7490) 2024-11-26 14:38:47 +08:00
README.md docs(napi): Remove JSON.parse from example (#6836) 2024-10-24 14:49:44 +01:00

The JavaScript Oxidation Compiler

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

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

const sourceText = "let foo: Foo = 'foo';";
// 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));

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