From b1de10fbfdacc6db80c201bb2208f0015851541a Mon Sep 17 00:00:00 2001 From: luhc228 Date: Thu, 11 Jan 2024 23:19:09 +0800 Subject: [PATCH] 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`. --- npm/oxc-parser/README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/npm/oxc-parser/README.md b/npm/oxc-parser/README.md index 38a1d09e9..1d911b536 100644 --- a/npm/oxc-parser/README.md +++ b/npm/oxc-parser/README.md @@ -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); }