var fs  = require('fs');
var Bitmap =  require(__dirname+'/lib/bitmap.js');
var vm  = require('vm');


function load(path) {
    var rootPath = __dirname + "/" + path;
    var text = fs.readFileSync(rootPath);
    if (!text)
        var bwippPath = __dirname + "/bwipp/" + path;
    var text = fs.readFileSync(rootPath);
    if (!text)
        throw new Error(path + ": could not read file");

    console.log('loading: ' + path);
    vm.runInThisContext(text, path);
}

// Load the primary bwip-js script
load('bwip.js');


// Set the hook for demand-loading the remaining bwip-js files
BWIPJS.load = load;

module.exports.createQR = function (text, callback){

    var bw = new BWIPJS;
    var rot = 'N';
    var opts= {};
    opts.inkspread = bw.value(0);
    opts.alttext = bw.value(text);
    opts.includetext = bw.value(true);

    bw.bitmap(new Bitmap);
    bw.scale(1, 1);
    bw.push(text);
    bw.push(opts);
    bw.call("qrcode");
    var png = bw.bitmap().getPNG(rot);
    callback(png);
}

module.exports.createBarcode = function (text, callback){

    var bw = new BWIPJS;
    var rot = 'N';
    var opts= {};
    opts.inkspread = bw.value(0);
    opts.alttext = bw.value(text);
    opts.includetext = bw.value(true);

    bw.bitmap(new Bitmap);
    bw.scale(1, 1);
    bw.push(text);
    bw.push(opts);
    bw.call("interleaved2of5");
    var png = bw.bitmap().getPNG(rot);
    callback(png);

}
@@ -627,10 +627,15 @@
 eate
-QR
+Barcode
  = f
@@ -635,36 +635,36 @@
 ode = function (
-text
+data
 , callback)%7B%0A%0A  
@@ -669,401 +669,111 @@
     
-var bw = new BWIPJS;%0A    var rot = 'N';%0A    var opts
+/*data 
 = %7B
-%7D;
 %0A    
-opts.inkspread = bw.value(0);%0A    opts.alttext = bw.value(text);%0A    opts.includetext = bw.value(true);%0A%0A    bw.bitmap(new Bitmap);%0A    bw.scale(1, 1);%0A    bw.push(text);%0A    bw.push(opts);%0A    bw.call(%22qrcode%22);%0A    var png = bw.bitmap().getPNG(rot);%0A    callback(png);%0A%7D%0A%0Amodule.exports.createBarcode = function (text, callback)%7B
+ text : 'asd',%0A     type : 'interleaved2of5',%0A     scale : 2,%0A     rotate : 'N'%0A     %7D*/
 %0A%0A  
@@ -812,14 +812,30 @@
 ot =
+ data.rotate %7C%7C
  'N';%0A
+%0A
     
@@ -849,20 +849,17 @@
 s= %7B
-%7D;
 %0A    
-opts.
+    
 inks
@@ -864,17 +864,17 @@
 kspread 
-=
+:
  bw.valu
@@ -881,27 +881,26 @@
 e(0)
-;
+,
 %0A    
-opts.
+    
 alttext 
 = bw
@@ -891,25 +891,25 @@
     alttext 
-=
+:
  bw.value(te
@@ -910,24 +910,28 @@
 lue(
-text);%0A    opts.
+data.text),%0A        
 incl
@@ -938,17 +938,17 @@
 udetext 
-=
+:
  bw.valu
@@ -954,16 +954,22 @@
 ue(true)
+%0A    %7D
 ;%0A%0A    b
@@ -1007,12 +1007,30 @@
 ale(
-1, 1
+data.scale, data.scale
 );%0A 
@@ -1040,16 +1040,21 @@
 bw.push(
+data.
 text);%0A 
@@ -1087,25 +1087,17 @@
 all(
-%22interleaved2of5%22
+data.type
 );%0A 

Generalize call, add an options array that receives a couple params