Skip to content

btford/astral-pass

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Astral Pass

Pass helper for Astral that simplifies traversal.

Example

Below is a simple example.

var myPass = require('astral-pass')();

myPass.name = 'myPass';
myPass.prereqs = [ /* other pass names here */ ];

myPass.
  when({
    // ... AST chunk
  }).
  when(function (chunk, info) {
    // return true or false
  }).
  do(function (chunk, info) {

  });

More Complicated Passes

You can introduce more complicated behavior by composing passes. This is done by modifying a pass's prereqs property.

var astralPass = require('astral-pass');

// p1 needs some info to do its transformations

var p1 = astralPass();
p1.name = 'myPass';
p1.prereqs = [ 'p2' ];

p1.
  when( ... ).
  do( ... );

// p2 gathers the info for p1

var p2 = astralPass();
p2.name = 'myPass';

p2.
  when( ... ).
  do( ... );

I recommend namespacing passes with :.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published