1.0.0 • Published 3 years ago

@ticklepoke/sayjs v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

SAY.JS - A Static Analyser for Javascript

npm

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.

Usage

Installation

yarn add @ticklepoke/sayjs
npm install @ticklepoke/sayjs

CLI Usage

  • 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

Programming Interface

import sayjs from '@ticklepoke/sayjs';
// or
const sayjs = require('@ticklepoke/sayjs');

sayjs.setFiles(['file.js', 'directory/']);
const edges = sayjs.build();

Output JSON

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"
  }
]

Supported Modern Javascript Features

  • Modules
    • ES modules
    • CommonJS

Contributing

Refer to CONTRIBUTING.md for developer documentation.