oxc/npm/napi
2023-08-21 15:04:33 +08:00
..
scripts feat: napi (#302) 2023-04-22 14:41:45 +08:00
index.d.ts feat: napi (#302) 2023-04-22 14:41:45 +08:00
index.js feat: napi (#302) 2023-04-22 14:41:45 +08:00
package.json fix(npm): fix github link according to provernance 2023-08-21 15:04:33 +08:00
README.md chore: add README to npm/napi 2023-04-22 15:19:49 +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("@oxidation-compiler/napi");
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 '@oxidation-compiler/napi';
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()