From 8af6bdca6a6dfd4403f9a47c43c6d06e1d3786d3 Mon Sep 17 00:00:00 2001 From: zxkmm Date: Sun, 17 Dec 2023 18:05:08 +0800 Subject: [PATCH 1/2] correctly_display_field --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.md b/README.md index dc9ed4e..d894c8d 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,27 @@ console.log(dependenciesName); console.log(inTryDeps); console.log(warnings); ``` +--- + +If you meant to run this example with Node.js quickly in terminal, use this example below to correctly display the ``location`` field. +```js +import { runASTAnalysis } from "@nodesecure/js-x-ray"; +import { readFileSync } from "fs"; + +const str = readFileSync("./file.js", "utf-8"); +const { warnings, dependencies } = runASTAnalysis(str); + +const dependenciesName = [...dependencies]; +const inTryDeps = [...dependencies.getDependenciesInTryStatement()]; + +console.log(dependenciesName); +console.log(inTryDeps); +console.log(JSON.stringify(warnings, null, 2)); +``` +save content above to a ``.mjs`` file and run it with this command in your terminal`` +node ./example_filename.mjs`` + +--- The analysis will return: `http` (in try), `crypto`, `util` and `fs`. From 36f6589a2a68f28ae9ed438035cd9708cae656cf Mon Sep 17 00:00:00 2001 From: zxkmm Date: Sun, 17 Dec 2023 18:34:45 +0800 Subject: [PATCH 2/2] accept review --- README.md | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/README.md b/README.md index d894c8d..91edbb2 100644 --- a/README.md +++ b/README.md @@ -78,29 +78,8 @@ const inTryDeps = [...dependencies.getDependenciesInTryStatement()]; console.log(dependenciesName); console.log(inTryDeps); -console.log(warnings); +console.dir(warnings, { depth: null }); ``` ---- - -If you meant to run this example with Node.js quickly in terminal, use this example below to correctly display the ``location`` field. -```js -import { runASTAnalysis } from "@nodesecure/js-x-ray"; -import { readFileSync } from "fs"; - -const str = readFileSync("./file.js", "utf-8"); -const { warnings, dependencies } = runASTAnalysis(str); - -const dependenciesName = [...dependencies]; -const inTryDeps = [...dependencies.getDependenciesInTryStatement()]; - -console.log(dependenciesName); -console.log(inTryDeps); -console.log(JSON.stringify(warnings, null, 2)); -``` -save content above to a ``.mjs`` file and run it with this command in your terminal`` -node ./example_filename.mjs`` - ---- The analysis will return: `http` (in try), `crypto`, `util` and `fs`.