Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lean-qr

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lean-qr - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

1

bin/cli.js

@@ -11,2 +11,3 @@ #!/usr/bin/env node

ENCODINGS.set('iso-8859-1', mode.iso8859_1);
ENCODINGS.set('utf8', mode.utf8);

@@ -13,0 +14,0 @@ const TEXT_FORMATS = new Map();

2

build/index.js

@@ -1,2 +0,2 @@

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("lean-qr",[],e):"object"==typeof exports?exports["lean-qr"]=e():t["lean-qr"]=e()}(global,(function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var s=e[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,r),s.l=!0,s.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)r.d(n,s,function(e){return t[e]}.bind(null,s));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){t.exports=r(1)},function(t,e,r){"use strict";r.r(e),r.d(e,"correction",(function(){return o})),r.d(e,"mode",(function(){return f})),r.d(e,"generate",(function(){return B}));const n=t=>{const e=t>>18,r=t>>12&63,n=t>>5&127;return{capBits:8*(r*n+e*(n+1)),groups:e?[[r,n],[e,n+1]]:[[r,n]],ecsize:31&t}},s=[{id:1,v:[4711,5194,5871,6676,7578,10386,10708,11320,11934,534674,18996,535448,19834,278142,285430,285784,1318268,286494,1064508,1326460,1068700,1846780,1331006,1076926,1084762,568924,1085278,2637502,1867422,2645630,843390,73342,335486,1629822,1888062,3698494,1122142,4738910,1134270,1654494].map(n)},{id:0,v:[4618,5008,5530,9234,9592,17264,17394,533718,537750,279930,1054302,550038,296118,1328408,1332536,816572,304604,1086842,2897306,3421498,71002,71132,3687932,3696060,3442172,1127900,878012,6043068,1922492,2700796,7611868,6071772,5563868,6088156,6866428,8939004,3790300,8443356,2000380,8201724].map(n)},{id:3,v:[4525,4822,8754,8986,532978,17016,1057234,541270,1065492,549496,1065692,1589914,1082008,1356308,1856286,586360,3936988,332508,1118906,1372958,1643228,4223774,3715870,4240158,5796638,1688284,6849278,8143646,9704190,6615838,434974,9216798,5100318,2016030,3830558,2810654,2822942,3867422,5944094,9052958].map(n)},{id:2,v:[4401,4636,8630,16688,532854,16892,278970,541146,1065368,549372,2109848,1077724,1098102,1356184,1880472,3420670,4465116,4989404,4231610,2683388,1651230,139704,3736062,647710,3498494,1184286,7389694,8172030,6894078,6648318,7434750,9253374,12104190,504350,10838526,16785918,12157438,8561150,17605118,16073214].map(n)}],o={min:0,L:0,M:1,Q:2,H:3,max:3},i=t=>"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:".indexOf(t),l=t=>(e,r)=>{e.push(1,4),e.push(t.length,r<10?10:r<27?12:14);let n=0;for(;n<t.length-2;n+=3)e.push(Number(t.substr(n,3)),10);n<t.length-1?e.push(Number(t.substr(n,2)),7):n<t.length&&e.push(Number(t.substr(n,1)),4)},u=t=>(e,r)=>{e.push(2,4),e.push(t.length,r<10?9:r<27?11:13);let n=0;for(;n<t.length-1;n+=2)e.push(45*i(t[n])+i(t[n+1]),11);n<t.length&&e.push(i(t[n]),6)},a=t=>(e,r)=>{e.push(4,4),e.push(t.length,r<10?8:16);for(let r=0;r<t.length;++r)e.push(t.codePointAt(r),8)},c=t=>t.reduce((t,e)=>!t||e.e<t.e?e:t);l.reg=/[0-9]/,l.est=(t,e)=>4+(e<10?10:e<27?12:14)+10*t.length/3,u.reg=/[0-9A-Z $%*+./:-]/,u.est=(t,e)=>4+(e<10?9:e<27?11:13)+5.5*t.length,a.reg=/[\u0000-\u00FF]/,a.est=(t,e)=>4+(e<10?8:16)+8*t.length;var f={auto:(t,{modes:e=[l,u,a]}={})=>(r,n)=>{let s=[{c:0,e:0}];[...t].forEach((r,o)=>{if(s=e.filter(t=>t.reg.test(r)).map(e=>c(s.map(r=>{const s={c:e,p:r.c===e?r.p:r,s:r.c===e?r.s:o};return s.v=t.substring(s.s,o+1),s.e=s.p.e+Math.ceil(e.est(s.v,n)),s}))),!s.length)throw new Error("Unencodable")});const o=[];for(let t=c(s);t.c;t=t.p)o.unshift(t.c(t.v));o.forEach(t=>t(r,n))},multi:(...t)=>(e,r)=>t.forEach(t=>t(e,r)),numeric:l,alphaNumeric:u,iso8859_1:a};class h{constructor(t){this.bytes=new Uint8Array(t),this.bits=0}push(t,e){for(let r=e,n=8-(7&this.bits);r>0;r-=n,n=8)this.bytes[this.bits>>>3]|=t<<n>>>r,this.bits+=Math.min(r,n)}}class p{constructor({size:t,d:e}){this.size=t,this.d=new Uint8Array(e||t*t)}get(t,e){return!!(1&this.d[e*this.size+t])}masked(t,e){return 2&this.d[e*this.size+t]}set(t,e,r,n=1){this.d[e*this.size+t]=2*n|!!r}inv(t,e){this.d[e*this.size+t]^=1}toString({on:t="##",off:e=" ",lf:r="\n",padX:n=4,padY:s=4}={}){const o=(e.repeat(this.size+2*n)+r).repeat(s),i=e.repeat(n);let l=o;for(let n=0;n<this.size;++n){l+=i;for(let r=0;r<this.size;++r)l+=this.get(r,n)?t:e;l+=i+r}return l+o}toImageData(t,{on:e=4278190080,off:r=0}={}){const n=t.createImageData(this.size,this.size),s=new Uint32Array(n.data.buffer);s.fill(r);for(let t=0;t<this.size*this.size;++t)s[t]=1&this.d[t]?e:r;return n}toCanvas(t,{padX:e=4,padY:r=4,...n}={}){t.width=this.size+2*e,t.height=this.size+2*r;const s=t.getContext("2d"),o=this.toImageData(s,n);s.putImageData(o,e,r)}}var d=[(t,e)=>!(1&(t^e)),(t,e)=>!(1&e),t=>!(t%3),(t,e)=>!((t+e)%3),(t,e)=>!(1&(Math.floor(t/3)^Math.floor(e/2))),(t,e)=>!((t&e&1)+t*e%3),(t,e)=>!((t&e&1)+t*e%3&1),(t,e)=>!((1&(t^e))+t*e%3&1)];const g=new Uint8Array(512);g[0]=1;for(let t=0,e=1;t<255;g[++t]=e)g[e+256]=t,e*=2,256&e&&(e^=285);const m=t=>g[t%255],b=t=>g[t+256],v=(t,e)=>{const r=new Uint8Array(t.length+e.length-1);for(let n=0;n<t.length;++n)for(let s=0;s<e.length;++s)r[n+s]^=m(t[n]+e[s]);return r.map(b)},z=(t,e)=>{const r=new Uint8Array(t.length+e.length-1);r.set(t,0);for(let n=0;n<t.length;++n)if(r[n]){const t=b(r[n]);for(let s=0;s<e.length;++s)r[n+s]^=m(e[s]+t)}return r.slice(t.length)},y=[[0],[0,0]];for(let t=1,e=y[1];t<30;++t){const r=v(e,[0,t]);y.push(r),e=r}const w=(t,e,r)=>{let n=e;const s=Math.max(...r.map(t=>t.length));for(let e=0;e<s;++e)r.forEach(r=>{e<r.length&&(t[n++]=r[e])});return n};var x=(t,{groups:e,ecsize:r})=>{const n=[],s=[];let o=0,i=0;e.forEach(([e,l])=>{for(let i=0;i<e;++i,o+=l){const e=t.slice(o,o+l);n.push(e),s.push(z(e,y[r]))}i+=e*(l+r)});const l=new Uint8Array(i),u=w(l,0,n);return w(l,u,s),l};const M=(t,e,r)=>{let n=t<<r-1;for(let t=1073741824;t;t>>>=1)n&t&&(n^=e*(t>>>r-1));return n},E=(t,e,r,n,s,o)=>{for(let i=r;i<s;++i)for(let r=e;r<n;++r)t.set(r,i,o)},j=(t,e,r)=>{E(t,e-3,r-3,e+4,r+4,1),E(t,e-2,r-2,e+3,r+3,0),E(t,e-1,r-1,e+2,r+2,1)},A=(t,e,r)=>{E(t,e-2,r-2,e+3,r+3,1),E(t,e-1,r-1,e+2,r+2,0),t.set(e,r,1)},O=t=>{const e=t.size,r=[];for(let n=e-2,s=e,o=-1;n>=0;n-=2){for(5===n&&(n=4);s+=o,-1!==s&&s!==e;)t.masked(n+1,s)||r.push([n+1,s]),t.masked(n,s)||r.push([n,s]);o*=-1}return r},U=(t,e,r)=>{e.forEach(([e,n],s)=>t.set(e,n,r[s>>3]<<(7&s)&128,0))},I=(t,e,r,n)=>{for(let r=0;r<t.size;++r)for(let n=0;n<t.size;++n)e(n,r)&&!t.masked(n,r)&&t.inv(n,r);const s=n<<3|r,o=21522^(s<<10|M(s,1335,11));let i=16384;for(let e=0;e<7;++e){const r=o&i;t.set(6===e?7:e,8,r),t.set(8,t.size-e-1,r),i>>>=1}for(let e=0;e<8;++e){const r=o&i;t.set(8,(e>1?7:8)-e,r),t.set(t.size-8+e,8,r),i>>>=1}},P=(t,e,r)=>{for(let n=0;n<t.size;++n){let s=e,o=e;for(let e=0;e<t.size;++e)s=r(s,t.get(e,n)),o=r(o,t.get(n,e))}};var S=t=>(t=>{let e=0;return P(t,[0],([t,r],n)=>n!==r?[1,n]:(4===t?e+=3:t>4&&++e,[t+1,r])),e})(t)+3*(t=>{let e=0;for(let r=1;r<t.size;++r){let n=t.get(r-1,0),s=t.get(r,0)===n;for(let o=1;o<t.size;++o){const i=t.get(r-1,o),l=t.get(r,o)===i;e+=s&&l&&n===i,n=i,s=l}}return e})(t)+40*(t=>{let e=0;return P(t,0,(t,r)=>{const n=(t>>>1|2098176)&(3047517^(r?0:-1));return 2049&n&&++e,n}),e})(t)+(t=>{let e=0;for(let r=0;r<t.size;++r)for(let n=0;n<t.size;++n)e+=t.get(n,r);return 10*Math.floor(20*Math.abs(e/(t.size*t.size)-.5))})(t);const _=[],k=t=>{let e=_[t];if(!e){const r=new p({size:4*t+17});((t,e)=>{const r=4*e+17;j(t,3,3),j(t,r-4,3),j(t,3,r-4),E(t,0,7,9,9,0),E(t,7,0,9,7,0),E(t,r-8,7,r,9,0),E(t,r-8,0,r-7,7,0),E(t,7,r-8,9,r,0),E(t,0,r-8,7,r-7,0),t.set(8,r-8,1);for(let e=8;e<r-8;++e)t.set(e,6,!(1&e)),t.set(6,e,!(1&e));if(e>=2){const n=Math.floor(e/7)+1,s=2*Math.ceil((r-13)/n/2-.25),o=[6];for(let t=n;t-- >0;)o.push(r-7-t*s);for(let e=0;e<=n;++e)for(let r=0;r<=n;++r)!e&&!r||!e&&r===n||e===n&&!r||A(t,o[e],o[r])}if(e>=7){const n=e<<12|M(e,7973,13);let s=1<<17;for(let e=6;e-- >0;)for(let o=0;o<3;++o){const i=n&s;t.set(e,r-9-o,i),t.set(r-9-o,e,i),s>>>=1}}})(r,t),_[t]=e=[r,O(r)]}return[new p(e[0]),e[1]]};var B=(t,{minCorrectionLevel:e=o.min,maxCorrectionLevel:r=o.max,minVersion:n=1,maxVersion:i=40,mask:l=null}={})=>{if(r<e)throw new Error("Invalid correction level range");if(i<n)throw new Error("Invalid version range");"string"==typeof t&&(t=f.auto(t));let u=0;for(let o=n;o<=i;++o){if(s[e].v[o-1].capBits<u)continue;const n=new h(2956);t(n,o),u=n.bits;for(let t=r;t>=e;--t){const e=s[t],r=e.v[o-1];if(r.capBits<u)continue;for(n.push(0,4),n.bits=n.bits+7&-8;n.bits<r.capBits;)n.push(60433,16);const[i,a]=k(o);return U(i,a,x(n.bytes,r)),null!==l?(I(i,d[l],l,e.id),i):d.map((t,r)=>{const n=new p(i);return I(n,t,r,e.id),n.s=S(n),n}).reduce((t,e)=>!t||e.s<t.s?e:t)}}throw new Error("Too much data")}}])}));
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("lean-qr",[],e):"object"==typeof exports?exports["lean-qr"]=e():t["lean-qr"]=e()}(global,(function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var s=e[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,r),s.l=!0,s.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)r.d(n,s,function(e){return t[e]}.bind(null,s));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){t.exports=r(1)},function(t,e,r){"use strict";r.r(e),r.d(e,"correction",(function(){return o})),r.d(e,"mode",(function(){return g})),r.d(e,"generate",(function(){return L}));const n=t=>{const e=t>>18,r=t>>12&63,n=t>>5&127;return{capBits:8*(r*n+e*(n+1)),groups:e?[[r,n],[e,n+1]]:[[r,n]],ecsize:31&t}},s=[{id:1,v:[4711,5194,5871,6676,7578,10386,10708,11320,11934,534674,18996,535448,19834,278142,285430,285784,1318268,286494,1064508,1326460,1068700,1846780,1331006,1076926,1084762,568924,1085278,2637502,1867422,2645630,843390,73342,335486,1629822,1888062,3698494,1122142,4738910,1134270,1654494].map(n)},{id:0,v:[4618,5008,5530,9234,9592,17264,17394,533718,537750,279930,1054302,550038,296118,1328408,1332536,816572,304604,1086842,2897306,3421498,71002,71132,3687932,3696060,3442172,1127900,878012,6043068,1922492,2700796,7611868,6071772,5563868,6088156,6866428,8939004,3790300,8443356,2000380,8201724].map(n)},{id:3,v:[4525,4822,8754,8986,532978,17016,1057234,541270,1065492,549496,1065692,1589914,1082008,1356308,1856286,586360,3936988,332508,1118906,1372958,1643228,4223774,3715870,4240158,5796638,1688284,6849278,8143646,9704190,6615838,434974,9216798,5100318,2016030,3830558,2810654,2822942,3867422,5944094,9052958].map(n)},{id:2,v:[4401,4636,8630,16688,532854,16892,278970,541146,1065368,549372,2109848,1077724,1098102,1356184,1880472,3420670,4465116,4989404,4231610,2683388,1651230,139704,3736062,647710,3498494,1184286,7389694,8172030,6894078,6648318,7434750,9253374,12104190,504350,10838526,16785918,12157438,8561150,17605118,16073214].map(n)}],o={min:0,L:0,M:1,Q:2,H:3,max:3},i=t=>"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:".indexOf(t),l=(...t)=>(e,r)=>t.forEach(t=>t(e,r)),u=t=>(e,r)=>{e.push(1,4),e.push(t.length,r<10?10:r<27?12:14);let n=0;for(;n<t.length-2;n+=3)e.push(Number(t.substr(n,3)),10);n<t.length-1?e.push(Number(t.substr(n,2)),7):n<t.length&&e.push(Number(t.substr(n,1)),4)},a=t=>(e,r)=>{e.push(2,4),e.push(t.length,r<10?9:r<27?11:13);let n=0;for(;n<t.length-1;n+=2)e.push(45*i(t[n])+i(t[n+1]),11);n<t.length&&e.push(i(t[n]),6)},f=t=>(e,r)=>{e.push(4,4),e.push(t.length,r<10?8:16),t.forEach(t=>e.push(t,8))},c=t=>e=>{e.push(7,4),e.push(t,8)},h=t=>f([...t].map(t=>t.codePointAt(0))),p=t=>l(c(26),f((new TextEncoder).encode(t))),d=t=>t.reduce((t,e)=>e.e<t.e?e:t);u.reg=/[0-9]/,u.est=(t,e)=>4+(e<10?10:e<27?12:14)+10*t.length/3,a.reg=/[0-9A-Z $%*+./:-]/,a.est=(t,e)=>4+(e<10?9:e<27?11:13)+5.5*t.length,h.reg=/[\u0000-\u00FF]/,h.est=(t,e)=>4+(e<10?8:16)+8*t.length;var g={auto:(t,{modes:e=[u,a,h,p]}={})=>{const r=new Set(e),n=r.delete(p);return n&&(e=[...r]),(r,s)=>{let o=[{c:0,e:0}];for(let i=0;i<t.length;++i)if(o=e.filter(e=>e.reg.test(t[i])).map(e=>d(o.map(r=>{const n={c:e,p:r.c===e?r.p:r,s:r.c===e?r.s:i};return n.v=t.substring(n.s,i+1),n.e=n.p.e+Math.ceil(e.est(n.v,s)),n}))),!o.length){if(n)return void p(t)(r,s);throw new Error("Unencodable")}const i=[];for(let t=d(o);t.c;t=t.p)i.unshift(t.c(t.v));i.forEach(t=>t(r,s))}},multi:l,eci:c,numeric:u,alphaNumeric:a,bytes:f,iso8859_1:h,utf8:p};class m{constructor(t){this.bytes=new Uint8Array(t),this.bits=0}push(t,e){for(let r=e,n=8-(7&this.bits);r>0;r-=n,n=8)this.bytes[this.bits>>>3]|=t<<n>>>r,this.bits+=Math.min(r,n)}}function b(t){Array.isArray(t)||(t=[255&t,t>>>8&255,t>>>16&255,t>>>24]);const e=new Uint8Array([...t,255]);return new Uint32Array(e.buffer,0,1)[0]}class v{constructor({size:t,d:e}){this.size=t,this.d=new Uint8Array(e||t*t)}get(t,e){return!!(1&this.d[e*this.size+t])}masked(t,e){return 2&this.d[e*this.size+t]}set(t,e,r,n=1){this.d[e*this.size+t]=2*n|!!r}inv(t,e){this.d[e*this.size+t]^=1}toString({on:t="##",off:e=" ",lf:r="\n",padX:n=4,padY:s=4}={}){const o=(e.repeat(this.size+2*n)+r).repeat(s),i=e.repeat(n);let l=o;for(let n=0;n<this.size;++n){l+=i;for(let r=0;r<this.size;++r)l+=this.get(r,n)?t:e;l+=i+r}return l+o}toImageData(t,{on:e=4278190080,off:r=0}={}){const n=t.createImageData(this.size,this.size),s=new Uint32Array(n.data.buffer),o=b(e),i=b(r);s.fill(i);for(let t=0;t<this.size*this.size;++t)s[t]=1&this.d[t]?o:i;return n}toCanvas(t,{padX:e=4,padY:r=4,...n}={}){t.width=this.size+2*e,t.height=this.size+2*r;const s=t.getContext("2d"),o=this.toImageData(s,n);s.putImageData(o,e,r)}}var y=[(t,e)=>!(1&(t^e)),(t,e)=>!(1&e),t=>!(t%3),(t,e)=>!((t+e)%3),(t,e)=>!(1&(Math.floor(t/3)^Math.floor(e/2))),(t,e)=>!((t&e&1)+t*e%3),(t,e)=>!((t&e&1)+t*e%3&1),(t,e)=>!((1&(t^e))+t*e%3&1)];const z=new Uint8Array(512);z[0]=1;for(let t=0,e=1;t<255;z[++t]=e)z[e+256]=t,e*=2,256&e&&(e^=285);const w=t=>z[t%255],x=t=>z[t+256],M=(t,e)=>{const r=new Uint8Array(t.length+e.length-1);for(let n=0;n<t.length;++n)for(let s=0;s<e.length;++s)r[n+s]^=w(t[n]+e[s]);return r.map(x)},A=(t,e)=>{const r=new Uint8Array(t.length+e.length-1);r.set(t,0);for(let n=0;n<t.length;++n)if(r[n]){const t=x(r[n]);for(let s=0;s<e.length;++s)r[n+s]^=w(e[s]+t)}return r.slice(t.length)},E=[[0],[0,0]];for(let t=1,e=E[1];t<30;++t){const r=M(e,[0,t]);E.push(r),e=r}const U=(t,e,r)=>{let n=e;const s=Math.max(...r.map(t=>t.length));for(let e=0;e<s;++e)r.forEach(r=>{e<r.length&&(t[n++]=r[e])});return n};var j=(t,{groups:e,ecsize:r})=>{const n=[],s=[];let o=0,i=0;e.forEach(([e,l])=>{for(let i=0;i<e;++i,o+=l){const e=t.slice(o,o+l);n.push(e),s.push(A(e,E[r]))}i+=e*(l+r)});const l=new Uint8Array(i),u=U(l,0,n);return U(l,u,s),l};const O=(t,e,r)=>{let n=t<<r-1;for(let t=134217728;t;t>>>=1)n&t&&(n^=e*(t>>>r-1));return n},S=(t,e,r,n,s,o)=>{for(let i=r;i<s;++i)for(let r=e;r<n;++r)t.set(r,i,o)},I=(t,e,r)=>{S(t,e-3,r-3,e+4,r+4,1),S(t,e-2,r-2,e+3,r+3,0),S(t,e-1,r-1,e+2,r+2,1)},P=(t,e,r)=>{S(t,e-2,r-2,e+3,r+3,1),S(t,e-1,r-1,e+2,r+2,0),t.set(e,r,1)},_=t=>{const e=t.size,r=[];for(let n=e-2,s=e,o=-1;n>=0;n-=2){for(5===n&&(n=4);s+=o,-1!==s&&s!==e;)t.masked(n+1,s)||r.push([n+1,s]),t.masked(n,s)||r.push([n,s]);o*=-1}return r},k=(t,e,r)=>{e.forEach(([e,n],s)=>t.set(e,n,r[s>>3]<<(7&s)&128,0))},B=(t,e,r,n)=>{const s=t.size;for(let r=0;r<s;++r)for(let n=0;n<s;++n)e(n,r)&&!t.masked(n,r)&&t.inv(n,r);const o=n<<3|r;let i=21522^(o<<10|O(o,1335,11));for(let e=8;e-- >0;i>>=1)t.set(8,(e>1?7:8)-e,1&i),t.set(s-8+e,8,1&i);for(let e=7;e-- >0;i>>=1)t.set(e>5?7:e,8,1&i),t.set(8,s-e-1,1&i)},C=(t,e,r)=>{for(let n=0;n<t.size;++n){let s=e,o=e;for(let e=0;e<t.size;++e)s=r(s,t.get(e,n)),o=r(o,t.get(n,e))}};var D=t=>(t=>{let e=0;return C(t,[0],([t,r],n)=>n!==r?[1,n]:(4===t?e+=3:t>4&&++e,[t+1,r])),e})(t)+3*(t=>{let e=0;for(let r=1;r<t.size;++r){let n=t.get(r-1,0),s=t.get(r,0)===n;for(let o=1;o<t.size;++o){const i=t.get(r-1,o),l=t.get(r,o)===i;e+=s&&l&&n===i,n=i,s=l}}return e})(t)+40*(t=>{let e=0;return C(t,0,(t,r)=>{const n=(t>>>1|2098176)&(3047517^(r?0:-1));return 2049&n&&++e,n}),e})(t)+(t=>{let e=0;for(let r=0;r<t.size;++r)for(let n=0;n<t.size;++n)e+=t.get(n,r);return 10*Math.floor(20*Math.abs(e/(t.size*t.size)-.5))})(t);const N=[],T=t=>{let e=N[t];if(!e){const r=new v({size:4*t+17});((t,e)=>{const r=4*e+17;I(t,3,3),I(t,r-4,3),I(t,3,r-4),S(t,0,7,9,9,0),S(t,7,0,9,7,0),S(t,r-8,7,r,9,0),S(t,r-8,0,r-7,7,0),S(t,7,r-8,9,r,0),S(t,0,r-8,7,r-7,0),t.set(8,r-8,1);for(let e=8;e<r-8;++e)t.set(e,6,!(1&e)),t.set(6,e,!(1&e));if(e>=2){const n=Math.floor(e/7)+1,s=2*Math.ceil((r-13)/n/2-.25),o=[6];for(let t=n;t-- >0;)o.push(r-7-t*s);for(let e=0;e<=n;++e)for(let r=0;r<=n;++r)!e&&!r||!e&&r===n||e===n&&!r||P(t,o[e],o[r])}if(e>=7)for(let n=e<<12|O(e,7973,13),s=0;s<6;++s)for(let e=12;e-- >9;n>>>=1)t.set(s,r-e,1&n),t.set(r-e,s,1&n)})(r,t),N[t]=e=[r,_(r)]}return[new v(e[0]),e[1]]};var L=(t,{minCorrectionLevel:e=o.min,maxCorrectionLevel:r=o.max,minVersion:n=1,maxVersion:i=40,mask:l=null}={})=>{if(r<e)throw new Error("Invalid correction level range");if(i<n)throw new Error("Invalid version range");"string"==typeof t&&(t=g.auto(t));let u=0;for(let o=n;o<=i;++o){if(s[e].v[o-1].capBits<u)continue;const n=new m(2956);t(n,o),u=n.bits;for(let t=r;t>=e;--t){const e=s[t],r=e.v[o-1];if(r.capBits<u)continue;for(n.push(0,4),n.bits=n.bits+7&-8;n.bits<r.capBits;)n.push(60433,16);const[i,a]=T(o);return k(i,a,j(n.bytes,r)),null!==l?(B(i,y[l],l,e.id),i):y.map((t,r)=>{const n=new v(i);return B(n,t,r,e.id),n.s=D(n),n}).reduce((t,e)=>e.s<t.s?e:t)}}throw new Error("Too much data")}}])}));
//# sourceMappingURL=index.js.map

