oxc/npm/oxc-parser
overlookmotel d48e008e47
docs(napi): simplify + reformat README (#6834)
In particular:

* the long comment was scrolling off side of screen on
[npm.com](https://www.npmjs.com/package/oxc-parser).
* the example is ESM, so can simplify it by using top level await.
2024-10-24 08:34:46 +08:00
..
scripts chore: use dprint to format js, json and markdown 2024-09-08 13:24:58 +08:00
CHANGELOG.md release(oxc): crates v0.28.0 (#5696) 2024-09-11 17:57:55 +08:00
package.json release(crates): v0.32.0 (#6691) 2024-10-19 23:09:35 +08:00
README.md docs(napi): simplify + reformat README (#6834) 2024-10-24 08:34:46 +08: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) {
  const program = JSON.parse(ret.program);
  assert(program.body.length == 1);
  assert(ret.errors.length == 0);
}