├── .gitignore
├── README.md
├── assets
└── preview.png
├── babelrc.config.js
├── config
├── default.json
└── production.json
├── dist
├── index.html
├── index.js
└── index.js.map
├── index.html
├── package-lock.json
├── package.json
├── postcss.config.js
├── src
├── constants
│ ├── character-map.js
│ └── event-emitter.js
├── index.js
├── lib
│ ├── block.js
│ ├── canvas.js
│ └── pixel.js
├── scss
│ └── styles.scss
└── util
│ └── common.js
└── webpack.config.js
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | build
3 | .DS_Store
4 | .vscode
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # dot-matrix-lcd
2 | A JavaScript plugin to emulate Dot Matrix LCD display.
3 |
4 |
5 |
6 | # Install
7 | ```bash
8 | npm i -S dot-matrix-lcd
9 | ```
10 |
11 | # Import in HTML
12 | ```html
13 |
14 |
15 |
16 |
17 |
18 | ```
19 |
20 | > This script exposes `LCD` class on `window` object.
21 |
22 | # Import in Node.js
23 | ```js
24 | const LCD = require('dot-matrix-lcd');
25 | ```
26 |
27 | ## Plugin API
28 | ```js
29 | var lcd = new LCD({
30 | elem: document.getElementById("lcd-container"),
31 | rows: 2, // number of character rows on the LCD screen
32 | columns: 16, // number of character columns on the LCD screen
33 | pixelSize: 4, // size of each pixel
34 | pixelColor: "#000", // color of the pixel
35 | });
36 |
37 | // Write a character on LCD screen.
38 | // charCode => decimal number or hexadecimal string ASCII code point
39 | // blockIndex => index of the character block (default: 0)
40 | lcd.writeCharacter( { charCode, blockIndex } );
41 |
42 | // Write string (text) on LCD screen.
43 | // string => text (default: "")
44 | // offset => offset index from the start of the screen.
45 | lcd.writeString({ string, offset });
46 |
47 | // Clear a character at a given index on the LCD screen.
48 | // blockIndex => Index of the character block (default: 0)
49 | lcd.clearCharacter({ blockIndex });
50 |
51 | // Toggle cursor blink at the given character block.
52 | // blockIndex => index of the character block (default: 0)
53 | // stop => stop cursor blink (default: false)
54 | lcd.blinkCursor({ blockIndex, stop });
55 |
56 | // Clear entire LCD screen.
57 | lcd.clearScreen();
58 | ```
59 |
--------------------------------------------------------------------------------
/assets/preview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thatisuday/dot-matrix-lcd/769df1aeda99dafdc92ee0dec73cb5c88380d406/assets/preview.png
--------------------------------------------------------------------------------
/babelrc.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: [
3 | "@babel/preset-env"
4 | ],
5 | plugins: [
6 | '@babel/plugin-transform-runtime',
7 | '@babel/plugin-proposal-class-properties',
8 | [ '@babel/plugin-proposal-decorators', { 'legacy': true } ],
9 | '@babel/plugin-transform-async-to-generator',
10 | '@babel/plugin-transform-arrow-functions',
11 | '@babel/plugin-proposal-object-rest-spread',
12 | '@babel/plugin-proposal-export-default-from'
13 | ]
14 | }
--------------------------------------------------------------------------------
/config/default.json:
--------------------------------------------------------------------------------
1 | {
2 | "uglify": false,
3 | "sourcemap": false,
4 | "open": true,
5 | "publicPath": "/"
6 | }
--------------------------------------------------------------------------------
/config/production.json:
--------------------------------------------------------------------------------
1 | {
2 | "uglify": true,
3 | "sourcemap": true,
4 | "open": false,
5 | "publicPath": "./"
6 | }
--------------------------------------------------------------------------------
/dist/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | User Application
7 |
8 |
26 |
27 |
28 |
29 |
Hello World!
30 |
31 |
32 |
33 |
66 |
67 |
--------------------------------------------------------------------------------
/dist/index.js:
--------------------------------------------------------------------------------
1 | !function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.LCD=n():t.LCD=n()}(window,(function(){return function(t){var n={};function r(e){if(n[e])return n[e].exports;var u=n[e]={i:e,l:!1,exports:{}};return t[e].call(u.exports,u,u.exports,r),u.l=!0,u.exports}return r.m=t,r.c=n,r.d=function(t,n,e){r.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:e})},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,n){if(1&n&&(t=r(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var e=Object.create(null);if(r.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var u in t)r.d(e,u,function(n){return t[n]}.bind(null,u));return e},r.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(n,"a",n),n},r.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},r.p="./",r(r.s=7)}([function(t,n,r){(function(t,e){var u;
2 | /**
3 | * @license
4 | * Lodash
5 | * Copyright OpenJS Foundation and other contributors
6 | * Released under MIT license
7 | * Based on Underscore.js 1.8.3
8 | * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
9 | */(function(){var i,o=200,a="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",c="Expected a function",f="__lodash_hash_undefined__",s=500,l="__lodash_placeholder__",h=1,p=2,v=4,_=1,g=2,d=1,y=2,w=4,b=8,m=16,x=32,j=64,k=128,S=256,A=512,z=30,C="...",I=800,O=16,E=1,R=2,L=1/0,B=9007199254740991,T=17976931348623157e292,W=NaN,M=4294967295,P=M-1,U=M>>>1,D=[["ary",k],["bind",d],["bindKey",y],["curry",b],["curryRight",m],["flip",A],["partial",x],["partialRight",j],["rearg",S]],N="[object Arguments]",$="[object Array]",F="[object AsyncFunction]",q="[object Boolean]",G="[object Date]",V="[object DOMException]",Z="[object Error]",K="[object Function]",H="[object GeneratorFunction]",J="[object Map]",Y="[object Number]",Q="[object Null]",X="[object Object]",tt="[object Proxy]",nt="[object RegExp]",rt="[object Set]",et="[object String]",ut="[object Symbol]",it="[object Undefined]",ot="[object WeakMap]",at="[object WeakSet]",ct="[object ArrayBuffer]",ft="[object DataView]",st="[object Float32Array]",lt="[object Float64Array]",ht="[object Int8Array]",pt="[object Int16Array]",vt="[object Int32Array]",_t="[object Uint8Array]",gt="[object Uint8ClampedArray]",dt="[object Uint16Array]",yt="[object Uint32Array]",wt=/\b__p \+= '';/g,bt=/\b(__p \+=) '' \+/g,mt=/(__e\(.*?\)|\b__t\)) \+\n'';/g,xt=/&(?:amp|lt|gt|quot|#39);/g,jt=/[&<>"']/g,kt=RegExp(xt.source),St=RegExp(jt.source),At=/<%-([\s\S]+?)%>/g,zt=/<%([\s\S]+?)%>/g,Ct=/<%=([\s\S]+?)%>/g,It=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ot=/^\w*$/,Et=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Rt=/[\\^$.*+?()[\]{}|]/g,Lt=RegExp(Rt.source),Bt=/^\s+|\s+$/g,Tt=/^\s+/,Wt=/\s+$/,Mt=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Pt=/\{\n\/\* \[wrapped with (.+)\] \*/,Ut=/,? & /,Dt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Nt=/\\(\\)?/g,$t=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Ft=/\w*$/,qt=/^[-+]0x[0-9a-f]+$/i,Gt=/^0b[01]+$/i,Vt=/^\[object .+?Constructor\]$/,Zt=/^0o[0-7]+$/i,Kt=/^(?:0|[1-9]\d*)$/,Ht=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Jt=/($^)/,Yt=/['\n\r\u2028\u2029\\]/g,Qt="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",Xt="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",tn="[\\ud800-\\udfff]",nn="["+Xt+"]",rn="["+Qt+"]",en="\\d+",un="[\\u2700-\\u27bf]",on="[a-z\\xdf-\\xf6\\xf8-\\xff]",an="[^\\ud800-\\udfff"+Xt+en+"\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde]",cn="\\ud83c[\\udffb-\\udfff]",fn="[^\\ud800-\\udfff]",sn="(?:\\ud83c[\\udde6-\\uddff]){2}",ln="[\\ud800-\\udbff][\\udc00-\\udfff]",hn="[A-Z\\xc0-\\xd6\\xd8-\\xde]",pn="(?:"+on+"|"+an+")",vn="(?:"+hn+"|"+an+")",_n="(?:"+rn+"|"+cn+")"+"?",gn="[\\ufe0e\\ufe0f]?"+_n+("(?:\\u200d(?:"+[fn,sn,ln].join("|")+")[\\ufe0e\\ufe0f]?"+_n+")*"),dn="(?:"+[un,sn,ln].join("|")+")"+gn,yn="(?:"+[fn+rn+"?",rn,sn,ln,tn].join("|")+")",wn=RegExp("['’]","g"),bn=RegExp(rn,"g"),mn=RegExp(cn+"(?="+cn+")|"+yn+gn,"g"),xn=RegExp([hn+"?"+on+"+(?:['’](?:d|ll|m|re|s|t|ve))?(?="+[nn,hn,"$"].join("|")+")",vn+"+(?:['’](?:D|LL|M|RE|S|T|VE))?(?="+[nn,hn+pn,"$"].join("|")+")",hn+"?"+pn+"+(?:['’](?:d|ll|m|re|s|t|ve))?",hn+"+(?:['’](?:D|LL|M|RE|S|T|VE))?","\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",en,dn].join("|"),"g"),jn=RegExp("[\\u200d\\ud800-\\udfff"+Qt+"\\ufe0e\\ufe0f]"),kn=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Sn=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],An=-1,zn={};zn[st]=zn[lt]=zn[ht]=zn[pt]=zn[vt]=zn[_t]=zn[gt]=zn[dt]=zn[yt]=!0,zn[N]=zn[$]=zn[ct]=zn[q]=zn[ft]=zn[G]=zn[Z]=zn[K]=zn[J]=zn[Y]=zn[X]=zn[nt]=zn[rt]=zn[et]=zn[ot]=!1;var Cn={};Cn[N]=Cn[$]=Cn[ct]=Cn[ft]=Cn[q]=Cn[G]=Cn[st]=Cn[lt]=Cn[ht]=Cn[pt]=Cn[vt]=Cn[J]=Cn[Y]=Cn[X]=Cn[nt]=Cn[rt]=Cn[et]=Cn[ut]=Cn[_t]=Cn[gt]=Cn[dt]=Cn[yt]=!0,Cn[Z]=Cn[K]=Cn[ot]=!1;var In={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},On=parseFloat,En=parseInt,Rn="object"==typeof t&&t&&t.Object===Object&&t,Ln="object"==typeof self&&self&&self.Object===Object&&self,Bn=Rn||Ln||Function("return this")(),Tn=n&&!n.nodeType&&n,Wn=Tn&&"object"==typeof e&&e&&!e.nodeType&&e,Mn=Wn&&Wn.exports===Tn,Pn=Mn&&Rn.process,Un=function(){try{var t=Wn&&Wn.require&&Wn.require("util").types;return t||Pn&&Pn.binding&&Pn.binding("util")}catch(t){}}(),Dn=Un&&Un.isArrayBuffer,Nn=Un&&Un.isDate,$n=Un&&Un.isMap,Fn=Un&&Un.isRegExp,qn=Un&&Un.isSet,Gn=Un&&Un.isTypedArray;function Vn(t,n,r){switch(r.length){case 0:return t.call(n);case 1:return t.call(n,r[0]);case 2:return t.call(n,r[0],r[1]);case 3:return t.call(n,r[0],r[1],r[2])}return t.apply(n,r)}function Zn(t,n,r,e){for(var u=-1,i=null==t?0:t.length;++u-1}function Xn(t,n,r){for(var e=-1,u=null==t?0:t.length;++e-1;);return r}function mr(t,n){for(var r=t.length;r--&&cr(n,t[r],0)>-1;);return r}var xr=pr({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),jr=pr({"&":"&","<":"<",">":">",'"':""","'":"'"});function kr(t){return"\\"+In[t]}function Sr(t){return jn.test(t)}function Ar(t){var n=-1,r=Array(t.size);return t.forEach((function(t,e){r[++n]=[e,t]})),r}function zr(t,n){return function(r){return t(n(r))}}function Cr(t,n){for(var r=-1,e=t.length,u=0,i=[];++r",""":'"',"'":"'"});var Br=function t(n){var r,e=(n=null==n?Bn:Br.defaults(Bn.Object(),n,Br.pick(Bn,Sn))).Array,u=n.Date,Qt=n.Error,Xt=n.Function,tn=n.Math,nn=n.Object,rn=n.RegExp,en=n.String,un=n.TypeError,on=e.prototype,an=Xt.prototype,cn=nn.prototype,fn=n["__core-js_shared__"],sn=an.toString,ln=cn.hasOwnProperty,hn=0,pn=(r=/[^.]+$/.exec(fn&&fn.keys&&fn.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"",vn=cn.toString,_n=sn.call(nn),gn=Bn._,dn=rn("^"+sn.call(ln).replace(Rt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),yn=Mn?n.Buffer:i,mn=n.Symbol,jn=n.Uint8Array,In=yn?yn.allocUnsafe:i,Rn=zr(nn.getPrototypeOf,nn),Ln=nn.create,Tn=cn.propertyIsEnumerable,Wn=on.splice,Pn=mn?mn.isConcatSpreadable:i,Un=mn?mn.iterator:i,ir=mn?mn.toStringTag:i,pr=function(){try{var t=Pi(nn,"defineProperty");return t({},"",{}),t}catch(t){}}(),Tr=n.clearTimeout!==Bn.clearTimeout&&n.clearTimeout,Wr=u&&u.now!==Bn.Date.now&&u.now,Mr=n.setTimeout!==Bn.setTimeout&&n.setTimeout,Pr=tn.ceil,Ur=tn.floor,Dr=nn.getOwnPropertySymbols,Nr=yn?yn.isBuffer:i,$r=n.isFinite,Fr=on.join,qr=zr(nn.keys,nn),Gr=tn.max,Vr=tn.min,Zr=u.now,Kr=n.parseInt,Hr=tn.random,Jr=on.reverse,Yr=Pi(n,"DataView"),Qr=Pi(n,"Map"),Xr=Pi(n,"Promise"),te=Pi(n,"Set"),ne=Pi(n,"WeakMap"),re=Pi(nn,"create"),ee=ne&&new ne,ue={},ie=so(Yr),oe=so(Qr),ae=so(Xr),ce=so(te),fe=so(ne),se=mn?mn.prototype:i,le=se?se.valueOf:i,he=se?se.toString:i;function pe(t){if(Ca(t)&&!da(t)&&!(t instanceof de)){if(t instanceof ge)return t;if(ln.call(t,"__wrapped__"))return lo(t)}return new ge(t)}var ve=function(){function t(){}return function(n){if(!za(n))return{};if(Ln)return Ln(n);t.prototype=n;var r=new t;return t.prototype=i,r}}();function _e(){}function ge(t,n){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!n,this.__index__=0,this.__values__=i}function de(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=M,this.__views__=[]}function ye(t){var n=-1,r=null==t?0:t.length;for(this.clear();++n=n?t:n)),t}function Te(t,n,r,e,u,o){var a,c=n&h,f=n&p,s=n&v;if(r&&(a=u?r(t,e,u,o):r(t)),a!==i)return a;if(!za(t))return t;var l=da(t);if(l){if(a=function(t){var n=t.length,r=new t.constructor(n);n&&"string"==typeof t[0]&&ln.call(t,"index")&&(r.index=t.index,r.input=t.input);return r}(t),!c)return ri(t,a)}else{var _=Ni(t),g=_==K||_==H;if(ma(t))return Ju(t,c);if(_==X||_==N||g&&!u){if(a=f||g?{}:Fi(t),!c)return f?function(t,n){return ei(t,Di(t),n)}(t,function(t,n){return t&&ei(n,ic(n),t)}(a,t)):function(t,n){return ei(t,Ui(t),n)}(t,Ee(a,t))}else{if(!Cn[_])return u?t:{};a=function(t,n,r){var e=t.constructor;switch(n){case ct:return Yu(t);case q:case G:return new e(+t);case ft:return function(t,n){var r=n?Yu(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,r);case st:case lt:case ht:case pt:case vt:case _t:case gt:case dt:case yt:return Qu(t,r);case J:return new e;case Y:case et:return new e(t);case nt:return function(t){var n=new t.constructor(t.source,Ft.exec(t));return n.lastIndex=t.lastIndex,n}(t);case rt:return new e;case ut:return u=t,le?nn(le.call(u)):{}}var u}(t,_,c)}}o||(o=new xe);var d=o.get(t);if(d)return d;o.set(t,a),La(t)?t.forEach((function(e){a.add(Te(e,n,r,e,t,o))})):Ia(t)&&t.forEach((function(e,u){a.set(u,Te(e,n,r,u,t,o))}));var y=l?i:(s?f?Ei:Oi:f?ic:uc)(t);return Kn(y||t,(function(e,u){y&&(e=t[u=e]),Ce(a,u,Te(e,n,r,u,t,o))})),a}function We(t,n,r){var e=r.length;if(null==t)return!e;for(t=nn(t);e--;){var u=r[e],o=n[u],a=t[u];if(a===i&&!(u in t)||!o(a))return!1}return!0}function Me(t,n,r){if("function"!=typeof t)throw new un(c);return eo((function(){t.apply(i,r)}),n)}function Pe(t,n,r,e){var u=-1,i=Qn,a=!0,c=t.length,f=[],s=n.length;if(!c)return f;r&&(n=tr(n,dr(r))),e?(i=Xn,a=!1):n.length>=o&&(i=wr,a=!1,n=new me(n));t:for(;++u-1},we.prototype.set=function(t,n){var r=this.__data__,e=Ie(r,t);return e<0?(++this.size,r.push([t,n])):r[e][1]=n,this},be.prototype.clear=function(){this.size=0,this.__data__={hash:new ye,map:new(Qr||we),string:new ye}},be.prototype.delete=function(t){var n=Wi(this,t).delete(t);return this.size-=n?1:0,n},be.prototype.get=function(t){return Wi(this,t).get(t)},be.prototype.has=function(t){return Wi(this,t).has(t)},be.prototype.set=function(t,n){var r=Wi(this,t),e=r.size;return r.set(t,n),this.size+=r.size==e?0:1,this},me.prototype.add=me.prototype.push=function(t){return this.__data__.set(t,f),this},me.prototype.has=function(t){return this.__data__.has(t)},xe.prototype.clear=function(){this.__data__=new we,this.size=0},xe.prototype.delete=function(t){var n=this.__data__,r=n.delete(t);return this.size=n.size,r},xe.prototype.get=function(t){return this.__data__.get(t)},xe.prototype.has=function(t){return this.__data__.has(t)},xe.prototype.set=function(t,n){var r=this.__data__;if(r instanceof we){var e=r.__data__;if(!Qr||e.length0&&r(a)?n>1?qe(a,n-1,r,e,u):nr(u,a):e||(u[u.length]=a)}return u}var Ge=ai(),Ve=ai(!0);function Ze(t,n){return t&&Ge(t,n,uc)}function Ke(t,n){return t&&Ve(t,n,uc)}function He(t,n){return Yn(n,(function(n){return ka(t[n])}))}function Je(t,n){for(var r=0,e=(n=Vu(n,t)).length;null!=t&&rn}function tu(t,n){return null!=t&&ln.call(t,n)}function nu(t,n){return null!=t&&n in nn(t)}function ru(t,n,r){for(var u=r?Xn:Qn,o=t[0].length,a=t.length,c=a,f=e(a),s=1/0,l=[];c--;){var h=t[c];c&&n&&(h=tr(h,dr(n))),s=Vr(h.length,s),f[c]=!r&&(n||o>=120&&h.length>=120)?new me(c&&h):i}h=t[0];var p=-1,v=f[0];t:for(;++p=a)return c;var f=r[e];return c*("desc"==f?-1:1)}}return t.index-n.index}(t,n,r)}))}function yu(t,n,r){for(var e=-1,u=n.length,i={};++e-1;)a!==t&&Wn.call(a,c,1),Wn.call(t,c,1);return t}function bu(t,n){for(var r=t?n.length:0,e=r-1;r--;){var u=n[r];if(r==e||u!==i){var i=u;Gi(u)?Wn.call(t,u,1):Pu(t,u)}}return t}function mu(t,n){return t+Ur(Hr()*(n-t+1))}function xu(t,n){var r="";if(!t||n<1||n>B)return r;do{n%2&&(r+=t),(n=Ur(n/2))&&(t+=t)}while(n);return r}function ju(t,n){return uo(Xi(t,n,Oc),t+"")}function ku(t){return ke(pc(t))}function Su(t,n){var r=pc(t);return ao(r,Be(n,0,r.length))}function Au(t,n,r,e){if(!za(t))return t;for(var u=-1,o=(n=Vu(n,t)).length,a=o-1,c=t;null!=c&&++ui?0:i+n),(r=r>i?i:r)<0&&(r+=i),i=n>r?0:r-n>>>0,n>>>=0;for(var o=e(i);++u>>1,o=t[i];null!==o&&!Ta(o)&&(r?o<=n:o=o){var s=n?null:xi(t);if(s)return Ir(s);a=!1,u=wr,f=new me}else f=n?[]:c;t:for(;++e=e?t:Ou(t,n,r)}var Hu=Tr||function(t){return Bn.clearTimeout(t)};function Ju(t,n){if(n)return t.slice();var r=t.length,e=In?In(r):new t.constructor(r);return t.copy(e),e}function Yu(t){var n=new t.constructor(t.byteLength);return new jn(n).set(new jn(t)),n}function Qu(t,n){var r=n?Yu(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}function Xu(t,n){if(t!==n){var r=t!==i,e=null===t,u=t==t,o=Ta(t),a=n!==i,c=null===n,f=n==n,s=Ta(n);if(!c&&!s&&!o&&t>n||o&&a&&f&&!c&&!s||e&&a&&f||!r&&f||!u)return 1;if(!e&&!o&&!s&&t1?r[u-1]:i,a=u>2?r[2]:i;for(o=t.length>3&&"function"==typeof o?(u--,o):i,a&&Vi(r[0],r[1],a)&&(o=u<3?i:o,u=1),n=nn(n);++e-1?u[o?n[a]:a]:i}}function hi(t){return Ii((function(n){var r=n.length,e=r,u=ge.prototype.thru;for(t&&n.reverse();e--;){var o=n[e];if("function"!=typeof o)throw new un(c);if(u&&!a&&"wrapper"==Li(o))var a=new ge([],!0)}for(e=a?e:r;++e1&&b.reverse(),h&&sc))return!1;var s=o.get(t);if(s&&o.get(n))return s==n;var l=-1,h=!0,p=r&g?new me:i;for(o.set(t,n),o.set(n,t);++l-1&&t%1==0&&t1?"& ":"")+n[e],n=n.join(r>2?", ":" "),t.replace(Mt,"{\n/* [wrapped with "+n+"] */\n")}(e,function(t,n){return Kn(D,(function(r){var e="_."+r[0];n&r[1]&&!Qn(t,e)&&t.push(e)})),t.sort()}(function(t){var n=t.match(Pt);return n?n[1].split(Ut):[]}(e),r)))}function oo(t){var n=0,r=0;return function(){var e=Zr(),u=O-(e-r);if(r=e,u>0){if(++n>=I)return arguments[0]}else n=0;return t.apply(i,arguments)}}function ao(t,n){var r=-1,e=t.length,u=e-1;for(n=n===i?e:n;++r1?t[n-1]:i;return r="function"==typeof r?(t.pop(),r):i,Ro(t,r)}));function Uo(t){var n=pe(t);return n.__chain__=!0,n}function Do(t,n){return n(t)}var No=Ii((function(t){var n=t.length,r=n?t[0]:0,e=this.__wrapped__,u=function(n){return Le(n,t)};return!(n>1||this.__actions__.length)&&e instanceof de&&Gi(r)?((e=e.slice(r,+r+(n?1:0))).__actions__.push({func:Do,args:[u],thisArg:i}),new ge(e,this.__chain__).thru((function(t){return n&&!t.length&&t.push(i),t}))):this.thru(u)}));var $o=ui((function(t,n,r){ln.call(t,r)?++t[r]:Re(t,r,1)}));var Fo=li(_o),qo=li(go);function Go(t,n){return(da(t)?Kn:Ue)(t,Ti(n,3))}function Vo(t,n){return(da(t)?Hn:De)(t,Ti(n,3))}var Zo=ui((function(t,n,r){ln.call(t,r)?t[r].push(n):Re(t,r,[n])}));var Ko=ju((function(t,n,r){var u=-1,i="function"==typeof n,o=wa(t)?e(t.length):[];return Ue(t,(function(t){o[++u]=i?Vn(n,t,r):eu(t,n,r)})),o})),Ho=ui((function(t,n,r){Re(t,r,n)}));function Jo(t,n){return(da(t)?tr:hu)(t,Ti(n,3))}var Yo=ui((function(t,n,r){t[r?0:1].push(n)}),(function(){return[[],[]]}));var Qo=ju((function(t,n){if(null==t)return[];var r=n.length;return r>1&&Vi(t,n[0],n[1])?n=[]:r>2&&Vi(n[0],n[1],n[2])&&(n=[n[0]]),du(t,qe(n,1),[])})),Xo=Wr||function(){return Bn.Date.now()};function ta(t,n,r){return n=r?i:n,n=t&&null==n?t.length:n,ki(t,k,i,i,i,i,n)}function na(t,n){var r;if("function"!=typeof n)throw new un(c);return t=Na(t),function(){return--t>0&&(r=n.apply(this,arguments)),t<=1&&(n=i),r}}var ra=ju((function(t,n,r){var e=d;if(r.length){var u=Cr(r,Bi(ra));e|=x}return ki(t,e,n,r,u)})),ea=ju((function(t,n,r){var e=d|y;if(r.length){var u=Cr(r,Bi(ea));e|=x}return ki(n,e,t,r,u)}));function ua(t,n,r){var e,u,o,a,f,s,l=0,h=!1,p=!1,v=!0;if("function"!=typeof t)throw new un(c);function _(n){var r=e,o=u;return e=u=i,l=n,a=t.apply(o,r)}function g(t){var r=t-s;return s===i||r>=n||r<0||p&&t-l>=o}function d(){var t=Xo();if(g(t))return y(t);f=eo(d,function(t){var r=n-(t-s);return p?Vr(r,o-(t-l)):r}(t))}function y(t){return f=i,v&&e?_(t):(e=u=i,a)}function w(){var t=Xo(),r=g(t);if(e=arguments,u=this,s=t,r){if(f===i)return function(t){return l=t,f=eo(d,n),h?_(t):a}(s);if(p)return Hu(f),f=eo(d,n),_(s)}return f===i&&(f=eo(d,n)),a}return n=Fa(n)||0,za(r)&&(h=!!r.leading,o=(p="maxWait"in r)?Gr(Fa(r.maxWait)||0,n):o,v="trailing"in r?!!r.trailing:v),w.cancel=function(){f!==i&&Hu(f),l=0,e=s=u=f=i},w.flush=function(){return f===i?a:y(Xo())},w}var ia=ju((function(t,n){return Me(t,1,n)})),oa=ju((function(t,n,r){return Me(t,Fa(n)||0,r)}));function aa(t,n){if("function"!=typeof t||null!=n&&"function"!=typeof n)throw new un(c);var r=function(){var e=arguments,u=n?n.apply(this,e):e[0],i=r.cache;if(i.has(u))return i.get(u);var o=t.apply(this,e);return r.cache=i.set(u,o)||i,o};return r.cache=new(aa.Cache||be),r}function ca(t){if("function"!=typeof t)throw new un(c);return function(){var n=arguments;switch(n.length){case 0:return!t.call(this);case 1:return!t.call(this,n[0]);case 2:return!t.call(this,n[0],n[1]);case 3:return!t.call(this,n[0],n[1],n[2])}return!t.apply(this,n)}}aa.Cache=be;var fa=Zu((function(t,n){var r=(n=1==n.length&&da(n[0])?tr(n[0],dr(Ti())):tr(qe(n,1),dr(Ti()))).length;return ju((function(e){for(var u=-1,i=Vr(e.length,r);++u=n})),ga=uu(function(){return arguments}())?uu:function(t){return Ca(t)&&ln.call(t,"callee")&&!Tn.call(t,"callee")},da=e.isArray,ya=Dn?dr(Dn):function(t){return Ca(t)&&Qe(t)==ct};function wa(t){return null!=t&&Aa(t.length)&&!ka(t)}function ba(t){return Ca(t)&&wa(t)}var ma=Nr||Fc,xa=Nn?dr(Nn):function(t){return Ca(t)&&Qe(t)==G};function ja(t){if(!Ca(t))return!1;var n=Qe(t);return n==Z||n==V||"string"==typeof t.message&&"string"==typeof t.name&&!Ea(t)}function ka(t){if(!za(t))return!1;var n=Qe(t);return n==K||n==H||n==F||n==tt}function Sa(t){return"number"==typeof t&&t==Na(t)}function Aa(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=B}function za(t){var n=typeof t;return null!=t&&("object"==n||"function"==n)}function Ca(t){return null!=t&&"object"==typeof t}var Ia=$n?dr($n):function(t){return Ca(t)&&Ni(t)==J};function Oa(t){return"number"==typeof t||Ca(t)&&Qe(t)==Y}function Ea(t){if(!Ca(t)||Qe(t)!=X)return!1;var n=Rn(t);if(null===n)return!0;var r=ln.call(n,"constructor")&&n.constructor;return"function"==typeof r&&r instanceof r&&sn.call(r)==_n}var Ra=Fn?dr(Fn):function(t){return Ca(t)&&Qe(t)==nt};var La=qn?dr(qn):function(t){return Ca(t)&&Ni(t)==rt};function Ba(t){return"string"==typeof t||!da(t)&&Ca(t)&&Qe(t)==et}function Ta(t){return"symbol"==typeof t||Ca(t)&&Qe(t)==ut}var Wa=Gn?dr(Gn):function(t){return Ca(t)&&Aa(t.length)&&!!zn[Qe(t)]};var Ma=wi(lu),Pa=wi((function(t,n){return t<=n}));function Ua(t){if(!t)return[];if(wa(t))return Ba(t)?Rr(t):ri(t);if(Un&&t[Un])return function(t){for(var n,r=[];!(n=t.next()).done;)r.push(n.value);return r}(t[Un]());var n=Ni(t);return(n==J?Ar:n==rt?Ir:pc)(t)}function Da(t){return t?(t=Fa(t))===L||t===-L?(t<0?-1:1)*T:t==t?t:0:0===t?t:0}function Na(t){var n=Da(t),r=n%1;return n==n?r?n-r:n:0}function $a(t){return t?Be(Na(t),0,M):0}function Fa(t){if("number"==typeof t)return t;if(Ta(t))return W;if(za(t)){var n="function"==typeof t.valueOf?t.valueOf():t;t=za(n)?n+"":n}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(Bt,"");var r=Gt.test(t);return r||Zt.test(t)?En(t.slice(2),r?2:8):qt.test(t)?W:+t}function qa(t){return ei(t,ic(t))}function Ga(t){return null==t?"":Wu(t)}var Va=ii((function(t,n){if(Ji(n)||wa(n))ei(n,uc(n),t);else for(var r in n)ln.call(n,r)&&Ce(t,r,n[r])})),Za=ii((function(t,n){ei(n,ic(n),t)})),Ka=ii((function(t,n,r,e){ei(n,ic(n),t,e)})),Ha=ii((function(t,n,r,e){ei(n,uc(n),t,e)})),Ja=Ii(Le);var Ya=ju((function(t,n){t=nn(t);var r=-1,e=n.length,u=e>2?n[2]:i;for(u&&Vi(n[0],n[1],u)&&(e=1);++r1),n})),ei(t,Ei(t),r),e&&(r=Te(r,h|p|v,zi));for(var u=n.length;u--;)Pu(r,n[u]);return r}));var fc=Ii((function(t,n){return null==t?{}:function(t,n){return yu(t,n,(function(n,r){return tc(t,r)}))}(t,n)}));function sc(t,n){if(null==t)return{};var r=tr(Ei(t),(function(t){return[t]}));return n=Ti(n),yu(t,r,(function(t,r){return n(t,r[0])}))}var lc=ji(uc),hc=ji(ic);function pc(t){return null==t?[]:yr(t,uc(t))}var vc=fi((function(t,n,r){return n=n.toLowerCase(),t+(r?_c(n):n)}));function _c(t){return jc(Ga(t).toLowerCase())}function gc(t){return(t=Ga(t))&&t.replace(Ht,xr).replace(bn,"")}var dc=fi((function(t,n,r){return t+(r?"-":"")+n.toLowerCase()})),yc=fi((function(t,n,r){return t+(r?" ":"")+n.toLowerCase()})),wc=ci("toLowerCase");var bc=fi((function(t,n,r){return t+(r?"_":"")+n.toLowerCase()}));var mc=fi((function(t,n,r){return t+(r?" ":"")+jc(n)}));var xc=fi((function(t,n,r){return t+(r?" ":"")+n.toUpperCase()})),jc=ci("toUpperCase");function kc(t,n,r){return t=Ga(t),(n=r?i:n)===i?function(t){return kn.test(t)}(t)?function(t){return t.match(xn)||[]}(t):function(t){return t.match(Dt)||[]}(t):t.match(n)||[]}var Sc=ju((function(t,n){try{return Vn(t,i,n)}catch(t){return ja(t)?t:new Qt(t)}})),Ac=Ii((function(t,n){return Kn(n,(function(n){n=fo(n),Re(t,n,ra(t[n],t))})),t}));function zc(t){return function(){return t}}var Cc=hi(),Ic=hi(!0);function Oc(t){return t}function Ec(t){return cu("function"==typeof t?t:Te(t,h))}var Rc=ju((function(t,n){return function(r){return eu(r,t,n)}})),Lc=ju((function(t,n){return function(r){return eu(t,r,n)}}));function Bc(t,n,r){var e=uc(n),u=He(n,e);null!=r||za(n)&&(u.length||!e.length)||(r=n,n=t,t=this,u=He(n,uc(n)));var i=!(za(r)&&"chain"in r&&!r.chain),o=ka(t);return Kn(u,(function(r){var e=n[r];t[r]=e,o&&(t.prototype[r]=function(){var n=this.__chain__;if(i||n){var r=t(this.__wrapped__),u=r.__actions__=ri(this.__actions__);return u.push({func:e,args:arguments,thisArg:t}),r.__chain__=n,r}return e.apply(t,nr([this.value()],arguments))})})),t}function Tc(){}var Wc=gi(tr),Mc=gi(Jn),Pc=gi(ur);function Uc(t){return Zi(t)?hr(fo(t)):function(t){return function(n){return Je(n,t)}}(t)}var Dc=yi(),Nc=yi(!0);function $c(){return[]}function Fc(){return!1}var qc=_i((function(t,n){return t+n}),0),Gc=mi("ceil"),Vc=_i((function(t,n){return t/n}),1),Zc=mi("floor");var Kc,Hc=_i((function(t,n){return t*n}),1),Jc=mi("round"),Yc=_i((function(t,n){return t-n}),0);return pe.after=function(t,n){if("function"!=typeof n)throw new un(c);return t=Na(t),function(){if(--t<1)return n.apply(this,arguments)}},pe.ary=ta,pe.assign=Va,pe.assignIn=Za,pe.assignInWith=Ka,pe.assignWith=Ha,pe.at=Ja,pe.before=na,pe.bind=ra,pe.bindAll=Ac,pe.bindKey=ea,pe.castArray=function(){if(!arguments.length)return[];var t=arguments[0];return da(t)?t:[t]},pe.chain=Uo,pe.chunk=function(t,n,r){n=(r?Vi(t,n,r):n===i)?1:Gr(Na(n),0);var u=null==t?0:t.length;if(!u||n<1)return[];for(var o=0,a=0,c=e(Pr(u/n));ou?0:u+r),(e=e===i||e>u?u:Na(e))<0&&(e+=u),e=r>e?0:$a(e);r>>0)?(t=Ga(t))&&("string"==typeof n||null!=n&&!Ra(n))&&!(n=Wu(n))&&Sr(t)?Ku(Rr(t),0,r):t.split(n,r):[]},pe.spread=function(t,n){if("function"!=typeof t)throw new un(c);return n=null==n?0:Gr(Na(n),0),ju((function(r){var e=r[n],u=Ku(r,0,n);return e&&nr(u,e),Vn(t,this,u)}))},pe.tail=function(t){var n=null==t?0:t.length;return n?Ou(t,1,n):[]},pe.take=function(t,n,r){return t&&t.length?Ou(t,0,(n=r||n===i?1:Na(n))<0?0:n):[]},pe.takeRight=function(t,n,r){var e=null==t?0:t.length;return e?Ou(t,(n=e-(n=r||n===i?1:Na(n)))<0?0:n,e):[]},pe.takeRightWhile=function(t,n){return t&&t.length?Du(t,Ti(n,3),!1,!0):[]},pe.takeWhile=function(t,n){return t&&t.length?Du(t,Ti(n,3)):[]},pe.tap=function(t,n){return n(t),t},pe.throttle=function(t,n,r){var e=!0,u=!0;if("function"!=typeof t)throw new un(c);return za(r)&&(e="leading"in r?!!r.leading:e,u="trailing"in r?!!r.trailing:u),ua(t,n,{leading:e,maxWait:n,trailing:u})},pe.thru=Do,pe.toArray=Ua,pe.toPairs=lc,pe.toPairsIn=hc,pe.toPath=function(t){return da(t)?tr(t,fo):Ta(t)?[t]:ri(co(Ga(t)))},pe.toPlainObject=qa,pe.transform=function(t,n,r){var e=da(t),u=e||ma(t)||Wa(t);if(n=Ti(n,4),null==r){var i=t&&t.constructor;r=u?e?new i:[]:za(t)&&ka(i)?ve(Rn(t)):{}}return(u?Kn:Ze)(t,(function(t,e,u){return n(r,t,e,u)})),r},pe.unary=function(t){return ta(t,1)},pe.union=Co,pe.unionBy=Io,pe.unionWith=Oo,pe.uniq=function(t){return t&&t.length?Mu(t):[]},pe.uniqBy=function(t,n){return t&&t.length?Mu(t,Ti(n,2)):[]},pe.uniqWith=function(t,n){return n="function"==typeof n?n:i,t&&t.length?Mu(t,i,n):[]},pe.unset=function(t,n){return null==t||Pu(t,n)},pe.unzip=Eo,pe.unzipWith=Ro,pe.update=function(t,n,r){return null==t?t:Uu(t,n,Gu(r))},pe.updateWith=function(t,n,r,e){return e="function"==typeof e?e:i,null==t?t:Uu(t,n,Gu(r),e)},pe.values=pc,pe.valuesIn=function(t){return null==t?[]:yr(t,ic(t))},pe.without=Lo,pe.words=kc,pe.wrap=function(t,n){return sa(Gu(n),t)},pe.xor=Bo,pe.xorBy=To,pe.xorWith=Wo,pe.zip=Mo,pe.zipObject=function(t,n){return Fu(t||[],n||[],Ce)},pe.zipObjectDeep=function(t,n){return Fu(t||[],n||[],Au)},pe.zipWith=Po,pe.entries=lc,pe.entriesIn=hc,pe.extend=Za,pe.extendWith=Ka,Bc(pe,pe),pe.add=qc,pe.attempt=Sc,pe.camelCase=vc,pe.capitalize=_c,pe.ceil=Gc,pe.clamp=function(t,n,r){return r===i&&(r=n,n=i),r!==i&&(r=(r=Fa(r))==r?r:0),n!==i&&(n=(n=Fa(n))==n?n:0),Be(Fa(t),n,r)},pe.clone=function(t){return Te(t,v)},pe.cloneDeep=function(t){return Te(t,h|v)},pe.cloneDeepWith=function(t,n){return Te(t,h|v,n="function"==typeof n?n:i)},pe.cloneWith=function(t,n){return Te(t,v,n="function"==typeof n?n:i)},pe.conformsTo=function(t,n){return null==n||We(t,n,uc(n))},pe.deburr=gc,pe.defaultTo=function(t,n){return null==t||t!=t?n:t},pe.divide=Vc,pe.endsWith=function(t,n,r){t=Ga(t),n=Wu(n);var e=t.length,u=r=r===i?e:Be(Na(r),0,e);return(r-=n.length)>=0&&t.slice(r,u)==n},pe.eq=pa,pe.escape=function(t){return(t=Ga(t))&&St.test(t)?t.replace(jt,jr):t},pe.escapeRegExp=function(t){return(t=Ga(t))&&Lt.test(t)?t.replace(Rt,"\\$&"):t},pe.every=function(t,n,r){var e=da(t)?Jn:Ne;return r&&Vi(t,n,r)&&(n=i),e(t,Ti(n,3))},pe.find=Fo,pe.findIndex=_o,pe.findKey=function(t,n){return or(t,Ti(n,3),Ze)},pe.findLast=qo,pe.findLastIndex=go,pe.findLastKey=function(t,n){return or(t,Ti(n,3),Ke)},pe.floor=Zc,pe.forEach=Go,pe.forEachRight=Vo,pe.forIn=function(t,n){return null==t?t:Ge(t,Ti(n,3),ic)},pe.forInRight=function(t,n){return null==t?t:Ve(t,Ti(n,3),ic)},pe.forOwn=function(t,n){return t&&Ze(t,Ti(n,3))},pe.forOwnRight=function(t,n){return t&&Ke(t,Ti(n,3))},pe.get=Xa,pe.gt=va,pe.gte=_a,pe.has=function(t,n){return null!=t&&$i(t,n,tu)},pe.hasIn=tc,pe.head=wo,pe.identity=Oc,pe.includes=function(t,n,r,e){t=wa(t)?t:pc(t),r=r&&!e?Na(r):0;var u=t.length;return r<0&&(r=Gr(u+r,0)),Ba(t)?r<=u&&t.indexOf(n,r)>-1:!!u&&cr(t,n,r)>-1},pe.indexOf=function(t,n,r){var e=null==t?0:t.length;if(!e)return-1;var u=null==r?0:Na(r);return u<0&&(u=Gr(e+u,0)),cr(t,n,u)},pe.inRange=function(t,n,r){return n=Da(n),r===i?(r=n,n=0):r=Da(r),function(t,n,r){return t>=Vr(n,r)&&t=-B&&t<=B},pe.isSet=La,pe.isString=Ba,pe.isSymbol=Ta,pe.isTypedArray=Wa,pe.isUndefined=function(t){return t===i},pe.isWeakMap=function(t){return Ca(t)&&Ni(t)==ot},pe.isWeakSet=function(t){return Ca(t)&&Qe(t)==at},pe.join=function(t,n){return null==t?"":Fr.call(t,n)},pe.kebabCase=dc,pe.last=jo,pe.lastIndexOf=function(t,n,r){var e=null==t?0:t.length;if(!e)return-1;var u=e;return r!==i&&(u=(u=Na(r))<0?Gr(e+u,0):Vr(u,e-1)),n==n?function(t,n,r){for(var e=r+1;e--;)if(t[e]===n)return e;return e}(t,n,u):ar(t,sr,u,!0)},pe.lowerCase=yc,pe.lowerFirst=wc,pe.lt=Ma,pe.lte=Pa,pe.max=function(t){return t&&t.length?$e(t,Oc,Xe):i},pe.maxBy=function(t,n){return t&&t.length?$e(t,Ti(n,2),Xe):i},pe.mean=function(t){return lr(t,Oc)},pe.meanBy=function(t,n){return lr(t,Ti(n,2))},pe.min=function(t){return t&&t.length?$e(t,Oc,lu):i},pe.minBy=function(t,n){return t&&t.length?$e(t,Ti(n,2),lu):i},pe.stubArray=$c,pe.stubFalse=Fc,pe.stubObject=function(){return{}},pe.stubString=function(){return""},pe.stubTrue=function(){return!0},pe.multiply=Hc,pe.nth=function(t,n){return t&&t.length?gu(t,Na(n)):i},pe.noConflict=function(){return Bn._===this&&(Bn._=gn),this},pe.noop=Tc,pe.now=Xo,pe.pad=function(t,n,r){t=Ga(t);var e=(n=Na(n))?Er(t):0;if(!n||e>=n)return t;var u=(n-e)/2;return di(Ur(u),r)+t+di(Pr(u),r)},pe.padEnd=function(t,n,r){t=Ga(t);var e=(n=Na(n))?Er(t):0;return n&&en){var e=t;t=n,n=e}if(r||t%1||n%1){var u=Hr();return Vr(t+u*(n-t+On("1e-"+((u+"").length-1))),n)}return mu(t,n)},pe.reduce=function(t,n,r){var e=da(t)?rr:vr,u=arguments.length<3;return e(t,Ti(n,4),r,u,Ue)},pe.reduceRight=function(t,n,r){var e=da(t)?er:vr,u=arguments.length<3;return e(t,Ti(n,4),r,u,De)},pe.repeat=function(t,n,r){return n=(r?Vi(t,n,r):n===i)?1:Na(n),xu(Ga(t),n)},pe.replace=function(){var t=arguments,n=Ga(t[0]);return t.length<3?n:n.replace(t[1],t[2])},pe.result=function(t,n,r){var e=-1,u=(n=Vu(n,t)).length;for(u||(u=1,t=i);++eB)return[];var r=M,e=Vr(t,M);n=Ti(n),t-=M;for(var u=gr(e,n);++r=o)return t;var c=r-Er(e);if(c<1)return e;var f=a?Ku(a,0,c).join(""):t.slice(0,c);if(u===i)return f+e;if(a&&(c+=f.length-c),Ra(u)){if(t.slice(c).search(u)){var s,l=f;for(u.global||(u=rn(u.source,Ga(Ft.exec(u))+"g")),u.lastIndex=0;s=u.exec(l);)var h=s.index;f=f.slice(0,h===i?c:h)}}else if(t.indexOf(Wu(u),c)!=c){var p=f.lastIndexOf(u);p>-1&&(f=f.slice(0,p))}return f+e},pe.unescape=function(t){return(t=Ga(t))&&kt.test(t)?t.replace(xt,Lr):t},pe.uniqueId=function(t){var n=++hn;return Ga(t)+n},pe.upperCase=xc,pe.upperFirst=jc,pe.each=Go,pe.eachRight=Vo,pe.first=wo,Bc(pe,(Kc={},Ze(pe,(function(t,n){ln.call(pe.prototype,n)||(Kc[n]=t)})),Kc),{chain:!1}),pe.VERSION="4.17.15",Kn(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(t){pe[t].placeholder=pe})),Kn(["drop","take"],(function(t,n){de.prototype[t]=function(r){r=r===i?1:Gr(Na(r),0);var e=this.__filtered__&&!n?new de(this):this.clone();return e.__filtered__?e.__takeCount__=Vr(r,e.__takeCount__):e.__views__.push({size:Vr(r,M),type:t+(e.__dir__<0?"Right":"")}),e},de.prototype[t+"Right"]=function(n){return this.reverse()[t](n).reverse()}})),Kn(["filter","map","takeWhile"],(function(t,n){var r=n+1,e=r==E||3==r;de.prototype[t]=function(t){var n=this.clone();return n.__iteratees__.push({iteratee:Ti(t,3),type:r}),n.__filtered__=n.__filtered__||e,n}})),Kn(["head","last"],(function(t,n){var r="take"+(n?"Right":"");de.prototype[t]=function(){return this[r](1).value()[0]}})),Kn(["initial","tail"],(function(t,n){var r="drop"+(n?"":"Right");de.prototype[t]=function(){return this.__filtered__?new de(this):this[r](1)}})),de.prototype.compact=function(){return this.filter(Oc)},de.prototype.find=function(t){return this.filter(t).head()},de.prototype.findLast=function(t){return this.reverse().find(t)},de.prototype.invokeMap=ju((function(t,n){return"function"==typeof t?new de(this):this.map((function(r){return eu(r,t,n)}))})),de.prototype.reject=function(t){return this.filter(ca(Ti(t)))},de.prototype.slice=function(t,n){t=Na(t);var r=this;return r.__filtered__&&(t>0||n<0)?new de(r):(t<0?r=r.takeRight(-t):t&&(r=r.drop(t)),n!==i&&(r=(n=Na(n))<0?r.dropRight(-n):r.take(n-t)),r)},de.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},de.prototype.toArray=function(){return this.take(M)},Ze(de.prototype,(function(t,n){var r=/^(?:filter|find|map|reject)|While$/.test(n),e=/^(?:head|last)$/.test(n),u=pe[e?"take"+("last"==n?"Right":""):n],o=e||/^find/.test(n);u&&(pe.prototype[n]=function(){var n=this.__wrapped__,a=e?[1]:arguments,c=n instanceof de,f=a[0],s=c||da(n),l=function(t){var n=u.apply(pe,nr([t],a));return e&&h?n[0]:n};s&&r&&"function"==typeof f&&1!=f.length&&(c=s=!1);var h=this.__chain__,p=!!this.__actions__.length,v=o&&!h,_=c&&!p;if(!o&&s){n=_?n:new de(this);var g=t.apply(n,a);return g.__actions__.push({func:Do,args:[l],thisArg:i}),new ge(g,h)}return v&&_?t.apply(this,a):(g=this.thru(l),v?e?g.value()[0]:g.value():g)})})),Kn(["pop","push","shift","sort","splice","unshift"],(function(t){var n=on[t],r=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",e=/^(?:pop|shift)$/.test(t);pe.prototype[t]=function(){var t=arguments;if(e&&!this.__chain__){var u=this.value();return n.apply(da(u)?u:[],t)}return this[r]((function(r){return n.apply(da(r)?r:[],t)}))}})),Ze(de.prototype,(function(t,n){var r=pe[n];if(r){var e=r.name+"";ln.call(ue,e)||(ue[e]=[]),ue[e].push({name:n,func:r})}})),ue[pi(i,y).name]=[{name:"wrapper",func:i}],de.prototype.clone=function(){var t=new de(this.__wrapped__);return t.__actions__=ri(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=ri(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=ri(this.__views__),t},de.prototype.reverse=function(){if(this.__filtered__){var t=new de(this);t.__dir__=-1,t.__filtered__=!0}else(t=this.clone()).__dir__*=-1;return t},de.prototype.value=function(){var t=this.__wrapped__.value(),n=this.__dir__,r=da(t),e=n<0,u=r?t.length:0,i=function(t,n,r){var e=-1,u=r.length;for(;++e=this.__values__.length;return{done:t,value:t?i:this.__values__[this.__index__++]}},pe.prototype.plant=function(t){for(var n,r=this;r instanceof _e;){var e=lo(r);e.__index__=0,e.__values__=i,n?u.__wrapped__=e:n=e;var u=e;r=r.__wrapped__}return u.__wrapped__=t,n},pe.prototype.reverse=function(){var t=this.__wrapped__;if(t instanceof de){var n=t;return this.__actions__.length&&(n=new de(this)),(n=n.reverse()).__actions__.push({func:Do,args:[zo],thisArg:i}),new ge(n,this.__chain__)}return this.thru(zo)},pe.prototype.toJSON=pe.prototype.valueOf=pe.prototype.value=function(){return Nu(this.__wrapped__,this.__actions__)},pe.prototype.first=pe.prototype.head,Un&&(pe.prototype[Un]=function(){return this}),pe}();Bn._=Br,(u=function(){return Br}.call(n,r,n,e))===i||(e.exports=u)}).call(this)}).call(this,r(5),r(6)(t))},function(t,n,r){var e=r(2);"string"==typeof e&&(e=[[t.i,e,""]]);var u={insert:"head",singleton:!1};r(4)(e,u);e.locals&&(t.exports=e.locals)},function(t,n,r){(t.exports=r(3)(!1)).push([t.i,".lcd-container{padding:20px 30px;background-color:#c7e736;color:red;display:inline-block;font-size:0;border-color:#000;border-style:solid;border-width:10px 14px;box-shadow:inset 0 0 30px rgba(0,0,0,.3),0 10px 15px -5px rgba(0,0,0,.5);border-radius:3px;overflow:hidden}",""])},function(t,n,r){"use strict";t.exports=function(t){var n=[];return n.toString=function(){return this.map((function(n){var r=function(t,n){var r=t[1]||"",e=t[3];if(!e)return r;if(n&&"function"==typeof btoa){var u=(o=e,a=btoa(unescape(encodeURIComponent(JSON.stringify(o)))),c="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(a),"/*# ".concat(c," */")),i=e.sources.map((function(t){return"/*# sourceURL=".concat(e.sourceRoot).concat(t," */")}));return[r].concat(i).concat([u]).join("\n")}var o,a,c;return[r].join("\n")}(n,t);return n[2]?"@media ".concat(n[2],"{").concat(r,"}"):r})).join("")},n.i=function(t,r){"string"==typeof t&&(t=[[null,t,""]]);for(var e={},u=0;u{this.isVisible?this.render(!1):this.render(!0)},300))}}const i={20:{character:"Space",rows:[0,0,0,0,0,0,0]},21:{character:"!",rows:[4,4,4,4,4,0,4]},22:{character:'"',rows:[9,9,18,0,0,0,0]},23:{character:"#",rows:[10,10,31,10,31,10,10]},24:{character:"$",rows:[4,15,20,14,5,30,4]},25:{character:"%",rows:[25,25,2,4,8,19,19]},26:{character:"&",rows:[4,10,10,10,21,18,13]},27:{character:"'",rows:[4,4,8,0,0,0,0]},28:{character:"(",rows:[2,4,8,8,8,4,2]},29:{character:")",rows:[8,4,2,2,2,4,8]},"2a":{character:"*",rows:[4,21,14,31,14,21,4]},"2b":{character:"+",rows:[0,4,4,31,4,4,0]},"2c":{character:",",rows:[0,0,0,0,4,4,8]},"2d":{character:"-",rows:[0,0,0,31,0,0,0]},"2e":{character:".",rows:[0,0,0,0,0,12,12]},"2f":{character:"/",rows:[1,1,2,4,8,16,16]},30:{character:"0",rows:[14,17,19,21,25,17,14]},31:{character:"1",rows:[4,12,4,4,4,4,14]},32:{character:"2",rows:[14,17,1,2,4,8,31]},33:{character:"3",rows:[14,17,1,6,1,17,14]},34:{character:"4",rows:[2,6,10,18,31,2,2]},35:{character:"5",rows:[31,16,30,1,1,17,14]},36:{character:"6",rows:[6,8,16,30,17,17,14]},37:{character:"7",rows:[31,1,2,4,8,8,8]},38:{character:"8",rows:[14,17,17,14,17,17,14]},39:{character:"9",rows:[14,17,17,15,1,2,12]},"3a":{character:":",rows:[0,12,12,0,12,12,0]},"3b":{character:";",rows:[0,12,12,0,12,4,8]},"3c":{character:"<",rows:[2,4,8,16,8,4,2]},"3d":{character:"=",rows:[0,0,31,0,31,0,0]},"3e":{character:">",rows:[8,4,2,1,2,4,8]},"3f":{character:"?",rows:[14,17,1,2,4,0,4]},40:{character:"@",rows:[14,17,23,21,23,16,15]},41:{character:"A",rows:[4,10,17,17,31,17,17]},42:{character:"B",rows:[30,17,17,30,17,17,30]},43:{character:"C",rows:[14,17,16,16,16,17,14]},44:{character:"D",rows:[30,9,9,9,9,9,30]},45:{character:"E",rows:[31,16,16,28,16,16,31]},46:{character:"F",rows:[31,16,16,31,16,16,16]},47:{character:"G",rows:[14,17,16,16,19,17,15]},48:{character:"H",rows:[17,17,17,31,17,17,17]},49:{character:"I",rows:[14,4,4,4,4,4,14]},"4a":{character:"J",rows:[31,2,2,2,2,18,12]},"4b":{character:"K",rows:[17,18,20,24,20,18,17]},"4c":{character:"L",rows:[16,16,16,16,16,16,31]},"4d":{character:"M",rows:[17,27,21,17,17,17,17]},"4e":{character:"N",rows:[17,17,25,21,19,17,17]},"4f":{character:"O",rows:[14,17,17,17,17,17,14]},50:{character:"P",rows:[30,17,17,30,16,16,16]},51:{character:"Q",rows:[14,17,17,17,21,18,13]},52:{character:"R",rows:[30,17,17,30,20,18,17]},53:{character:"S",rows:[14,17,16,14,1,17,14]},54:{character:"T",rows:[31,4,4,4,4,4,4]},55:{character:"U",rows:[17,17,17,17,17,17,14]},56:{character:"V",rows:[17,17,17,17,17,10,4]},57:{character:"W",rows:[17,17,17,21,21,27,17]},58:{character:"X",rows:[17,17,10,4,10,17,17]},59:{character:"Y",rows:[17,17,10,4,4,4,4]},"5a":{character:"Z",rows:[31,1,2,4,8,16,31]},"5b":{character:"[",rows:[14,8,8,8,8,8,14]},"5c":{character:"\\",rows:[16,16,8,4,2,1,1]},"5d":{character:"]",rows:[14,2,2,2,2,2,14]},"5e":{character:"^",rows:[4,10,17,0,0,0,0]},"5f":{character:"_",rows:[0,0,0,0,0,0,31]},60:{character:"`",rows:[4,4,2,0,0,0,0]},61:{character:"a",rows:[0,14,1,13,19,19,13]},62:{character:"b",rows:[16,16,16,28,18,18,28]},63:{character:"c",rows:[0,0,0,14,16,16,14]},64:{character:"d",rows:[1,1,1,7,9,9,7]},65:{character:"e",rows:[0,0,14,17,31,16,15]},66:{character:"f",rows:[6,9,8,28,8,8,8]},67:{character:"g",rows:[14,17,19,13,1,1,14]},68:{character:"h",rows:[16,16,16,22,25,17,17]},69:{character:"i",rows:[0,4,0,12,4,4,14]},"6a":{character:"j",rows:[2,0,6,2,2,18,12]},"6b":{character:"k",rows:[16,16,18,20,24,20,18]},"6c":{character:"l",rows:[12,4,4,4,4,4,4]},"6d":{character:"m",rows:[0,0,10,21,21,17,17]},"6e":{character:"n",rows:[0,0,22,25,17,17,17]},"6f":{character:"o",rows:[0,0,14,17,17,17,14]},70:{character:"p",rows:[0,28,18,18,28,16,16]},71:{character:"q",rows:[0,7,9,9,7,1,1]},72:{character:"r",rows:[0,0,22,25,16,16,16]},73:{character:"s",rows:[0,0,15,16,14,1,30]},74:{character:"t",rows:[8,8,28,8,8,9,6]},75:{character:"u",rows:[0,0,17,17,17,19,13]},76:{character:"v",rows:[0,0,17,17,17,10,4]},77:{character:"w",rows:[0,0,17,17,21,21,10]},78:{character:"x",rows:[0,0,17,10,4,10,17]},79:{character:"y",rows:[0,17,17,15,1,17,14]},"7a":{character:"z",rows:[0,0,31,2,4,8,31]},"7b":{character:"{",rows:[6,8,8,16,8,8,6]},"7c":{character:"|",rows:[4,4,4,0,4,4,4]},"7d":{character:"}",rows:[12,2,2,1,2,2,12]},"7e":{character:"~",rows:[8,21,2,0,0,0,0]},"7f":{character:"DEL",rows:[31,31,31,31,31,31,31]}},o=(t,n)=>{return(Array(n).fill("0").join(0)+t).slice(-n)};class a{constructor({canvas:t,index:n,rows:r,columns:e,pixelSize:i,pixelColor:o}={}){this.canvas=t,this.index=n,this.rows=r,this.columns=e,this.pixelSize=i,this.pixelColor=o,this.setPosition(),this.pixels=[...Array(a.getPixelCount())].map((t,n)=>new u({canvas:this.canvas,index:n,size:this.pixelSize,color:this.pixelColor,offset:{x:this.x,y:this.y}})),this.render()}static getPixels(){return{row:5,column:8}}static getPixelCount(){const{row:t,column:n}=a.getPixels();return t*n}static getGutterSize(t){return t}static getSize(t){const{row:n,column:r}=a.getPixels(),e=u.getGutterSize(t);return{width:t*n+e*(n-1),height:t*r+e*(r-1)}}setPosition(){this.gutter=a.getGutterSize(this.pixelSize);const{width:t,height:n}=a.getSize(this.pixelSize),r=this.index%this.columns,e=Math.floor(this.index/this.columns);this.x=r*t+r*this.gutter,this.y=e*n+e*this.gutter}render(){this.pixels.forEach(t=>{t.render(!1)})}writeCharacter({charCode:t}){this.clearCharacter();const n=Object(e.isNumber)(t)?Number(t).toString(16):t,{rows:r}=i[n],u=r.map(t=>{const n=Number(t).toString(2);return o(n,5)}).join("").split("");this.pixels.forEach(t=>{const n=u[t.index];t.render("1"===n)})}clearCharacter(){this.pixels.forEach(t=>{t.render(!1)})}toggleCursorBlink(t=!1){const{row:n}=a.getPixels();this.pixels.slice(-n).forEach(n=>{n.blink(t)})}}class c{constructor({elem:t,rows:n,columns:r,pixelSize:e,pixelColor:u}){this.rows=n,this.columns=r,this.pixelSize=e,this.pixelColor=u,this.elem=t,this.render(),this.blocks=[...Array(this.rows*this.columns)].map((t,n)=>new a({canvas:this.canvas,index:n,rows:this.rows,columns:this.columns,pixelSize:e,pixelColor:u})),this.activeBlockIndex=null}static getSize(t,n,r){const e=a.getSize(r),u=a.getGutterSize(r);return{width:e.width*n+u*(n-1),height:e.height*t+u*(t-1)}}render(){this.canvas=document.createElement("canvas");const{width:t,height:n}=c.getSize(this.rows,this.columns,this.pixelSize);this.canvas.setAttribute("width",t),this.canvas.setAttribute("height",n),this.elem.innerHTML="",this.elem.appendChild(this.canvas)}writeCharacter({charCode:t,blockIndex:n=0}={}){const r=Object(e.find)(this.blocks,{index:n});r&&r.writeCharacter({charCode:t})}writeString({string:t="",offset:n=0}={}){t.split("").forEach((t,r)=>{const e=t.charCodeAt(0);this.writeCharacter({charCode:e,blockIndex:r+n})})}clearCharacter({blockIndex:t=0}={}){const n=Object(e.find)(this.blocks,{index:t});n&&n.clearCharacter()}clearScreen(){this.blocks.forEach(t=>{this.clearCharacter({blockIndex:t.index})})}blinkCursor({blockIndex:t=0,stop:n=!1}={}){const r=Object(e.find)(this.blocks,{index:t});if(r){if(null!==this.activeBlockIndex){Object(e.find)(this.blocks,{index:this.activeBlockIndex}).toggleCursorBlink(!0)}this.activeBlockIndex=t,r.toggleCursorBlink(n)}}}n.default=c}]).default}));
10 | //# sourceMappingURL=index.js.map
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | User Application
7 |
8 |
26 |
27 |
28 |
29 |
Hello World!
30 |
31 |
32 |
33 |
66 |
67 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "dot-matrix-lcd",
3 | "version": "1.0.0",
4 | "description": "A simple Dot Matrix LCD emulator for JavaScript.",
5 | "main": "dist/index.js",
6 | "scripts": {
7 | "build": "NODE_ENV=production webpack",
8 | "start": "webpack-dev-server"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/thatisuday/dot-matrix-lcd.git"
13 | },
14 | "keywords": [],
15 | "author": "Uday Hiwarale ",
16 | "license": "ISC",
17 | "bugs": {
18 | "url": "https://github.com/thatisuday/dot-matrix-lcd/issues"
19 | },
20 | "homepage": "https://github.com/thatisuday/dot-matrix-lcd#readme",
21 | "devDependencies": {
22 | "@babel/core": "^7.7.5",
23 | "@babel/plugin-proposal-class-properties": "^7.7.4",
24 | "@babel/plugin-proposal-decorators": "^7.7.4",
25 | "@babel/plugin-proposal-export-default-from": "^7.7.4",
26 | "@babel/plugin-proposal-object-rest-spread": "^7.7.4",
27 | "@babel/plugin-transform-arrow-functions": "^7.7.4",
28 | "@babel/plugin-transform-async-to-generator": "^7.7.4",
29 | "@babel/plugin-transform-runtime": "^7.7.6",
30 | "@babel/preset-env": "^7.7.6",
31 | "autoprefixer": "^9.7.3",
32 | "babel-loader": "^8.0.6",
33 | "config": "^3.2.4",
34 | "css-loader": "^3.3.0",
35 | "cssnano": "^4.1.10",
36 | "html-webpack-plugin": "^3.2.0",
37 | "node-sass": "^4.13.0",
38 | "postcss-loader": "^3.0.0",
39 | "sass-loader": "^8.0.0",
40 | "style-loader": "^1.0.1",
41 | "webpack": "^4.41.2",
42 | "webpack-cli": "^3.3.10",
43 | "webpack-dev-server": "^3.9.0"
44 | },
45 | "dependencies": {
46 | "lodash": "^4.17.15"
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/postcss.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | plugins: [
3 | require('autoprefixer'),
4 | require('cssnano'),
5 | ]
6 | };
--------------------------------------------------------------------------------
/src/constants/character-map.js:
--------------------------------------------------------------------------------
1 | // 5*7 dot-matrix pixel values for ASCII characters
2 | export const characterMap = {
3 | "20": {
4 | character: "Space",
5 | rows: [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
6 | },
7 | "21": { character: "!", rows: [0x04, 0x04, 0x04, 0x04, 0x04, 0x00, 0x04] },
8 | "22": { character: '"', rows: [0x09, 0x09, 0x12, 0x00, 0x00, 0x00, 0x00] },
9 | "23": { character: "#", rows: [0x0a, 0x0a, 0x1f, 0x0a, 0x1f, 0x0a, 0x0a] },
10 | "24": { character: "$", rows: [0x04, 0x0f, 0x14, 0x0e, 0x05, 0x1e, 0x04] },
11 | "25": { character: "%", rows: [0x19, 0x19, 0x02, 0x04, 0x08, 0x13, 0x13] },
12 | "26": { character: "&", rows: [0x04, 0x0a, 0x0a, 0x0a, 0x15, 0x12, 0x0d] },
13 | "27": { character: "'", rows: [0x04, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00] },
14 | "28": { character: "(", rows: [0x02, 0x04, 0x08, 0x08, 0x08, 0x04, 0x02] },
15 | "29": { character: ")", rows: [0x08, 0x04, 0x02, 0x02, 0x02, 0x04, 0x08] },
16 | "2a": { character: "*", rows: [0x04, 0x15, 0x0e, 0x1f, 0x0e, 0x15, 0x04] },
17 | "2b": { character: "+", rows: [0x00, 0x04, 0x04, 0x1f, 0x04, 0x04, 0x00] },
18 | "2c": { character: ",", rows: [0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x08] },
19 | "2d": { character: "-", rows: [0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00] },
20 | "2e": { character: ".", rows: [0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x0c] },
21 | "2f": { character: "/", rows: [0x01, 0x01, 0x02, 0x04, 0x08, 0x10, 0x10] },
22 | "30": { character: "0", rows: [0x0e, 0x11, 0x13, 0x15, 0x19, 0x11, 0x0e] },
23 | "31": { character: "1", rows: [0x04, 0x0c, 0x04, 0x04, 0x04, 0x04, 0x0e] },
24 | "32": { character: "2", rows: [0x0e, 0x11, 0x01, 0x02, 0x04, 0x08, 0x1f] },
25 | "33": { character: "3", rows: [0x0e, 0x11, 0x01, 0x06, 0x01, 0x11, 0x0e] },
26 | "34": { character: "4", rows: [0x02, 0x06, 0x0a, 0x12, 0x1f, 0x02, 0x02] },
27 | "35": { character: "5", rows: [0x1f, 0x10, 0x1e, 0x01, 0x01, 0x11, 0x0e] },
28 | "36": { character: "6", rows: [0x06, 0x08, 0x10, 0x1e, 0x11, 0x11, 0x0e] },
29 | "37": { character: "7", rows: [0x1f, 0x01, 0x02, 0x04, 0x08, 0x08, 0x08] },
30 | "38": { character: "8", rows: [0x0e, 0x11, 0x11, 0x0e, 0x11, 0x11, 0x0e] },
31 | "39": { character: "9", rows: [0x0e, 0x11, 0x11, 0x0f, 0x01, 0x02, 0x0c] },
32 | "3a": { character: ":", rows: [0x00, 0x0c, 0x0c, 0x00, 0x0c, 0x0c, 0x00] },
33 | "3b": { character: ";", rows: [0x00, 0x0c, 0x0c, 0x00, 0x0c, 0x04, 0x08] },
34 | "3c": { character: "<", rows: [0x02, 0x04, 0x08, 0x10, 0x08, 0x04, 0x02] },
35 | "3d": { character: "=", rows: [0x00, 0x00, 0x1f, 0x00, 0x1f, 0x00, 0x00] },
36 | "3e": { character: ">", rows: [0x08, 0x04, 0x02, 0x01, 0x02, 0x04, 0x08] },
37 | "3f": { character: "?", rows: [0x0e, 0x11, 0x01, 0x02, 0x04, 0x00, 0x04] },
38 | "40": { character: "@", rows: [0x0e, 0x11, 0x17, 0x15, 0x17, 0x10, 0x0f] },
39 | "41": { character: "A", rows: [0x04, 0x0a, 0x11, 0x11, 0x1f, 0x11, 0x11] },
40 | "42": { character: "B", rows: [0x1e, 0x11, 0x11, 0x1e, 0x11, 0x11, 0x1e] },
41 | "43": { character: "C", rows: [0x0e, 0x11, 0x10, 0x10, 0x10, 0x11, 0x0e] },
42 | "44": { character: "D", rows: [0x1e, 0x09, 0x09, 0x09, 0x09, 0x09, 0x1e] },
43 | "45": { character: "E", rows: [0x1f, 0x10, 0x10, 0x1c, 0x10, 0x10, 0x1f] },
44 | "46": { character: "F", rows: [0x1f, 0x10, 0x10, 0x1f, 0x10, 0x10, 0x10] },
45 | "47": { character: "G", rows: [0x0e, 0x11, 0x10, 0x10, 0x13, 0x11, 0x0f] },
46 | "48": { character: "H", rows: [0x11, 0x11, 0x11, 0x1f, 0x11, 0x11, 0x11] },
47 | "49": { character: "I", rows: [0x0e, 0x04, 0x04, 0x04, 0x04, 0x04, 0x0e] },
48 | "4a": { character: "J", rows: [0x1f, 0x02, 0x02, 0x02, 0x02, 0x12, 0x0c] },
49 | "4b": { character: "K", rows: [0x11, 0x12, 0x14, 0x18, 0x14, 0x12, 0x11] },
50 | "4c": { character: "L", rows: [0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x1f] },
51 | "4d": { character: "M", rows: [0x11, 0x1b, 0x15, 0x11, 0x11, 0x11, 0x11] },
52 | "4e": { character: "N", rows: [0x11, 0x11, 0x19, 0x15, 0x13, 0x11, 0x11] },
53 | "4f": { character: "O", rows: [0x0e, 0x11, 0x11, 0x11, 0x11, 0x11, 0x0e] },
54 | "50": { character: "P", rows: [0x1e, 0x11, 0x11, 0x1e, 0x10, 0x10, 0x10] },
55 | "51": { character: "Q", rows: [0x0e, 0x11, 0x11, 0x11, 0x15, 0x12, 0x0d] },
56 | "52": { character: "R", rows: [0x1e, 0x11, 0x11, 0x1e, 0x14, 0x12, 0x11] },
57 | "53": { character: "S", rows: [0x0e, 0x11, 0x10, 0x0e, 0x01, 0x11, 0x0e] },
58 | "54": { character: "T", rows: [0x1f, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04] },
59 | "55": { character: "U", rows: [0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x0e] },
60 | "56": { character: "V", rows: [0x11, 0x11, 0x11, 0x11, 0x11, 0x0a, 0x04] },
61 | "57": { character: "W", rows: [0x11, 0x11, 0x11, 0x15, 0x15, 0x1b, 0x11] },
62 | "58": { character: "X", rows: [0x11, 0x11, 0x0a, 0x04, 0x0a, 0x11, 0x11] },
63 | "59": { character: "Y", rows: [0x11, 0x11, 0x0a, 0x04, 0x04, 0x04, 0x04] },
64 | "5a": { character: "Z", rows: [0x1f, 0x01, 0x02, 0x04, 0x08, 0x10, 0x1f] },
65 | "5b": { character: "[", rows: [0x0e, 0x08, 0x08, 0x08, 0x08, 0x08, 0x0e] },
66 | "5c": { character: "\\", rows: [0x10, 0x10, 0x08, 0x04, 0x02, 0x01, 0x01] },
67 | "5d": { character: "]", rows: [0x0e, 0x02, 0x02, 0x02, 0x02, 0x02, 0x0e] },
68 | "5e": { character: "^", rows: [0x04, 0x0a, 0x11, 0x00, 0x00, 0x00, 0x00] },
69 | "5f": { character: "_", rows: [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f] },
70 | "60": { character: "`", rows: [0x04, 0x04, 0x02, 0x00, 0x00, 0x00, 0x00] },
71 | "61": { character: "a", rows: [0x00, 0x0e, 0x01, 0x0d, 0x13, 0x13, 0x0d] },
72 | "62": { character: "b", rows: [0x10, 0x10, 0x10, 0x1c, 0x12, 0x12, 0x1c] },
73 | "63": { character: "c", rows: [0x00, 0x00, 0x00, 0x0e, 0x10, 0x10, 0x0e] },
74 | "64": { character: "d", rows: [0x01, 0x01, 0x01, 0x07, 0x09, 0x09, 0x07] },
75 | "65": { character: "e", rows: [0x00, 0x00, 0x0e, 0x11, 0x1f, 0x10, 0x0f] },
76 | "66": { character: "f", rows: [0x06, 0x09, 0x08, 0x1c, 0x08, 0x08, 0x08] },
77 | "67": { character: "g", rows: [0x0e, 0x11, 0x13, 0x0d, 0x01, 0x01, 0x0e] },
78 | "68": { character: "h", rows: [0x10, 0x10, 0x10, 0x16, 0x19, 0x11, 0x11] },
79 | "69": { character: "i", rows: [0x00, 0x04, 0x00, 0x0c, 0x04, 0x04, 0x0e] },
80 | "6a": { character: "j", rows: [0x02, 0x00, 0x06, 0x02, 0x02, 0x12, 0x0c] },
81 | "6b": { character: "k", rows: [0x10, 0x10, 0x12, 0x14, 0x18, 0x14, 0x12] },
82 | "6c": { character: "l", rows: [0x0c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04] },
83 | "6d": { character: "m", rows: [0x00, 0x00, 0x0a, 0x15, 0x15, 0x11, 0x11] },
84 | "6e": { character: "n", rows: [0x00, 0x00, 0x16, 0x19, 0x11, 0x11, 0x11] },
85 | "6f": { character: "o", rows: [0x00, 0x00, 0x0e, 0x11, 0x11, 0x11, 0x0e] },
86 | "70": { character: "p", rows: [0x00, 0x1c, 0x12, 0x12, 0x1c, 0x10, 0x10] },
87 | "71": { character: "q", rows: [0x00, 0x07, 0x09, 0x09, 0x07, 0x01, 0x01] },
88 | "72": { character: "r", rows: [0x00, 0x00, 0x16, 0x19, 0x10, 0x10, 0x10] },
89 | "73": { character: "s", rows: [0x00, 0x00, 0x0f, 0x10, 0x0e, 0x01, 0x1e] },
90 | "74": { character: "t", rows: [0x08, 0x08, 0x1c, 0x08, 0x08, 0x09, 0x06] },
91 | "75": { character: "u", rows: [0x00, 0x00, 0x11, 0x11, 0x11, 0x13, 0x0d] },
92 | "76": { character: "v", rows: [0x00, 0x00, 0x11, 0x11, 0x11, 0x0a, 0x04] },
93 | "77": { character: "w", rows: [0x00, 0x00, 0x11, 0x11, 0x15, 0x15, 0x0a] },
94 | "78": { character: "x", rows: [0x00, 0x00, 0x11, 0x0a, 0x04, 0x0a, 0x11] },
95 | "79": { character: "y", rows: [0x00, 0x11, 0x11, 0x0f, 0x01, 0x11, 0x0e] },
96 | "7a": { character: "z", rows: [0x00, 0x00, 0x1f, 0x02, 0x04, 0x08, 0x1f] },
97 | "7b": { character: "{", rows: [0x06, 0x08, 0x08, 0x10, 0x08, 0x08, 0x06] },
98 | "7c": { character: "|", rows: [0x04, 0x04, 0x04, 0x00, 0x04, 0x04, 0x04] },
99 | "7d": { character: "}", rows: [0x0c, 0x02, 0x02, 0x01, 0x02, 0x02, 0x0c] },
100 | "7e": { character: "~", rows: [0x08, 0x15, 0x02, 0x00, 0x00, 0x00, 0x00] },
101 | "7f": { character: "DEL", rows: [0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f] }
102 | };
103 |
--------------------------------------------------------------------------------
/src/constants/event-emitter.js:
--------------------------------------------------------------------------------
1 | // create event emitter
2 | export const emitter = EventEmitter();
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | // import `.scss` files
2 | import './scss/styles.scss';
3 |
4 | // import `Canvas` class
5 | import { Canvas } from './lib/canvas';
6 |
7 | // export canvas as default export
8 | export default Canvas;
--------------------------------------------------------------------------------
/src/lib/block.js:
--------------------------------------------------------------------------------
1 | import { isNumber } from 'lodash';
2 |
3 | // import local dependencies
4 | import { Pixel } from './pixel';
5 | import { characterMap } from '../constants/character-map';
6 | import { padLeftZeros } from '../util/common';
7 |
8 | export class Block {
9 | constructor({ canvas, index, rows, columns, pixelSize, pixelColor } = {}) {
10 | this.canvas = canvas; // canvas element
11 | this.index = index; // index of the block
12 | this.rows = rows; // total rows of blocks on the canvas
13 | this.columns = columns; // total columns of blocks on the canvas
14 | this.pixelSize = pixelSize; // size of each pixel
15 | this.pixelColor = pixelColor; // color of pixels
16 |
17 | // set block position
18 | this.setPosition();
19 |
20 | // create pixel array ( 5 x 8 = 40 pixels )
21 | this.pixels = [...Array(Block.getPixelCount())].map((_, index) => {
22 | return new Pixel({
23 | canvas: this.canvas,
24 | index,
25 | size: this.pixelSize,
26 | color: this.pixelColor,
27 | offset: { x: this.x, y: this.y }
28 | });
29 | });
30 |
31 | // render block
32 | this.render();
33 | }
34 |
35 | /*****************************************/
36 |
37 | // number of pixels in row and columns
38 | static getPixels() {
39 | return {
40 | row: 5, // 5 pixels in a row
41 | column: 8 // 8 pixels in a column
42 | };
43 | }
44 |
45 | // get pixel count
46 | static getPixelCount() {
47 | const { row, column } = Block.getPixels();
48 | return row * column;
49 | }
50 |
51 | // get gutter size : separation between each block
52 | static getGutterSize(pixelSize) {
53 | return pixelSize;
54 | }
55 |
56 | // get size of the block
57 | static getSize(pixelSize) {
58 | const { row, column } = Block.getPixels();
59 |
60 | // separation between each pixels
61 | const pGutter = Pixel.getGutterSize(pixelSize);
62 |
63 | // width and heigh pf entire block
64 | const width = pixelSize * row + pGutter * (row - 1);
65 | const height = pixelSize * column + pGutter * (column - 1);
66 |
67 | return { width, height };
68 | }
69 |
70 | /*****************************************/
71 |
72 | // set position of the block relative to the canvas
73 | setPosition() {
74 | // separation between each block
75 | this.gutter = Block.getGutterSize(this.pixelSize);
76 |
77 | // size of the block
78 | const { width, height } = Block.getSize(this.pixelSize);
79 |
80 | // horizontal and vertical index
81 | const hIndex = this.index % this.columns;
82 | const vIndex = Math.floor(this.index / this.columns);
83 |
84 | // relative X position to the canvas = (horizontal index * width) + (horizontal index * gutter)
85 | this.x = hIndex * width + hIndex * this.gutter;
86 |
87 | // relative Y position to the canvas = (vertical index * size) + (vertical index * gutter)
88 | this.y = vIndex * height + vIndex * this.gutter;
89 | }
90 |
91 | // render block
92 | render() {
93 | // render pixels
94 | this.pixels.forEach(pixel => {
95 | pixel.render(false);
96 | });
97 | }
98 |
99 | // write a character if the `blockIndex` is the current block index
100 | writeCharacter({ charCode }) {
101 | // clear character first
102 | this.clearCharacter();
103 |
104 | // if `charCode` is number, convert to hexadecimal string
105 | const hexCode = isNumber(charCode) ? Number(charCode).toString(16) : charCode;
106 |
107 | // get rows (containing active pixels values) from `characterMap`
108 | const { rows } = characterMap[hexCode];
109 |
110 | // for each element in row, convert value to binary number string
111 | const binaryRows = rows.map(rowValue => {
112 | // covert number to binary number
113 | const binaryString = Number(rowValue).toString(2);
114 |
115 | // pad left zero until total length becomes 5
116 | return padLeftZeros(binaryString, 5);
117 | });
118 |
119 | // get bit value of each pixels in the block
120 | const bitPixels = binaryRows.join("").split("");
121 |
122 | // for each pixel, re-render if pixel value is `1`
123 | this.pixels.forEach(pixel => {
124 | const pixelValue = bitPixels[pixel.index];
125 | pixel.render(pixelValue === "1");
126 | });
127 | }
128 |
129 | // clear a character if the `blockIndex` is the current block index
130 | clearCharacter() {
131 | // for each pixel, re-render
132 | this.pixels.forEach(pixel => {
133 | pixel.render(false);
134 | });
135 | }
136 |
137 | // toggle cursort blink
138 | toggleCursorBlink(stop = false) {
139 | // get last row of pixels
140 | const { row } = Block.getPixels();
141 | const pixels = this.pixels.slice(-row);
142 |
143 | pixels.forEach(pixel => {
144 | pixel.blink(stop);
145 | });
146 | }
147 | }
--------------------------------------------------------------------------------
/src/lib/canvas.js:
--------------------------------------------------------------------------------
1 | import { find } from 'lodash';
2 |
3 | // import Block class
4 | import { Block } from './block';
5 |
6 | export class Canvas {
7 | constructor({ elem, rows, columns, pixelSize, pixelColor }) {
8 | this.rows = rows; // total rows of blocks on the canvas
9 | this.columns = columns; // total columns of blocks on the canvas
10 | this.pixelSize = pixelSize; // size of each pixel
11 | this.pixelColor = pixelColor; // color of pixels
12 | this.elem = elem; // DOM element to render canvas element
13 |
14 | // render canvas element
15 | this.render();
16 |
17 | // create block
18 | this.blocks = [...Array(this.rows * this.columns)].map((_, index) => {
19 | return new Block({
20 | canvas: this.canvas,
21 | index,
22 | rows: this.rows,
23 | columns: this.columns,
24 | pixelSize,
25 | pixelColor
26 | });
27 | });
28 |
29 | // active cursor block
30 | this.activeBlockIndex = null;
31 | }
32 |
33 | /*****************************************/
34 |
35 | // get size of the canvas
36 | static getSize(rows, columns, pixelSize) {
37 | const blockSize = Block.getSize(pixelSize);
38 | const blockGutterSize = Block.getGutterSize(pixelSize);
39 |
40 | return {
41 | width: blockSize.width * columns + blockGutterSize * (columns - 1),
42 | height: blockSize.height * rows + blockGutterSize * (rows - 1)
43 | };
44 | }
45 |
46 | /*****************************************/
47 |
48 | // render canvas
49 | render() {
50 | // create canvas element
51 | this.canvas = document.createElement("canvas");
52 |
53 | // get width of height of canvas
54 | const { width, height } = Canvas.getSize(
55 | this.rows,
56 | this.columns,
57 | this.pixelSize
58 | );
59 |
60 | // set width and height attributes
61 | this.canvas.setAttribute("width", width);
62 | this.canvas.setAttribute("height", height);
63 |
64 | // render canvas
65 | this.elem.innerHTML = "";
66 | this.elem.appendChild(this.canvas);
67 | }
68 |
69 | // write a character in a block using index
70 | writeCharacter({ charCode, blockIndex = 0 } = {}) {
71 | const block = find(this.blocks, { index: blockIndex });
72 |
73 | // if block is not found with the block index, return
74 | if (!block) {
75 | return;
76 | }
77 |
78 | // write character
79 | block.writeCharacter({
80 | charCode
81 | });
82 | }
83 |
84 | // write string of characters
85 | writeString({ string = "", offset = 0 } = {}) {
86 | // generate characters from the string
87 | const characters = string.split("");
88 |
89 | // render each character on blocks
90 | characters.forEach((character, index) => {
91 | const charCode = character.charCodeAt(0); // returns a decimal number
92 | this.writeCharacter({
93 | charCode,
94 | blockIndex: index + offset // use block offset to shift the block
95 | });
96 | });
97 | }
98 |
99 | // clear a character
100 | clearCharacter({ blockIndex = 0 } = {}) {
101 | const block = find(this.blocks, { index: blockIndex });
102 |
103 | // if block is not found with the block index, return
104 | if (!block) {
105 | return;
106 | }
107 |
108 | // write character
109 | block.clearCharacter();
110 | }
111 |
112 | // clear the canvas (screen)
113 | clearScreen() {
114 | // for each block, clear character
115 | this.blocks.forEach(block => {
116 | this.clearCharacter({ blockIndex: block.index });
117 | });
118 | }
119 |
120 | // toggle cursor blink
121 | blinkCursor({ blockIndex = 0, stop = false } = {}) {
122 | const block = find(this.blocks, { index: blockIndex });
123 |
124 | // if block is not found with the block index, return
125 | if (!block) {
126 | return;
127 | }
128 |
129 | // if cursor is already active on a block, stop it first
130 | if (this.activeBlockIndex !== null) {
131 | const activeBlock = find(this.blocks, { index: this.activeBlockIndex });
132 | activeBlock.toggleCursorBlink(true);
133 | }
134 |
135 | // toggle cursor blink on a block
136 | this.activeBlockIndex = blockIndex;
137 | block.toggleCursorBlink(stop);
138 | }
139 | }
--------------------------------------------------------------------------------
/src/lib/pixel.js:
--------------------------------------------------------------------------------
1 | export class Pixel {
2 | constructor({ canvas, index, size, color, offset } = {}) {
3 | this.canvas = canvas; // canvas element
4 | this.index = index; // index of the pixel
5 | this.size = size; // size of each pixel
6 | this.color = color; // color of pixels
7 | this.offset = offset; // position of the container block from the canvas
8 | this.gutter = Pixel.getGutterSize(size);
9 |
10 | // set pixel position
11 | this.setPosition();
12 |
13 | // blink interval
14 | this.blinkInterval = null;
15 | this.isVisible = false;
16 | }
17 |
18 | /*****************************************/
19 |
20 | // get gutter size : separation between each pixels
21 | static getGutterSize(pixelSize) {
22 | return Math.ceil(pixelSize / 4);
23 | }
24 |
25 | /*****************************************/
26 |
27 | // get position of the pixel relative to the block
28 | setPosition() {
29 | // horizontal and vertical index
30 | const hIndex = this.index % 5;
31 | const vIndex = Math.floor(this.index / 5);
32 |
33 | // relative X position to the block = (horizontal index * size) + (horizontal index * gutter)
34 | const posX = hIndex * this.size + hIndex * this.gutter;
35 |
36 | // relative Y position to the block = (vertical index * size) + (vertical index * gutter)
37 | const posY = vIndex * this.size + vIndex * this.gutter;
38 |
39 | // absolute position to the canvas
40 | this.x = this.offset.x + posX;
41 | this.y = this.offset.y + posY;
42 | }
43 |
44 | // render pixel based on `isActive` value
45 | render(isActive = true) {
46 | const ctx = this.canvas.getContext("2d");
47 |
48 | // set fill style (color)
49 | ctx.fillStyle = this.color;
50 |
51 | if (isActive) {
52 | ctx.fillRect(this.x, this.y, this.size, this.size);
53 | this.isVisible = true;
54 | } else {
55 | ctx.clearRect(this.x, this.y, this.size, this.size);
56 | ctx.fillStyle = "rgba(0,0,0,0.025)"; // dim backlight effecr
57 | ctx.fillRect(this.x, this.y, this.size, this.size);
58 | this.isVisible = false;
59 | }
60 | }
61 |
62 | // blink pixel
63 | blink(stop = false) {
64 | if (stop && this.blinkInterval) {
65 | clearInterval(this.blinkInterval);
66 | this.blinkInterval = null;
67 | this.render(false); // hide pixel
68 | } else {
69 | if (!this.blinkInterval) {
70 | this.blinkInterval = setInterval(() => {
71 | if (this.isVisible) {
72 | this.render(false); // show pixel
73 | } else {
74 | this.render(true); // hide pixel
75 | }
76 | }, 300);
77 | }
78 | }
79 | }
80 | }
--------------------------------------------------------------------------------
/src/scss/styles.scss:
--------------------------------------------------------------------------------
1 | // plugin level css
2 | .lcd-container {
3 | padding: 20px 30px;
4 | background-color: #c7e736;
5 | color: red;
6 | display: inline-block;
7 | font-size: 0px;
8 | border: 10px solid #000;
9 | border-left-width: 14px;
10 | border-right-width: 14px;
11 | box-shadow: inset 0 0 30px rgba( #000, 0.3 ), 0 10px 15px -5px rgba( #000, 0.5 );
12 | border-radius: 3px;
13 | overflow: hidden;
14 | }
--------------------------------------------------------------------------------
/src/util/common.js:
--------------------------------------------------------------------------------
1 | // pad left zeros to a binary number to achieve certain length
2 | export const padLeftZeros = (binaryString, desiredLength) => {
3 | const zerosString = Array(desiredLength).fill("0").join(0);
4 | const finalString = zerosString + binaryString;
5 |
6 | return finalString.slice(-desiredLength);
7 | };
--------------------------------------------------------------------------------
/webpack.config.js:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 | const webpack = require('webpack');
3 | const HTMLWebpackPlugin = require('html-webpack-plugin');
4 | const config = require('config');
5 |
6 | /*-------------------------------------------------*/
7 |
8 | module.exports = {
9 | // webpack optimization mode
10 | mode: ( process.env.NODE_ENV ? process.env.NODE_ENV : 'development' ),
11 |
12 | // entry file(s)
13 | entry: './src/index.js',
14 |
15 | // output file(s) and chunks
16 | output: {
17 | library: 'LCD',
18 | libraryTarget: 'umd',
19 | libraryExport: 'default',
20 | path: path.resolve(__dirname, 'dist'),
21 | filename: 'index.js',
22 | publicPath: config.get('publicPath')
23 | },
24 |
25 | // module/loaders configuration
26 | module: {
27 | rules: [
28 | {
29 | test: /\.js$/,
30 | exclude: /node_modules/,
31 | use: ['babel-loader']
32 | },
33 | {
34 | test: /\.scss$/,
35 | use: ['style-loader', 'css-loader', 'postcss-loader', 'sass-loader']
36 | }
37 | ]
38 | },
39 |
40 | plugins: [
41 | new HTMLWebpackPlugin({
42 | template: path.resolve(__dirname, 'index.html')
43 | })
44 | ],
45 |
46 | // development server configuration
47 | devServer: {
48 |
49 | // must be `true` for SPAs
50 | historyApiFallback: true,
51 |
52 | // open browser on server start
53 | open: config.get('open')
54 | },
55 |
56 | // generate source map
57 | devtool: ( 'production' === process.env.NODE_ENV ? 'source-map' : 'cheap-module-eval-source-map' ),
58 | };
59 |
--------------------------------------------------------------------------------