• Stars
    star
    168
  • Rank 225,507 (Top 5 %)
  • Language
    JavaScript
  • Created over 11 years ago
  • Updated about 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

creates a control flow graph from an esprima abstract syntax tree

esgraph

creates a control flow graph from an esprima abstract syntax tree

Build Status Coverage Status Dependency Status

Installation

$ npm install esgraph

Usage

esgraph

The esgraph binary reads from stdin and outputs dot-format usable by graphviz. To create a png file showing the CFG of a js file:

$ cat $file | esgraph | dot -Tpng > output.png

example graph

library

const esgraph = require("esgraph");

const cfg = esgraph(esprima.parse(source, { range: true }));
// cfg[0] is the start node
// cfg[1] is the end node
// cfg[2] is an array of all nodes for easier iteration

// each node has:
node.astNode; // this is the original esprima AST node, either a statement or an expression
node.prev; // an array of predecessor nodes
node.next; // an array of all successor nodes

// the successor nodes are also awailable by type:
node.normal; // the next statement reached via normal flow
node.true; // the next statement reached when `node.astNode` evaluates to true
node.false; // the next statement reached when `node.astNode` evaluates to false
node.exception; // the next statement reached when `node.astNode` throws

const dot = esgraph.dot(cfg, { counter: startCount, source: source });
// returns the cfg printed in graphviz dot format.
node.label; // can be used to use a custom label for that node
// otherwise `esgraph.dot` will print the nodes source when the ast is created
// with {range: true} and {source: source} option is set

License

LGPLv3

More Repositories

1

rust-cache

A GitHub Action that implements smart caching for rust/cargo projects
TypeScript
1,275
star
2

rollup-plugin-dts

A rollup plugin to generate .d.ts rollup files for your typescript project
TypeScript
804
star
3

diff

implementation of myers diff algorithm
JavaScript
82
star
4

virtualdom

tools to work with a virtual dom
JavaScript
31
star
5

jade-virtualdom

compile jade templates to virtualdom
JavaScript
21
star
6

proxy

Small shim providing `new Proxy(target, handler)`
JavaScript
14
star
7

walkes

very simple walker for estree AST
JavaScript
12
star
8

scroll-beyond

Very simple gedit plugin to scroll past the end of documents
Python
12
star
9

cow

copy on write deep, cyclic js objects
JavaScript
9
star
10

analyses

basic data flow analyses framework based on esprima
JavaScript
9
star
11

fucov

A GitHub Action that does single-action code coverage generation.
TypeScript
8
star
12

scrollbars

An efficient overflow area with custom scrollbars
JavaScript
8
star
13

wamp1

Very simple WAMP v1 implementation
JavaScript
7
star
14

perf-cpuprofile

Converts linux `perf` tool output to .cpuprofile files readable by chromiums devtools
JavaScript
7
star
15

tern_for_gedit

This is a simple gedit plugin that provides code completion results based on tern
Python
6
star
16

next-monorepo

reproduction for some problems with monorepos
TypeScript
4
star
17

analyses-old

Static Analysis based on Esprima
JavaScript
3
star
18

inferences

type inference for js
JavaScript
3
star
19

rust-maintain

A GitHub Action to do crate maintenance
Rust
3
star
20

stream-utils

some utilities for whatwg streams
JavaScript
2
star
21

hexite

TypeScript
2
star
22

psy

Rust
2
star
23

yavd

yet another virtual dom library
JavaScript
2
star
24

codingcontest-2018-11-16

https://register.codingcontest.org/listing/6-2018-11-16
TypeScript
2
star
25

model

transparent ES5 models
JavaScript
2
star
26

fondoeh

Rust
2
star
27

channel-utils

1
star
28

motorina

too early to reveal :-)
TypeScript
1
star
29

fast-babel-register

Temporary fork until @babel/register upstream is fast enough
JavaScript
1
star
30

model-cast

Automatically cast properties for Swatinem/model
JavaScript
1
star
31

dotfiles

Vim Script
1
star
32

style-canvas

Component to apply CSS styles to a canvas
JavaScript
1
star
33

pinch

experiments with csp
JavaScript
1
star
34

normalize-serve-jade

Opinionated jade server for frontend development workflow using Normalize.IO
JavaScript
1
star
35

depstalk

Scrape the dependents of a GitHub repository
Rust
1
star
36

component-istanbul

instruments component files with istanbul coverage
JavaScript
1
star
37

observ-delegate

A observable value representation that delegates to a different observable value
JavaScript
1
star
38

crid

Crid - The cryptographic ID serializer
Rust
1
star
39

websocket-buffering

small wrapper around websocket that does message buffering and reconnects
JavaScript
1
star
40

component-linknpm

Link downloaded components into node_modules
JavaScript
1
star
41

co-promisify

Seems like I have duplicated this. So just use
JavaScript
1
star