oxc/napi/parser/index.js
ottomated 67a7bde4c6 feat(napi/parser)!: add typings to napi/parser (#6796)
- Added TypeScript annotation for `ParseResult.program`
- Modified the entrypoint for `oxc-parser` to allow wrapping the napi functions
- Updated `index.js` to parse the `program` string into a JSON object
- Updated tests
- Added a dependency on `@oxc/types`
2024-10-24 13:08:59 +00:00

16 lines
585 B
JavaScript

const bindings = require('./bindings.js');
module.exports.moduleLexerAsync = bindings.moduleLexerAsync;
module.exports.moduleLexerSync = bindings.moduleLexerSync;
module.exports.parseWithoutReturn = bindings.parseWithoutReturn;
module.exports.parseAsync = async function parseAsync(...args) {
const result = await bindings.parseAsync(...args);
result.program = JSON.parse(result.program);
return result;
};
module.exports.parseSync = function parseSync(...args) {
const result = bindings.parseSync(...args);
result.program = JSON.parse(result.program);
return result;
};