javascript node.js

How can I detect all dependencies of a function in Node.js?

I’m trying to give a broad picture of my problem. I need to write a program with Node.js that should be able to detect all dependencies a function.


function a() {
//do something
function b() {
console.log("Hey, This is b");

At the example above I need to have an JSON like this:

"a": {
dependencies: ["b"],
range: [1, 4]
"b": {
dependencies: [],
range: [5, 8]

In the dependencies property I need to have an array of functions that called inside the function, and by range I mean the line range of function definition.

I need a solution to achieve this goal. Are there any tools or plugins for Node.js?