Simple interface for checking structure of JS code against a template, backed by Esprima.

npm install structured
2 downloads in the last week
4 downloads in the last month

structured.js is a Javascript library that provides a simple interface for static analysis of Javascript code, backed by the abstract syntax tree generated by Esprima. Structured.js works in-browser <script src='structured.js'></script>, or as a standalone npm module.


var structure = function structure() {
  var _ = _;
  if (_ % 2 == 1) {
    _ += 1;
var code = "var a = 11; var b = 1; if (a % 2 == 1) { b += 1;}"
var result = Structured.match(structure, code); // true

Check out the test suite for more.


demo/demo.html provides a user interface to create and test wildcard structures. The demo page is a good way to get a feel for the analysis and generate QUnit tests.


Run structured.js tests with npm test or by opening browser-test/index.html.


Esprima and UnderscoreJS for the framework, QUnit for the test suite.

npm loves you