Merge pull request from vigreco/fix/typed-array

Remove unused Uint32Array and replace it with Array
This commit is contained in:
Ryan Day 2016-09-26 09:03:01 -04:00 committed by GitHub
commit 7d57b052d4
2 changed files with 9 additions and 12 deletions

View file

@ -31,7 +31,6 @@ QRCodeDraw.prototype = {
scale:4,//4 px module size
defaultMargin:20,
marginScaleFactor:5,
Array:(typeof Uint32Array == 'undefined'?Uint32Array:Array),
// you may configure the error behavior for input string too long
errorBehavior:{
length:'trim'
@ -158,7 +157,7 @@ QRCodeDraw.prototype = {
qr.make();
width = this.dataWidth(qr,1);
bits = new this.Array(width*width);
bits = new Array(width*width);
for (var r = 0,rl=qr.getModuleCount(); r < rl; r++) {

View file

@ -37,15 +37,13 @@ var bops = require('bops');
exports.QRCode = QRCode;
var QRDataArray = (typeof Uint32Array == 'undefined'?Uint32Array:Array);
function QRCode(typeNumber, errorCorrectLevel) {
this.typeNumber = typeNumber;
this.errorCorrectLevel = errorCorrectLevel;
this.modules = null;
this.moduleCount = 0;
this.dataCache = null;
this.dataList = new QRDataArray();
this.dataList = [];
}
QRCode.prototype = {
@ -75,11 +73,11 @@ QRCode.prototype = {
makeImpl : function(test, maskPattern) {
this.moduleCount = this.typeNumber * 4 + 17;
this.modules = new QRDataArray(this.moduleCount);
this.modules = new Array(this.moduleCount);
for (var row = 0; row < this.moduleCount; row++) {
this.modules[row] = new QRDataArray(this.moduleCount);
this.modules[row] = new Array(this.moduleCount);
for (var col = 0; col < this.moduleCount; col++) {
this.modules[row][col] = null;//(col + row) % 3;
@ -363,8 +361,8 @@ QRCode.createBytes = function(buffer, rsBlocks) {
var maxDcCount = 0;
var maxEcCount = 0;
var dcdata = new QRDataArray(rsBlocks.length);
var ecdata = new QRDataArray(rsBlocks.length);
var dcdata = new Array(rsBlocks.length);
var ecdata = new Array(rsBlocks.length);
for (var r = 0; r < rsBlocks.length; r++) {
@ -374,7 +372,7 @@ QRCode.createBytes = function(buffer, rsBlocks) {
maxDcCount = Math.max(maxDcCount, dcCount);
maxEcCount = Math.max(maxEcCount, ecCount);
dcdata[r] = new QRDataArray(dcCount);
dcdata[r] = new Array(dcCount);
for (var i = 0; i < dcdata[r].length; i++) {
dcdata[r][i] = 0xff & buffer.buffer[i + offset];
@ -385,7 +383,7 @@ QRCode.createBytes = function(buffer, rsBlocks) {
var rawPoly = new QRPolynomial(dcdata[r], rsPoly.getLength() - 1);
var modPoly = rawPoly.mod(rsPoly);
ecdata[r] = new QRDataArray(rsPoly.getLength() - 1);
ecdata[r] = new Array(rsPoly.getLength() - 1);
for (var i = 0; i < ecdata[r].length; i++) {
var modIndex = i + modPoly.getLength() - ecdata[r].length;
ecdata[r][i] = (modIndex >= 0)? modPoly.get(modIndex) : 0;
@ -398,7 +396,7 @@ QRCode.createBytes = function(buffer, rsBlocks) {
totalCodeCount += rsBlocks[i].totalCount;
}
var data = new QRDataArray(totalCodeCount);
var data = new Array(totalCodeCount);
var index = 0;
for (var i = 0; i < maxDcCount; i++) {