docs: fix oxc-parser README demo error (#1993)

The type of `ret.program` is `string`, it need to parse it first to get
the `body`.
This commit is contained in:
luhc228 2024-01-11 23:19:09 +08:00 committed by GitHub
parent d51c9f19f9
commit b1de10fbfd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -11,7 +11,8 @@ const oxc = require("oxc-parser");
const assert = require('assert');
function test(ret) {
assert(ret.program.body.length == 1);
const program = JSON.parse(ret.program);
assert(program.body.length == 1);
assert(ret.errors.length == 0);
}
@ -31,7 +32,8 @@ import oxc from 'oxc-parser';
import assert from 'assert';
function test(ret) {
assert(ret.program.body.length == 1);
const program = JSON.parse(ret.program);
assert(program.body.length == 1);
assert(ret.errors.length == 0);
}