oxc/npm/oxc-parser
2023-11-10 14:30:18 +08:00
..
scripts refactor: change @oxidation-compiler/napi to oxc-parser (#1209) 2023-11-10 06:17:05 +00:00
package.json s/web-infra-dev/oxc-project 2023-11-10 14:30:18 +08:00
README.md refactor: change @oxidation-compiler/napi to oxc-parser (#1209) 2023-11-10 06:17:05 +00: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) {
  assert(ret.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) {
  assert(ret.program.body.length == 1);
  assert(ret.errors.length == 0);
}

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

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

main()