markuno_lib 1.2.83 → 1.2.85

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/proto.js CHANGED
@@ -1,184 +1 @@
1
- /**
2
- * Estende il prototipo di Date con metodi per calcolare il numero della settimana
3
- */
4
- if(Date.prototype.getWeek||(
5
- /**
6
- * Calcola il numero della settimana nell'anno corrente
7
- * @returns {number} Numero della settimana (1-53)
8
- */
9
- Date.prototype.getWeek=function(){let onejan=new Date(this.getFullYear(),0,1);return Math.ceil(((this-onejan)/864e5+onejan.getDay()-1)/7)},
10
- /**
11
- * Calcola l'anno e il numero della settimana come numero intero (YYYYWW)
12
- * @returns {number} Anno e settimana nel formato YYYYWW
13
- */
14
- Date.prototype.getYWeek=function(){let onejan=new Date(this.getFullYear(),0,1);return 100*this.getFullYear()+Math.ceil(((this-onejan)/864e5+onejan.getDay()-1)/7)}),!Number.prototype.toDate){
15
- /**
16
- * Converte un numero nel formato YYYYMMDDHHMMSS in un oggetto Date
17
- * @param {number} nn - Numero da convertire
18
- * @returns {Date} Data convertita
19
- */
20
- const toDate=nn=>{let xx,x1,x2,d,m,y,hh,mm,ss;return xx=nn,x1=Math.floor(xx),x2=Math.floor(1e6*(xx-x1)+.8),d=x1%100,d<1&&(d=1),x1=Math.floor(x1/100),m=x1%100,m<1&&(m=1),y=Math.floor(x1/100),y<1900&&(y=1900),ss=x2%100,x2=Math.floor(x2/100),mm=x2%100,hh=Math.floor(x2/100),new Date(y,m-1,d,hh,mm,ss)};
21
- /**
22
- * Converte un numero in un oggetto Date
23
- * @returns {Date} Data convertita
24
- */Number.prototype.toDate=function(){return toDate(this.valueOf()+0)},Date.prototype.toInt||(
25
- /**
26
- * Converte una data in un numero intero nel formato YYYYMMDD
27
- * @returns {number} Data come numero intero
28
- */
29
- Date.prototype.toInt=function(){return this.getDate()+100*(this.getMonth()+1)+1e4*this.getFullYear()}),Date.prototype.toFloat||(
30
- /**
31
- * Converte una data in un numero float nel formato YYYYMMDD.HHMM
32
- * @returns {number} Data come numero float
33
- */
34
- Date.prototype.toFloat=function(){return Math.floor(1e4*this.getDate()+1e6*(this.getMonth()+1)+1e8*this.getFullYear()+100*this.getHours()+this.getMinutes()+.5)/1e4})
35
- /**
36
- * Aggiunge o sottrae mesi alla data
37
- * @param {number} value - Numero di mesi da aggiungere (negativo per sottrarre)
38
- * @returns {number} Nuova data nel formato originale
39
- */,Number.prototype.addmesi=function(value){const mm=toDate(this.valueOf()+0),n=mm.getDate();return mm.setMonth(mm.getMonth()+value),n>20&&mm.getDate()<10&&mm.setDate(0),Math.floor(this)===this?mm.toInt():mm.toFloat()},
40
- /**
41
- * Aggiunge giorni, ore e minuti alla data
42
- * @param {number} days - Giorni da aggiungere
43
- * @param {number} ore - Ore da aggiungere
44
- * @param {number} minuti - Minuti da aggiungere
45
- * @returns {number} Nuova data nel formato originale
46
- */
47
- Number.prototype.addgiorni=function(days=0,ore=0,minuti=0){const date=new Date(this.toDate().valueOf()+6e4*days*24*60+6e4*ore*60+minuti);return Math.floor(this)===this?date.toInt():date.toFloat()},
48
- /**
49
- * Calcola la differenza in giorni tra due date
50
- * @param {number} d1 - Data di confronto
51
- * @returns {number} Differenza in giorni
52
- */
53
- Number.prototype.diffgiorni=function(d1){const date1=toDate(this.valueOf()+0),date2=toDate(d1);return Math.ceil((date2-date1)/864e5)},
54
- /**
55
- * Calcola la differenza in ore tra due date
56
- * @param {number} d1 - Data di confronto
57
- * @returns {number} Differenza in ore
58
- */
59
- Number.prototype.diffore=function(d1){const date1=toDate(this.valueOf()+0),date2=toDate(d1);return Math.ceil((date2-date1)/36e5)},
60
- /**
61
- * Calcola la differenza in minuti tra due date
62
- * @param {number} d1 - Data di confronto
63
- * @returns {number} Differenza in minuti
64
- */
65
- Number.prototype.diffminuti=function(d1){const date1=toDate(this.valueOf()+0),date2=toDate(d1);return Math.ceil((date2-date1)/6e4)},
66
- /**
67
- * Calcola l'ultimo giorno del mese della data
68
- * @returns {number} Data dell'ultimo giorno del mese
69
- */
70
- Number.prototype.finemese=function(){return new Date(new Date(new Date(this.toDate().setDate(1)).setDate(32)).setDate(0)).toInt()},
71
- /**
72
- * Calcola il primo giorno del mese della data
73
- * @returns {number} Data del primo giorno del mese
74
- */
75
- Number.prototype.iniziomese=function(){return new Date(this.toDate().setDate(1)).toInt()},
76
- /**
77
- * Calcola l'ultimo giorno dell'anno della data
78
- * @returns {number} Data dell'ultimo giorno dell'anno (31/12)
79
- */
80
- Number.prototype.fineanno=function(){return 1e4*Math.floor(this/1e4)+1231},
81
- /**
82
- * Calcola il primo giorno dell'anno della data
83
- * @returns {number} Data del primo giorno dell'anno (01/01)
84
- */
85
- Number.prototype.inizioanno=function(){return 1e4*Math.floor(this/1e4)+101},
86
- /**
87
- * Limita un numero tra due valori
88
- * @param {number} v1 - Valore minimo
89
- * @param {number} v2 - Valore massimo
90
- * @returns {number} Numero limitato tra v1 e v2
91
- */
92
- Number.prototype.clamp=function(v1,v2){return this<v1?v1:this>v2?v2:this},
93
- /**
94
- * Estrae il giorno da una data numerica
95
- * @returns {number} Giorno del mese (1-31)
96
- */
97
- Number.prototype.dgiorno=function(){return Math.floor(this)%100},
98
- /**
99
- * Estrae il mese da una data numerica
100
- * @returns {number} Mese (1-12)
101
- */
102
- Number.prototype.dmese=function(){return Math.floor(this/100)%100},
103
- /**
104
- * Estrae l'anno da una data numerica
105
- * @returns {number} Anno
106
- */
107
- Number.prototype.danno=function(){return Math.floor(this/1e4)},
108
- /**
109
- * Calcola il giorno della settimana
110
- * @returns {number} Giorno della settimana (0-6, 0=domenica)
111
- */
112
- Number.prototype.weekday=function(){return toDate(this).getDay()},
113
- /**
114
- * Calcola il numero di giorni nel mese della data
115
- * @returns {number} Numero di giorni nel mese
116
- */
117
- Number.prototype.giornimese=function(){return this.finemese()%100},
118
- /**
119
- * Calcola il numero della settimana nell'anno
120
- * @returns {number} Numero della settimana (1-53)
121
- */
122
- Number.prototype.week=function(){return toDate(this).getWeek()},
123
- /**
124
- * Calcola l'anno e la settimana come numero
125
- * @returns {number} Anno e settimana nel formato YYYYWW
126
- */
127
- Number.prototype.yweek=function(){return toDate(this).getYWeek()},
128
- /**
129
- * Restituisce un elemento casuale dall'array
130
- * @returns {*} Elemento casuale
131
- */
132
- Array.prototype.random=function(){return this[Math.floor(Math.random()*this.length)]},
133
- /**
134
- * Mescola casualmente gli elementi dell'array
135
- * @returns {Array} Array mescolato
136
- */
137
- Array.prototype.shuffle=function(){let array=this,counter=array.length;for(;counter>0;){let index=Math.floor(Math.random()*counter);counter--;let temp=array[counter];array[counter]=array[index],array[index]=temp}return array},
138
- /**
139
- * Genera un numero casuale
140
- * @param {number} [min] - Valore minimo
141
- * @param {number} [max] - Valore massimo
142
- * @returns {number} Numero casuale
143
- */
144
- Number.random=function(min,max){if(void 0===min)return Math.random();if(void 0===max)return Math.random()*min;if(min>max){let tmp=min;min=max,max=tmp}return Math.random()*(max-min)+min},
145
- /**
146
- * Arrotonda per difetto un numero
147
- * @returns {number} Numero arrotondato per difetto
148
- */
149
- Number.prototype.int=Number.prototype.floor=function(){return isNaN(this)||!isFinite(this)?0:Math.floor(this)},
150
- /**
151
- * Arrotonda un numero al più vicino
152
- * @returns {number} Numero arrotondato
153
- */
154
- Number.prototype.round=function(){return isNaN(this)||!isFinite(this)?0:Math.floor(this+.5)},
155
- /**
156
- * Arrotonda per eccesso un numero
157
- * @returns {number} Numero arrotondato per eccesso
158
- */
159
- Number.prototype.ceil=function(){return isNaN(this)||!isFinite(this)?0:Math.ceil(this)}}String.prototype.splitComma||(
160
- /**
161
- * Divide una stringa usando virgola o punto e virgola come separatori
162
- * @returns {string[]} Array di sottostringhe
163
- */
164
- String.prototype.splitComma=function(){return(this||"").split(/[;,]+/)}),String.prototype.lines||(
165
- /**
166
- * Divide una stringa in righe
167
- * @returns {string[]} Array di righe
168
- */
169
- String.prototype.lines=function(){return(this||"").split(/[\r\n]+/)}),String.prototype.var||(
170
- /**
171
- * Estrae il valore di una variabile da una stringa formattata
172
- * @param {string} name - Nome della variabile
173
- * @param {string} [sep] - Separatore (default: ';')
174
- * @returns {string} Valore della variabile o stringa vuota
175
- */
176
- String.prototype.var=function(name,sep){if(sep||(sep=";"),name){name=name.toLowerCase();const v=this.split(sep);for(let i=0;i<v.length;i++){const q=v[i].indexOf("=");if(q>0){if(v[i].substr(0,q).toLowerCase()===name)return v[i].substr(q+1,9999)}}}return""}),String.prototype.setvar||(
177
- /**
178
- * Imposta il valore di una variabile in una stringa formattata
179
- * @param {string} name - Nome della variabile
180
- * @param {string} value - Valore da impostare
181
- * @param {string} [sep] - Separatore (default: ';')
182
- * @returns {string} Stringa aggiornata
183
- */
184
- String.prototype.setvar=function(name,value,sep){if(sep||(sep=";"),name){name=name.toUpperCase();const v=this.split(sep);for(let i=0;i<v.length;i++){const q=v[i].indexOf("=");if(q>0){if(v[i].substr(0,q).toUpperCase()===name)return value?v[i]=name+"="+value:v.splice(i,1),v.join(sep)}}}return value?this+sep+name+"="+value:this});
1
+ if(Date.prototype.getWeek||(Date.prototype.getWeek=function(){let t=new Date(this.getFullYear(),0,1);return Math.ceil(((this-t)/864e5+t.getDay()-1)/7)},Date.prototype.getYWeek=function(){let 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=>{let e,o,r,n,i,u,s,a,p;return e=t,o=Math.floor(e),r=Math.floor(1e6*(e-o)+.8),n=o%100,n<1&&(n=1),o=Math.floor(o/100),i=o%100,i<1&&(i=1),u=Math.floor(o/100),u<1900&&(u=1900),p=r%100,r=Math.floor(r/100),a=r%100,s=Math.floor(r/100),new Date(u,i-1,n,s,a,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){let 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});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markuno_lib",
3
- "version": "1.2.83",
3
+ "version": "1.2.85",
4
4
  "description": "Croswil Markuno Language Lib",
5
5
  "author": "Croswil SRL",
6
6
  "license": "SEE LICENSE IN LICENSE.txt",
@@ -1,48 +1,18 @@
1
- /**
2
- * Implementa un sistema di eventi publish/subscribe
3
- */ export const bus: {
1
+ declare const e: {
4
2
  buslist: {};
5
- /**
6
- * Registra un handler per un evento
7
- * @param {string} des - Nome dell'evento
8
- * @param {Function} func - Handler da eseguire
9
- * @returns {number} Indice dell'handler nella lista
10
- */ on(des: string, func: Function): number;
11
- /**
12
- * Emette un evento con i relativi parametri
13
- * @param {string} des - Nome dell'evento
14
- * @param {...any} args - Parametri da passare agli handler
15
- */ emit(des: string, ...args: any[]): void;
16
- /**
17
- * Rimuove un handler per un evento
18
- * @param {string} des - Nome dell'evento
19
- * @param {Function|number} func - Handler da rimuovere o suo indice
20
- */ off(des: string, func: Function | number): void;
21
- $on(des: any, func: any): void;
22
- $off(des: any, func: any): void;
23
- $emit(des: any, ...args: any[]): void;
3
+ on(t: any, e: any): number;
4
+ emit(t: any, ...e: any[]): void;
5
+ off(t: any, e: any): void;
6
+ $on(t: any, e: any): void;
7
+ $off(t: any, e: any): void;
8
+ $emit(t: any, ...e: any[]): void;
24
9
  };
25
- /**
26
- * Formatta una data nel formato YYYY-MM-DD
27
- * @param {string|Date} dateString - La data da formattare
28
- * @returns {string} La data formattata come YYYY-MM-DD
29
- */ export function formatDate(dateString: string | Date): string;
30
- export function getdim(l: any, a: any, p: any, al: any, aa: any, ap: any, fmodl: any, fmoda: any, fmodp: any): string;
31
- /**
32
- * Converte una stringa delimitata in array di oggetti {cod, des}
33
- * @param {string|Array} x - Stringa con valori delimitati da \n ; o ,
34
- * @returns {Array<{cod: string, des: string}>} Array di oggetti con codice e descrizione
35
- */
36
- export function listfromstring(x: string | any[]): Array<{
37
- cod: string;
38
- des: string;
39
- }>;
10
+ export function formatDate(t: any): string;
11
+ export function getdim(t: any, e: any, i: any, a: any, r: any, n: any, m: any, s: any, o: any): string;
12
+ export function listfromstring(t: any): any[];
40
13
  export function myuuid(): number;
41
- export function strDate(date: any, formato: any): any;
42
- /**
43
- * Converte una data nel formato DD/MM/YYYY HH:mm
44
- * @param {Date|number} date - La data da convertire
45
- * @returns {string} La data formattata come DD/MM/YYYY HH:mm
46
- */ export function toDateStr(date: Date | number): string;
47
- export function toEuro(n: any, gratis: any, des?: string): any;
48
- export function tonum(s: any, dec?: number): number;
14
+ export function strDate(t: any, e: any): any;
15
+ export function toDateStr(t: any): string;
16
+ export function toEuro(t: any, e: any, i?: string): any;
17
+ export function tonum(t: any, e?: number): number;
18
+ export { e as bus };