oxc/npm/oxc-parser
2024-04-22 12:56:40 +08:00
..
scripts Release napi oxc-parser@v0.4.0-alpha.0 2024-02-11 11:56:46 +08:00
package.json Release napi oxc-parser@v0.9.0 2024-04-22 12:56:40 +08:00
README.md docs: fix oxc-parser README demo error (#1993) 2024-01-11 23:19:09 +08:00

The JavaScript Oxidation Compiler

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

TypeScript typings for the AST is currently work in progress.

cjs

const oxc = require("oxc-parser");
const assert = require('assert');

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

test(oxc.parseSync("foo"));

async function main() {
  test(await oxc.parseAsync("foo"));
}

main()

ESM

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

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

test(oxc.parseSync("foo"));

async function main() {
  test(await oxc.parseAsync("foo"));
}

main()