From 909a086f6ea8c732dbed28bbdd3a4e5a9e8cd0f9 Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Tue, 23 Sep 2025 13:15:33 +0000 Subject: [PATCH] docs(parser): simplify example (#14044) Pure refactor. Remove unnecessary `main` function, to clarify the example. --- napi/parser/example.mjs | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/napi/parser/example.mjs b/napi/parser/example.mjs index 50835bdae2bc2..5330eeff5b382 100644 --- a/napi/parser/example.mjs +++ b/napi/parser/example.mjs @@ -8,24 +8,22 @@ import { parseSync } from './src-js/index.mjs'; process.chdir(path.join(import.meta.dirname, '../..')); -function main() { - const args = parseArgs({ - args: process.argv.slice(2), - allowPositionals: true, - options: { - lang: { - type: 'string', - }, - astType: { - type: 'string', - }, +const args = parseArgs({ + args: process.argv.slice(2), + allowPositionals: true, + options: { + lang: { + type: 'string', }, - }); - const file = args.positionals[0] ?? 'test.js'; - const code = fs.readFileSync(file, 'utf-8'); - const result = parseSync(file, code, args.values); - // oxlint-disable-next-line typescript-eslint/no-misused-spread - console.dir({ ...result }, { depth: Infinity }); -} + astType: { + type: 'string', + }, + }, +}); + +const file = args.positionals[0] ?? 'test.js'; -main(); +const code = fs.readFileSync(file, 'utf-8'); +const result = parseSync(file, code, args.values); +// oxlint-disable-next-line typescript-eslint/no-misused-spread +console.dir({ ...result }, { depth: Infinity });