falafel-helpers

0.0.3 • Public • Published

falafel-helpers

Wraps your falafel callback function, adding handy helpers:

var falafelHelpers = require('falafel-helpers');
 
var src = falafel(fs.readFileSync('test.js', 'utf8'), helpers.wrap(function (node) {
    if (/Expression$/.test(node.type)) {
        node.wrap('debug(', ')');
    } else if (node.type === 'BlockStatement') {
        node.before('console.log("entering block");');
        node.after('console.log("exiting block");', true); // second argument makes it use a try-finally to always execute the inserted code
    }
});

Also works with falafel-map:

var falafelHelpers = require('falafel-helpers');
 
var src = falafel(fs.readFileSync('test.js', 'utf8'), helpers.wrap(function (node) {
    if (/Expression$/.test(node.type)) {
        node.wrap('debug(', ')');
    }
}, { falafelMap: true }));

Readme

Keywords

none

Package Sidebar

Install

npm i falafel-helpers

Weekly Downloads

1

Version

0.0.3

License

MIT

Last publish

Collaborators

  • alltom