Comparing version
{ | ||
"name": "qrcode", | ||
"description": "QRCode / 2d Barcode api with both server side and client side support using canvas", | ||
"version": "0.4.4", | ||
"version": "0.5.0", | ||
"author": "Ryan Day <soldair@gmail.com>", | ||
"contributors": [ | ||
"vigreco" | ||
], | ||
"keywords": [ | ||
@@ -17,3 +20,3 @@ "canvas", | ||
"prepublish": "node build.js", | ||
"test": "tap test/url.js" | ||
"test": "tap test/url.js test/svg.js" | ||
}, | ||
@@ -29,7 +32,8 @@ "bin": { | ||
"devDependencies": { | ||
"express": "2.5.x", | ||
"browserify": "~2.29.0", | ||
"uglify-js": "1.2.x", | ||
"canvasutil": "*", | ||
"tap": "*" | ||
"express": "2.5.x", | ||
"libxmljs": "^0.18.0", | ||
"tap": "*", | ||
"uglify-js": "1.2.x" | ||
}, | ||
@@ -36,0 +40,0 @@ "repository": { |
@@ -14,2 +14,3 @@ /* | ||
, terminalRender = require('./lib/termialrender.js') | ||
, svgRender = require('./lib/svgrender') | ||
, Canvas = require('canvas') | ||
@@ -138,2 +139,12 @@ , fs = require('fs'); | ||
var fileExt = path.slice((path.lastIndexOf(".") - 1 >>> 0) + 2).toLowerCase(); | ||
if (fileExt === 'svg') { | ||
saveSvg(path,text,options,cb); | ||
} else { | ||
savePng(path,text,options,cb); | ||
} | ||
}; | ||
function savePng(path,text,options,cb){ | ||
draw(text, options, function(error,canvas){ | ||
@@ -162,5 +173,15 @@ | ||
}); | ||
}; | ||
} | ||
function saveSvg(path,text,options,cb){ | ||
exports.drawSvg(text,function(error,code){ | ||
if (!error) { | ||
fs.writeFile(path, code, function(fsErr) { | ||
return cb(fsErr, fsErr ? null : code); | ||
}); | ||
} | ||
}); | ||
} | ||
// | ||
@@ -205,1 +226,17 @@ //this returns an array of points that have either a 0 or 1 value representing 0 for light and 1 for dark | ||
exports.drawSvg = function(text,options,cb){ | ||
if(typeof options == 'function'){ | ||
cb = options; | ||
options = {}; | ||
} | ||
var drawInstance = new QRCodeDraw(); | ||
drawInstance.drawBitArray(text,function(error,bits,width){ | ||
if (!error) { | ||
var code = svgRender.renderBits(bits,width,options); | ||
cb(error,code); | ||
} else { | ||
cb(error,null); | ||
} | ||
}); | ||
} |
@@ -57,2 +57,3 @@ [](http://travis-ci.org/soldair/node-qrcode) | ||
--- | ||
```javascript | ||
@@ -62,5 +63,12 @@ QRCode.draw(text, [optional options], cb(error,canvas)); | ||
Returns a node canvas object see https://github.com/LearnBoost/node-canvas for all of the cool node things you can do. Look up the canvas api for the other cool things. | ||
```javascript | ||
QRCode.toDataURL(text, [optional options], cb(error,dataURL)); | ||
``` | ||
SVG output! | ||
```javascript | ||
QRCode.drawSvg(text, [optional options],cb(error, svgString)); | ||
``` | ||
Returns mime image/png data url for the 2d barcode. | ||
@@ -67,0 +75,0 @@ ```javascript |
Sorry, the diff of this file is not supported yet
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
826843
2.93%32
10.34%4466
3%177
4.73%6
20%14
16.67%