regexper-static/lib/canopy-transform.js
2015-11-01 10:28:37 -05:00

25 lines
419 B
JavaScript

var through = require('through'),
canopy = require('canopy');
module.exports = function(file) {
var data = '';
if (!/\.peg$/.test(file)) {
return through();
}
return through(
function(buf) {
data += buf;
},
function() {
try {
this.queue(String(canopy.compile(data)));
} catch(err) {
this.emit('error', err);
}
this.queue(null);
}
);
};