Best JavaScript code snippet using wpt
RSBlock.js
Source: RSBlock.js
1// ErrorCorrectLevel2var ECL = require('./ErrorCorrectLevel');34function QRRSBlock(totalCount, dataCount) {5 this.totalCount = totalCount;6 this.dataCount = dataCount;7}89QRRSBlock.RS_BLOCK_TABLE = [1011 // L12 // M13 // Q14 // H1516 // 117 [1, 26, 19],18 [1, 26, 16],19 [1, 26, 13],20 [1, 26, 9],21 22 // 223 [1, 44, 34],24 [1, 44, 28],25 [1, 44, 22],26 [1, 44, 16],2728 // 329 [1, 70, 55],30 [1, 70, 44],31 [2, 35, 17],32 [2, 35, 13],3334 // 4 35 [1, 100, 80],36 [2, 50, 32],37 [2, 50, 24],38 [4, 25, 9],39 40 // 541 [1, 134, 108],42 [2, 67, 43],43 [2, 33, 15, 2, 34, 16],44 [2, 33, 11, 2, 34, 12],45 46 // 647 [2, 86, 68],48 [4, 43, 27],49 [4, 43, 19],50 [4, 43, 15],51 52 // 7 53 [2, 98, 78],54 [4, 49, 31],55 [2, 32, 14, 4, 33, 15],56 [4, 39, 13, 1, 40, 14],57 58 // 859 [2, 121, 97],60 [2, 60, 38, 2, 61, 39],61 [4, 40, 18, 2, 41, 19],62 [4, 40, 14, 2, 41, 15],63 64 // 965 [2, 146, 116],66 [3, 58, 36, 2, 59, 37],67 [4, 36, 16, 4, 37, 17],68 [4, 36, 12, 4, 37, 13],69 70 // 10 71 [2, 86, 68, 2, 87, 69],72 [4, 69, 43, 1, 70, 44],73 [6, 43, 19, 2, 44, 20],74 [6, 43, 15, 2, 44, 16],7576 // 1177 [4, 101, 81],78 [1, 80, 50, 4, 81, 51],79 [4, 50, 22, 4, 51, 23],80 [3, 36, 12, 8, 37, 13],8182 // 1283 [2, 116, 92, 2, 117, 93],84 [6, 58, 36, 2, 59, 37],85 [4, 46, 20, 6, 47, 21],86 [7, 42, 14, 4, 43, 15],8788 // 1389 [4, 133, 107],90 [8, 59, 37, 1, 60, 38],91 [8, 44, 20, 4, 45, 21],92 [12, 33, 11, 4, 34, 12],9394 // 1495 [3, 145, 115, 1, 146, 116],96 [4, 64, 40, 5, 65, 41],97 [11, 36, 16, 5, 37, 17],98 [11, 36, 12, 5, 37, 13],99100 // 15101 [5, 109, 87, 1, 110, 88],102 [5, 65, 41, 5, 66, 42],103 [5, 54, 24, 7, 55, 25],104 [11, 36, 12],105106 // 16107 [5, 122, 98, 1, 123, 99],108 [7, 73, 45, 3, 74, 46],109 [15, 43, 19, 2, 44, 20],110 [3, 45, 15, 13, 46, 16],111112 // 17113 [1, 135, 107, 5, 136, 108],114 [10, 74, 46, 1, 75, 47],115 [1, 50, 22, 15, 51, 23],116 [2, 42, 14, 17, 43, 15],117118 // 18119 [5, 150, 120, 1, 151, 121],120 [9, 69, 43, 4, 70, 44],121 [17, 50, 22, 1, 51, 23],122 [2, 42, 14, 19, 43, 15],123124 // 19125 [3, 141, 113, 4, 142, 114],126 [3, 70, 44, 11, 71, 45],127 [17, 47, 21, 4, 48, 22],128 [9, 39, 13, 16, 40, 14],129130 // 20131 [3, 135, 107, 5, 136, 108],132 [3, 67, 41, 13, 68, 42],133 [15, 54, 24, 5, 55, 25],134 [15, 43, 15, 10, 44, 16],135136 // 21137 [4, 144, 116, 4, 145, 117],138 [17, 68, 42],139 [17, 50, 22, 6, 51, 23],140 [19, 46, 16, 6, 47, 17],141142 // 22143 [2, 139, 111, 7, 140, 112],144 [17, 74, 46],145 [7, 54, 24, 16, 55, 25],146 [34, 37, 13],147148 // 23149 [4, 151, 121, 5, 152, 122],150 [4, 75, 47, 14, 76, 48],151 [11, 54, 24, 14, 55, 25],152 [16, 45, 15, 14, 46, 16],153154 // 24155 [6, 147, 117, 4, 148, 118],156 [6, 73, 45, 14, 74, 46],157 [11, 54, 24, 16, 55, 25],158 [30, 46, 16, 2, 47, 17],159160 // 25161 [8, 132, 106, 4, 133, 107],162 [8, 75, 47, 13, 76, 48],163 [7, 54, 24, 22, 55, 25],164 [22, 45, 15, 13, 46, 16],165166 // 26167 [10, 142, 114, 2, 143, 115],168 [19, 74, 46, 4, 75, 47],169 [28, 50, 22, 6, 51, 23],170 [33, 46, 16, 4, 47, 17],171172 // 27173 [8, 152, 122, 4, 153, 123],174 [22, 73, 45, 3, 74, 46],175 [8, 53, 23, 26, 54, 24],176 [12, 45, 15, 28, 46, 16],177178 // 28179 [3, 147, 117, 10, 148, 118],180 [3, 73, 45, 23, 74, 46],181 [4, 54, 24, 31, 55, 25],182 [11, 45, 15, 31, 46, 16],183184 // 29185 [7, 146, 116, 7, 147, 117],186 [21, 73, 45, 7, 74, 46],187 [1, 53, 23, 37, 54, 24],188 [19, 45, 15, 26, 46, 16],189190 // 30191 [5, 145, 115, 10, 146, 116],192 [19, 75, 47, 10, 76, 48],193 [15, 54, 24, 25, 55, 25],194 [23, 45, 15, 25, 46, 16],195196 // 31197 [13, 145, 115, 3, 146, 116],198 [2, 74, 46, 29, 75, 47],199 [42, 54, 24, 1, 55, 25],200 [23, 45, 15, 28, 46, 16],201202 // 32203 [17, 145, 115],204 [10, 74, 46, 23, 75, 47],205 [10, 54, 24, 35, 55, 25],206 [19, 45, 15, 35, 46, 16],207208 // 33209 [17, 145, 115, 1, 146, 116],210 [14, 74, 46, 21, 75, 47],211 [29, 54, 24, 19, 55, 25],212 [11, 45, 15, 46, 46, 16],213214 // 34215 [13, 145, 115, 6, 146, 116],216 [14, 74, 46, 23, 75, 47],217 [44, 54, 24, 7, 55, 25],218 [59, 46, 16, 1, 47, 17],219220 // 35221 [12, 151, 121, 7, 152, 122],222 [12, 75, 47, 26, 76, 48],223 [39, 54, 24, 14, 55, 25],224 [22, 45, 15, 41, 46, 16],225226 // 36227 [6, 151, 121, 14, 152, 122],228 [6, 75, 47, 34, 76, 48],229 [46, 54, 24, 10, 55, 25],230 [2, 45, 15, 64, 46, 16],231232 // 37233 [17, 152, 122, 4, 153, 123],234 [29, 74, 46, 14, 75, 47],235 [49, 54, 24, 10, 55, 25],236 [24, 45, 15, 46, 46, 16],237238 // 38239 [4, 152, 122, 18, 153, 123],240 [13, 74, 46, 32, 75, 47],241 [48, 54, 24, 14, 55, 25],242 [42, 45, 15, 32, 46, 16],243244 // 39245 [20, 147, 117, 4, 148, 118],246 [40, 75, 47, 7, 76, 48],247 [43, 54, 24, 22, 55, 25],248 [10, 45, 15, 67, 46, 16],249250 // 40251 [19, 148, 118, 6, 149, 119],252 [18, 75, 47, 31, 76, 48],253 [34, 54, 24, 34, 55, 25],254 [20, 45, 15, 61, 46, 16]255];256257QRRSBlock.getRSBlocks = function(typeNumber, errorCorrectLevel) {258 259 var rsBlock = QRRSBlock.getRsBlockTable(typeNumber, errorCorrectLevel);260 261 if (rsBlock == undefined) {262 throw new Error("bad rs block @ typeNumber:" + typeNumber + "/errorCorrectLevel:" + errorCorrectLevel);263 }264265 var length = rsBlock.length / 3;266 267 var list = new Array();268 269 for (var i = 0; i < length; i++) {270271 var count = rsBlock[i * 3 + 0];272 var totalCount = rsBlock[i * 3 + 1];273 var dataCount = rsBlock[i * 3 + 2];274275 for (var j = 0; j < count; j++) {276 list.push(new QRRSBlock(totalCount, dataCount) ); 277 }278 }279 280 return list;281}282283QRRSBlock.getRsBlockTable = function(typeNumber, errorCorrectLevel) {284285 switch(errorCorrectLevel) {286 case ECL.L :287 return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 0];288 case ECL.M :289 return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 1];290 case ECL.Q :
...
QRRSBlock.js
Source: QRRSBlock.js
1var QRErrorCorrectLevel = require('./QRErrorCorrectLevel');2function QRRSBlock(totalCount, dataCount) {3 this.totalCount = totalCount;4 this.dataCount = dataCount;5}6QRRSBlock.RS_BLOCK_TABLE = [7 // L8 // M9 // Q10 // H11 // 112 [1, 26, 19],13 [1, 26, 16],14 [1, 26, 13],15 [1, 26, 9],16 17 // 218 [1, 44, 34],19 [1, 44, 28],20 [1, 44, 22],21 [1, 44, 16],22 // 323 [1, 70, 55],24 [1, 70, 44],25 [2, 35, 17],26 [2, 35, 13],27 // 4 28 [1, 100, 80],29 [2, 50, 32],30 [2, 50, 24],31 [4, 25, 9],32 33 // 534 [1, 134, 108],35 [2, 67, 43],36 [2, 33, 15, 2, 34, 16],37 [2, 33, 11, 2, 34, 12],38 39 // 640 [2, 86, 68],41 [4, 43, 27],42 [4, 43, 19],43 [4, 43, 15],44 45 // 7 46 [2, 98, 78],47 [4, 49, 31],48 [2, 32, 14, 4, 33, 15],49 [4, 39, 13, 1, 40, 14],50 51 // 852 [2, 121, 97],53 [2, 60, 38, 2, 61, 39],54 [4, 40, 18, 2, 41, 19],55 [4, 40, 14, 2, 41, 15],56 57 // 958 [2, 146, 116],59 [3, 58, 36, 2, 59, 37],60 [4, 36, 16, 4, 37, 17],61 [4, 36, 12, 4, 37, 13],62 63 // 10 64 [2, 86, 68, 2, 87, 69],65 [4, 69, 43, 1, 70, 44],66 [6, 43, 19, 2, 44, 20],67 [6, 43, 15, 2, 44, 16],68 // 1169 [4, 101, 81],70 [1, 80, 50, 4, 81, 51],71 [4, 50, 22, 4, 51, 23],72 [3, 36, 12, 8, 37, 13],73 // 1274 [2, 116, 92, 2, 117, 93],75 [6, 58, 36, 2, 59, 37],76 [4, 46, 20, 6, 47, 21],77 [7, 42, 14, 4, 43, 15],78 // 1379 [4, 133, 107],80 [8, 59, 37, 1, 60, 38],81 [8, 44, 20, 4, 45, 21],82 [12, 33, 11, 4, 34, 12],83 // 1484 [3, 145, 115, 1, 146, 116],85 [4, 64, 40, 5, 65, 41],86 [11, 36, 16, 5, 37, 17],87 [11, 36, 12, 5, 37, 13],88 // 1589 [5, 109, 87, 1, 110, 88],90 [5, 65, 41, 5, 66, 42],91 [5, 54, 24, 7, 55, 25],92 [11, 36, 12],93 // 1694 [5, 122, 98, 1, 123, 99],95 [7, 73, 45, 3, 74, 46],96 [15, 43, 19, 2, 44, 20],97 [3, 45, 15, 13, 46, 16],98 // 1799 [1, 135, 107, 5, 136, 108],100 [10, 74, 46, 1, 75, 47],101 [1, 50, 22, 15, 51, 23],102 [2, 42, 14, 17, 43, 15],103 // 18104 [5, 150, 120, 1, 151, 121],105 [9, 69, 43, 4, 70, 44],106 [17, 50, 22, 1, 51, 23],107 [2, 42, 14, 19, 43, 15],108 // 19109 [3, 141, 113, 4, 142, 114],110 [3, 70, 44, 11, 71, 45],111 [17, 47, 21, 4, 48, 22],112 [9, 39, 13, 16, 40, 14],113 // 20114 [3, 135, 107, 5, 136, 108],115 [3, 67, 41, 13, 68, 42],116 [15, 54, 24, 5, 55, 25],117 [15, 43, 15, 10, 44, 16],118 // 21119 [4, 144, 116, 4, 145, 117],120 [17, 68, 42],121 [17, 50, 22, 6, 51, 23],122 [19, 46, 16, 6, 47, 17],123 // 22124 [2, 139, 111, 7, 140, 112],125 [17, 74, 46],126 [7, 54, 24, 16, 55, 25],127 [34, 37, 13],128 // 23129 [4, 151, 121, 5, 152, 122],130 [4, 75, 47, 14, 76, 48],131 [11, 54, 24, 14, 55, 25],132 [16, 45, 15, 14, 46, 16],133 // 24134 [6, 147, 117, 4, 148, 118],135 [6, 73, 45, 14, 74, 46],136 [11, 54, 24, 16, 55, 25],137 [30, 46, 16, 2, 47, 17],138 // 25139 [8, 132, 106, 4, 133, 107],140 [8, 75, 47, 13, 76, 48],141 [7, 54, 24, 22, 55, 25],142 [22, 45, 15, 13, 46, 16],143 // 26144 [10, 142, 114, 2, 143, 115],145 [19, 74, 46, 4, 75, 47],146 [28, 50, 22, 6, 51, 23],147 [33, 46, 16, 4, 47, 17],148 // 27149 [8, 152, 122, 4, 153, 123],150 [22, 73, 45, 3, 74, 46],151 [8, 53, 23, 26, 54, 24],152 [12, 45, 15, 28, 46, 16],153 // 28154 [3, 147, 117, 10, 148, 118],155 [3, 73, 45, 23, 74, 46],156 [4, 54, 24, 31, 55, 25],157 [11, 45, 15, 31, 46, 16],158 // 29159 [7, 146, 116, 7, 147, 117],160 [21, 73, 45, 7, 74, 46],161 [1, 53, 23, 37, 54, 24],162 [19, 45, 15, 26, 46, 16],163 // 30164 [5, 145, 115, 10, 146, 116],165 [19, 75, 47, 10, 76, 48],166 [15, 54, 24, 25, 55, 25],167 [23, 45, 15, 25, 46, 16],168 // 31169 [13, 145, 115, 3, 146, 116],170 [2, 74, 46, 29, 75, 47],171 [42, 54, 24, 1, 55, 25],172 [23, 45, 15, 28, 46, 16],173 // 32174 [17, 145, 115],175 [10, 74, 46, 23, 75, 47],176 [10, 54, 24, 35, 55, 25],177 [19, 45, 15, 35, 46, 16],178 // 33179 [17, 145, 115, 1, 146, 116],180 [14, 74, 46, 21, 75, 47],181 [29, 54, 24, 19, 55, 25],182 [11, 45, 15, 46, 46, 16],183 // 34184 [13, 145, 115, 6, 146, 116],185 [14, 74, 46, 23, 75, 47],186 [44, 54, 24, 7, 55, 25],187 [59, 46, 16, 1, 47, 17],188 // 35189 [12, 151, 121, 7, 152, 122],190 [12, 75, 47, 26, 76, 48],191 [39, 54, 24, 14, 55, 25],192 [22, 45, 15, 41, 46, 16],193 // 36194 [6, 151, 121, 14, 152, 122],195 [6, 75, 47, 34, 76, 48],196 [46, 54, 24, 10, 55, 25],197 [2, 45, 15, 64, 46, 16],198 // 37199 [17, 152, 122, 4, 153, 123],200 [29, 74, 46, 14, 75, 47],201 [49, 54, 24, 10, 55, 25],202 [24, 45, 15, 46, 46, 16],203 // 38204 [4, 152, 122, 18, 153, 123],205 [13, 74, 46, 32, 75, 47],206 [48, 54, 24, 14, 55, 25],207 [42, 45, 15, 32, 46, 16],208 // 39209 [20, 147, 117, 4, 148, 118],210 [40, 75, 47, 7, 76, 48],211 [43, 54, 24, 22, 55, 25],212 [10, 45, 15, 67, 46, 16],213 // 40214 [19, 148, 118, 6, 149, 119],215 [18, 75, 47, 31, 76, 48],216 [34, 54, 24, 34, 55, 25],217 [20, 45, 15, 61, 46, 16]218];219QRRSBlock.getRSBlocks = function(typeNumber, errorCorrectLevel) {220 221 var rsBlock = QRRSBlock.getRsBlockTable(typeNumber, errorCorrectLevel);222 223 if (rsBlock === undefined) {224 throw new Error("bad rs block @ typeNumber:" + typeNumber + "/errorCorrectLevel:" + errorCorrectLevel);225 }226 var length = rsBlock.length / 3;227 228 var list = [];229 230 for (var i = 0; i < length; i++) {231 var count = rsBlock[i * 3 + 0];232 var totalCount = rsBlock[i * 3 + 1];233 var dataCount = rsBlock[i * 3 + 2];234 for (var j = 0; j < count; j++) {235 list.push(new QRRSBlock(totalCount, dataCount) ); 236 }237 }238 239 return list;240};241QRRSBlock.getRsBlockTable = function(typeNumber, errorCorrectLevel) {242 switch(errorCorrectLevel) {243 case QRErrorCorrectLevel.L :244 return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 0];245 case QRErrorCorrectLevel.M :246 return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 1];247 case QRErrorCorrectLevel.Q :248 return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 2];249 case QRErrorCorrectLevel.H :...
Using AI Code Generation
1var typeNumber = 0;2var errorCorrectionLevel = 'L';3var qr = qrcode(typeNumber, errorCorrectionLevel);4qr.addData(data);5qr.make();6var qrsize = 300;7var margin = 4;8var tileW = qrsize / qr.getModuleCount();9var tileH = qrsize / qr.getModuleCount();10var scale = (window.devicePixelRatio || 1) / getBackingStorePixelRatio(qr);11var canvas = document.getElementById("canvas");12var ctx = canvas.getContext('2d');13canvas.height = canvas.width = qrsize * scale;14ctx.scale(scale, scale);15for (var row = 0; row < qr.getModuleCount(); row++) {16for (var col = 0; col < qr.getModuleCount(); col++) {17ctx.fillStyle = qr.isDark(row, col) ? "black" : "white";18var w = (Math.ceil((col + 1) * tileW) - Math.floor(col * tileW));19var h = (Math.ceil((row + 1) * tileW) - Math.floor(row * tileW));20ctx.fillRect(Math.round(col * tileW), Math.round(row * tileH), w, h);21}22}23function getBackingStorePixelRatio(ctx) {24return (ctx.webkitBackingStorePixelRatio ||25ctx.backingStorePixelRatio || 1);26}27var qrcode = function() {28var PAD0 = 0xEC;29var PAD1 = 0x11;30var _typeNumber = 4;31var _errorCorrectionLevel = 'L';32var _modules = null;33var _moduleCount = 0;34var _dataCache = null;35var _dataList = new Array();36var _this = {};37var makeImpl = false;38var PAD0, PAD1;39var _typeNumber = 4;40var _errorCorrectionLevel = 'L';41var _modules = null;42var _moduleCount = 0;43var _dataCache = null;
Check out the latest blogs from LambdaTest on this topic:
Testing is a critical step in any web application development process. However, it can be an overwhelming task if you don’t have the right tools and expertise. A large percentage of websites still launch with errors that frustrate users and negatively affect the overall success of the site. When a website faces failure after launch, it costs time and money to fix.
We launched LT Browser in 2020, and we were overwhelmed by the response as it was awarded as the #5 product of the day on the ProductHunt platform. Today, after 74,585 downloads and 7,000 total test runs with an average of 100 test runs each day, the LT Browser has continued to help developers build responsive web designs in a jiffy.
Smartphones have changed the way humans interact with technology. Be it travel, fitness, lifestyle, video games, or even services, it’s all just a few touches away (quite literally so). We only need to look at the growing throngs of smartphone or tablet users vs. desktop users to grasp this reality.
As part of one of my consulting efforts, I worked with a mid-sized company that was looking to move toward a more agile manner of developing software. As with any shift in work style, there is some bewilderment and, for some, considerable anxiety. People are being challenged to leave their comfort zones and embrace a continuously changing, dynamic working environment. And, dare I say it, testing may be the most ‘disturbed’ of the software roles in agile development.
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!