Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including astral-pass with all npm packages installed. Try it out:

var astralPass = require("astral-pass")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

astral-pass v0.1.0

Pass system for Astral

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

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free