@@ -62,5 +62,8 @@ declare module 'lean-qr' {

multi(...modes: Mode[]): Mode,
eci(id: number): Mode,
numeric: ModeFactory,
alphaNumeric: ModeFactory,
bytes(data: Uint8Array | number[]): Mode,
iso8859_1: ModeFactory,
utf8: ModeFactory,
};

@@ -67,0 +70,0 @@

{
"name": "lean-qr",
"version": "1.1.0",
"version": "1.2.0",
"description": "minimal QR code generation",

@@ -5,0 +5,0 @@ "files": [

@@ -66,2 +66,3 @@ # Lean QR

| `mode.iso8859_1` | 8 / 1 | ISO-8859-1 |
| `mode.utf8` | varies | Unicode |

@@ -85,2 +86,23 @@ Note that if you specify a mode explicitly, it is your responsibility to

Note that you should not mix `utf8`, `iso8859_1`, or `eci`, as they all
involve changing the global interpretation of the message and will
conflict with each other.
### `eci` / `bytes`
`mode.eci` lets you switch the Extended Channel Interpretation of the
message. After setting this, subsequent `mode.bytes` will be interpreted
in the specified character set.
[Wikipedia includes a list of possible values](https://en.wikipedia.org/wiki/Extended_Channel_Interpretation).
Note that `iso8859_1` and `utf8` both use `bytes` for their data, so
you cannot combine a custom `eci` with `iso8859_1` or `utf8`.
```javascript
const code = generate(mode.multi(
mode.eci(24), // Arabic (Windows-1256)
mode.bytes([0xD3]), // Shin character
));
```
### `auto`

@@ -279,4 +301,4 @@

code.toCanvas(myTargetCanvas, {
on: 0xFF000000,
off: 0x00000000,
on: [0x00, 0x00, 0x00, 0xFF],
off: [0x00, 0x00, 0x00, 0x00],
padX: 4,

@@ -300,3 +322,4 @@ padY: 4,

The values of `on` and `off` should be in `0xAABBGGRR` format.
The values of `on` and `off` should be arrays in `[red, green, blue, alpha]`
format. If `alpha` is omitted, 255 is assumed.

@@ -312,4 +335,4 @@ ### `toImageData(context[, options])`

const imageData = code.toImageData(myContext, {
on: 0xFF000000,
off: 0x00000000,
on: [0x00, 0x00, 0x00, 0xFF],
off: [0x00, 0x00, 0x00, 0x00],
});

@@ -316,0 +339,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc