This project provides static analysis tools for Javascript source code. It generates function - callee and variable - reference graphs. It builds upon the call-graph construction algorithm described in:
A. Feldthaus, M. Schäfer, M. Sridharan, J. Dolby, F. Tip. Efficient Construction of Approximate Call Graphs for JavaScript IDE Services. In ICSE, 2013.
yarn add @ticklepoke/sayjs
npm install @ticklepoke/sayjs
- Generate a graph for a single file:
sayjs foo/bar.js
- Generate a graph for an entire directory:
sayjs foo/
- Save results to JSON file:
sayjs -o graph.json foo/bar.js
sayjs --output-file graph.json foo/bar.js
import sayjs from '@ticklepoke/sayjs';
// or
const sayjs = require('@ticklepoke/sayjs');
sayjs.setFiles(['file.js', 'directory/']);
const edges = sayjs.build();
The following source code will generate the JSON file below:
function bar() {
return 1;
}
bar();
[
{
"source": {
"label": "global",
"file": "/home/user/project/simpleCall.js",
"start": {
"row": 4,
"column": 0
},
"end": {
"row": 4,
"column": 5
},
"range": {
"start": 30,
"end": 35
}
},
"target": {
"label": "bar",
"file": "/home/user/project/simpleCall.js",
"start": {
"row": 1,
"column": 0
},
"end": {
"row": 3,
"column": 1
},
"range": {
"start": 0,
"end": 29
}
},
"relation": "FunctionCall"
}
]
- Modules
- ES modules
- CommonJS
Refer to CONTRIBUTING.md for developer documentation.