markuno_lib 1.0.20 → 1.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/bus_utils.js +1 -0
- package/bin/proto.js +1 -0
- package/package.json +2 -2
package/bin/bus_utils.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
let t=1e3;function myuuid(){return t++,t}function getdim(t,e,a,i,r,n,m,s,o){let g,u=[];function getsingledim(t,e,a){return t||(t=e),e?"X"==(a=(a||"_").trim().toLowerCase())&&t!=e?t+"*":"M"==a?t+"M":t:t}return g=getsingledim(t,i,m),g&&u.push(g),g=getsingledim(e,r,s),g&&u.push(g),g=getsingledim(a,n,o),g&&u.push(g),(""+m+s+o).replace(/[_XM]/gi,""),u.join("x")}function formatDate(t){const e=new Date(t),a=e.getDate().toString().padStart(2,"0"),i=(e.getMonth()+1).toString().padStart(2,"0");return`${e.getFullYear()}-${i}-${a}`}function toDateStr(t){if(!t)return"";"number"==typeof t&&(t=t.toDate());let e=t.getDate(),a=t.getMonth()+1,i=t.getFullYear(),r=t.getHours(),n=t.getMinutes();return e=e<10?"0"+e:e,a=a<10?"0"+a:a,r=r<10?"0"+r:r,n=n<10?"0"+n:n,`${e}/${a}/${i} ${r}:${n}`}const e=new class Bus{constructor(){this.buslist={}}on(t,e){return this.buslist[t]||(this.buslist[t]=[]),this.buslist[t].push(e),this.buslist[t].length-1}emit(t,...e){this.buslist[t]&&this.buslist[t].forEach((t=>t(...e)))}off(t,e){this.buslist[t]&&("number"==typeof e?e>=0&&e<this.buslist[t].length&&this.buslist[t].splice(e,1):this.buslist[t]=this.buslist[t].filter((t=>t!==e)))}$on(t,e){this.on(t,e)}$off(t,e){this.off(t,e)}$emit(t,...e){this.emit(t,...e)}};function listfromstring(t){if(Array.isArray(t))return t;var e=[],a={};if(t){var i=t.split(/[\n;\,]/);for(var r of i){var n,m,s=r.search(/[\:=#]/);s<0?n=m=r.trim():(n=r.slice(0,s),m=r.slice(s+1)),(n=n.toLowerCase())&&!a[n]&&(a[n]=1,e.push({cod:n,des:m}))}}return e}e.messaggio=t=>e.emit("messaggio",t),e.warning=t=>e.emit("warning",t),e.errore=t=>e.emit("error",t),e.salvato=t=>e.emit("messaggio","dati memorizzati!"),e.wait=t=>e.emit("wait",t);var tonum=(t,e=-1)=>{if(!t)return 0;if("number"==typeof t)return t||0;let a=0;if("string"==typeof t){let e=(t=t.replaceAll(",",".")).match(/^-?[0-9.]+$/g);if(e&&e.length>0)a=Number(e[0]);else if(/^\s*\-?\s*[0-9]+(\.[0-9]+)?\s*$/gi.test(t))a=parseFloat(t);else if(/[\s\d\(\)\-\+\/\*\^\.]+/gi.test(t))try{a=new Function(`${baseeval} (${t})`)()}catch{a=0}}if(e>=0){const t=Math.pow(10,e);a=Math.round(a*t)/t}return a||0},toEuro=(t,e,a="")=>0==t?e||"":new Intl.NumberFormat("it-IT",{style:"currency",currency:"EUR"}).format(tonum(t))+a;function _(t,e="",a=!1){return t}let a={};var strDate=(t,e)=>{Date.prototype.getWeek||(Date.prototype.getWeek=function(){var t=new Date(this.getFullYear(),0,1);return Math.ceil(((this-t)/864e5+t.getDay()+1)/7)});var i="it";if("object"!=typeof t){if(!(t=parseFloat(t||0)))return"";t=t.toDate()}if("week"==e)return"w"+t.getWeek();if(!a[e])switch(e){case"giorni":if(!x)return"";var r=x.diffgiorni((new Date).toInt());return 0==r?"Oggi":-1==r?"Domani":1==r?"Ieri":Math.abs(r)<6?new Intl.DateTimeFormat(i,{weekday:"long"}).format(t).trim():strDate(x,"ggmmm");case"date":case"shortdate":a[e]=new Intl.DateTimeFormat(i,{weekday:"short",day:"numeric",month:"short",year:"numeric"});break;case"ggmmaa":case"ggmmyy":a[e]=new Intl.DateTimeFormat(i,{day:"2-digit",month:"2-digit",year:"2-digit"});break;case"datetime":a[e]=new Intl.DateTimeFormat(i,{day:"2-digit",month:"2-digit",year:"numeric",hour12:!1,hour:"numeric",minute:"2-digit"});break;case"yyyy":case"anno":a[e]=new Intl.DateTimeFormat(i,{year:"numeric"});break;case"ggmmaaaa":case"ggmmyyyy":a[e]=new Intl.DateTimeFormat(i,{day:"2-digit",month:"2-digit",year:"numeric"});break;case"ggmm":a[e]=new Intl.DateTimeFormat(i,{day:"2-digit",month:"2-digit"});break;case"giorno":case"gg":a[e]=new Intl.DateTimeFormat(i,{day:"2-digit"});break;case"ggmmmaaaa":case"ggmmmyyyy":a[e]=new Intl.DateTimeFormat(i,{day:"2-digit",month:"short",year:"numeric"});break;case"ggmmmaa":case"ggmmmyy":a[e]=new Intl.DateTimeFormat(i,{day:"2-digit",month:"short",year:"2-digit"});break;case"ggmmm":a[e]=new Intl.DateTimeFormat(i,{day:"2-digit",month:"short"});break;case"ggmmmm":a[e]=new Intl.DateTimeFormat(i,{day:"2-digit",month:"long"});break;case"mmmyy":case"mmmaa":case"mmmyyyy":case"mmmaaaa":a[e]=new Intl.DateTimeFormat(i,{month:"short",year:"numeric"});break;case"weekday":a[e]=new Intl.DateTimeFormat(i,{weekday:"long"});break;case"hhmm":a[e]=new Intl.DateTimeFormat(i,{hour12:!1,hour:"numeric",minute:"2-digit"});break;case"hhmmss":a[e]=new Intl.DateTimeFormat(i,{hour12:!1,hour:"numeric",minute:"2-digit",second:"2-digit"});break;case"mese":a[e]=new Intl.DateTimeFormat(i,{month:"long"});break;default:a[e="."]||(a[e]=new Intl.DateTimeFormat(i,{weekday:"long",day:"numeric",month:"long",year:"numeric",hour12:!1,hour:"numeric",minute:"2-digit"}))}return a[e].format(t).trim()};export{_,e as bus,formatDate,getdim,listfromstring,myuuid,strDate,toDateStr,toEuro,tonum};
|
package/bin/proto.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
if(Date.prototype.getWeek||(Date.prototype.getWeek=function(){var t=new Date(this.getFullYear(),0,1);return Math.ceil(((this-t)/864e5+t.getDay()-1)/7)},Date.prototype.getYWeek=function(){var t=new Date(this.getFullYear(),0,1);return 100*this.getFullYear()+Math.ceil(((this-t)/864e5+t.getDay()-1)/7)}),!Number.prototype.toDate){const toDate=t=>{var e,o,r,n,i,u,a,s,p;return e=t,o=Math.floor(e),r=Math.floor(1e6*(e-o)+.8),(n=o%100)<1&&(n=1),(i=(o=Math.floor(o/100))%100)<1&&(i=1),(u=Math.floor(o/100))<1900&&(u=1900),p=r%100,s=(r=Math.floor(r/100))%100,a=Math.floor(r/100),new Date(u,i-1,n,a,s,p)};Number.prototype.toDate=function(){return toDate(this.valueOf()+0)},Date.prototype.toInt||(Date.prototype.toInt=function(){const t=this;return t.getDate()+100*(t.getMonth()+1)+1e4*t.getFullYear()}),Date.prototype.toFloat||(Date.prototype.toFloat=function(){return Math.floor(1e4*this.getDate()+1e6*(this.getMonth()+1)+1e8*this.getFullYear()+100*this.getHours()+this.getMinutes()+.5)/1e4}),Number.prototype.addmesi=function(t){const e=toDate(this.valueOf()+0),o=e.getDate();return e.setMonth(e.getMonth()+t),o>20&&e.getDate()<10&&e.setDate(0),Math.floor(this)===this?e.toInt():e.toFloat()},Number.prototype.addgiorni=function(t=0,e=0,o=0){const r=new Date(this.toDate().valueOf()+6e4*t*24*60+6e4*e*60+o);return Math.floor(this)===this?r.toInt():r.toFloat()},Number.prototype.diffgiorni=function(t){const e=toDate(this.valueOf()+0),o=toDate(t);return Math.ceil((o-e)/864e5)},Number.prototype.diffore=function(t){const e=toDate(this.valueOf()+0),o=toDate(t);return Math.ceil((o-e)/36e5)},Number.prototype.diffminuti=function(t){const e=toDate(this.valueOf()+0),o=toDate(t);return Math.ceil((o-e)/6e4)},Number.prototype.finemese=function(){return new Date(new Date(new Date(this.toDate().setDate(1)).setDate(32)).setDate(0)).toInt()},Number.prototype.iniziomese=function(){return new Date(this.toDate().setDate(1)).toInt()},Number.prototype.fineanno=function(){return 1e4*Math.floor(this/1e4)+1231},Number.prototype.inizioanno=function(){return 1e4*Math.floor(this/1e4)+101},Number.prototype.clamp=function(t,e){return this<t?t:this>e?e:this},Number.prototype.dgiorno=function(){return Math.floor(this)%100},Number.prototype.dmese=function(){return Math.floor(this/100)%100},Number.prototype.danno=function(){return Math.floor(this/1e4)},Number.prototype.weekday=function(){return toDate(this).getDay()},Number.prototype.giornimese=function(){return this.finemese()%100},Number.prototype.week=function(){return toDate(this).getWeek()},Number.prototype.yweek=function(){return toDate(this).getYWeek()},Array.prototype.random=function(){return this[Math.floor(Math.random()*this.length)]},Array.prototype.shuffle=function(){let t=this,e=t.length;for(;e>0;){let o=Math.floor(Math.random()*e);e--;let r=t[e];t[e]=t[o],t[o]=r}return t},Number.random=function(t,e){if(void 0===t)return Math.random();if(void 0===e)return Math.random()*t;if(t>e){var o=t;t=e,e=o}return Math.random()*(e-t)+t},Number.prototype.int=Number.prototype.floor=function(){return isNaN(this)||!isFinite(this)?0:Math.floor(this)},Number.prototype.round=function(){return isNaN(this)||!isFinite(this)?0:Math.floor(this+.5)},Number.prototype.ceil=function(){return isNaN(this)||!isFinite(this)?0:Math.ceil(this)}}String.prototype.splitComma||(String.prototype.splitComma=function(){return(this||"").split(/[;,]+/)}),String.prototype.lines||(String.prototype.lines=function(){return(this||"").split(/[\r\n]+/)}),String.prototype.var||(String.prototype.var=function(t,e){if(e||(e=";"),t){t=t.toLowerCase();const o=this.split(e);for(let e=0;e<o.length;e++){const r=o[e].indexOf("=");if(r>0){if(o[e].substr(0,r).toLowerCase()===t)return o[e].substr(r+1,9999)}}}return""}),String.prototype.setvar||(String.prototype.setvar=function(t,e,o){if(o||(o=";"),t){t=t.toUpperCase();const r=this.split(o);for(let n=0;n<r.length;n++){const i=r[n].indexOf("=");if(i>0){if(r[n].substr(0,i).toUpperCase()===t)return e?r[n]=t+"="+e:r.splice(n,1),r.join(o)}}}return e?this+o+t+"="+e:this});
|