Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
stack trace instrumentation through AST manipulation
JavaScript
tree: 0071523d78

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
example
test
.travis.yml
README.markdown
index.js
package.json

README.markdown

fritter

Transform the AST in order to generate stack traces with no stack trace API necessary.

This module is like stackedy, except that it uses esprima by way of falafel.

build status

examples

var src = '(' + function () {
    (function fee () {
        [ 'foe', 'fum' ].forEach(fie);
    })();

    function fie (s) { smell(s) }
    function smell () { english('blood') }
}+ ')()'

var fritter = require('fritter');
var fry = fritter(src);
fry.on('error', function (err, c) {
    console.log(String(err));
    console.log('--------------------');
    c.stack.forEach(function (s) {
        console.log(
            s.callee.id && s.callee.id.name
            || src.slice(s.range[0], s.range[1] + 1)
        );
    });
    console.log('--------------------');
});

var vm = require('vm');
try {
    vm.runInNewContext(fry.source, fry.context);
} catch (err) { /* ignore this */ }

methods

var fritter = require('fritter')

var fry = fritter(src, context={})

Return a fry object given some javascript source src and some context to execute in and populate.

fry emits 'error' events with the error object and the present callstack as arguments when exceptions in src are thrown.

attributes

fry.source

transformed source to execute with something like vm.runInNewContext()

fry.context

context to execute fry.source with, including randomly-named wrapper functions to catch exceptions and track the call stack

fry.names

names of the randomly-generated wrapper functions

install

With npm do:

npm install fritter

license

MIT

Something went wrong with that request. Please try again.