@osimatic/helpers-js 1.0.6 → 1.0.9

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/location.js CHANGED
@@ -1,251 +1,4 @@
1
1
 
2
- const COUNTRIES_LIST = {
3
- AF:'Afghanistan',
4
- AX:'Åland Islands',
5
- AL:'Albania',
6
- DZ:'Algeria',
7
- AS:'American Samoa',
8
- AD:'Andorra',
9
- AO:'Angola',
10
- AI:'Anguilla',
11
- AQ:'Antarctica',
12
- AG:'Antigua and Barbuda',
13
- AR:'Argentina',
14
- AM:'Armenia',
15
- AW:'Aruba',
16
- AU:'Australia',
17
- AT:'Austria',
18
- AZ:'Azerbaijan',
19
- BS:'Bahamas',
20
- BH:'Bahrain',
21
- BD:'Bangladesh',
22
- BB:'Barbados',
23
- BY:'Belarus',
24
- BE:'Belgium',
25
- BZ:'Belize',
26
- BJ:'Benin',
27
- BM:'Bermuda',
28
- BT:'Bhutan',
29
- BO:'Bolivia',
30
- BA:'Bosnia and Herzegovina',
31
- BW:'Botswana',
32
- BV:'Bouvet Island',
33
- BR:'Brazil',
34
- IO:'British Indian Ocean Territory',
35
- BN:'Brunei Darussalam',
36
- BG:'Bulgaria',
37
- BF:'Burkina Faso',
38
- BI:'Burundi',
39
- KH:'Cambodia',
40
- CM:'Cameroon',
41
- CA:'Canada',
42
- CV:'Cape Verde',
43
- KY:'Cayman Islands',
44
- CF:'Central African Republic',
45
- TD:'Chad',
46
- CL:'Chile',
47
- CN:'China',
48
- CX:'Christmas Island',
49
- CC:'Cocos (Keeling) Islands',
50
- CO:'Colombia',
51
- KM:'Comoros',
52
- CG:'Congo',
53
- CD:'Congo, The Democratic Republic of The',
54
- CK:'Cook Islands',
55
- CR:'Costa Rica',
56
- CI:'Cote d’Ivoire',
57
- HR:'Croatia',
58
- CU:'Cuba',
59
- CY:'Cyprus',
60
- CZ:'Czechia',
61
- DK:'Denmark',
62
- DJ:'Djibouti',
63
- DM:'Dominica',
64
- DO:'Dominican Republic',
65
- EC:'Ecuador',
66
- EG:'Egypt',
67
- SV:'El Salvador',
68
- GQ:'Equatorial Guinea',
69
- ER:'Eritrea',
70
- EE:'Estonia',
71
- ET:'Ethiopia',
72
- FK:'Falkland Islands (Malvinas)',
73
- FO:'Faroe Islands',
74
- FJ:'Fiji',
75
- FI:'Finland',
76
- FR:'France',
77
- GF:'French Guiana',
78
- PF:'French Polynesia',
79
- TF:'French Southern Territories',
80
- GA:'Gabon',
81
- GM:'Gambia',
82
- GE:'Georgia',
83
- DE:'Germany',
84
- GH:'Ghana',
85
- GI:'Gibraltar',
86
- GR:'Greece',
87
- GL:'Greenland',
88
- GD:'Grenada',
89
- GP:'Guadeloupe',
90
- GU:'Guam',
91
- GT:'Guatemala',
92
- GG:'Guernsey',
93
- GN:'Guinea',
94
- GW:'Guinea-bissau',
95
- GY:'Guyana',
96
- HT:'Haiti',
97
- HM:'Heard Island and Mcdonald Islands',
98
- VA:'Holy See (Vatican City State)',
99
- HN:'Honduras',
100
- HK:'Hong Kong',
101
- HU:'Hungary',
102
- IS:'Iceland',
103
- IN:'India',
104
- ID:'Indonesia',
105
- IR:'Iran, Islamic Republic of',
106
- IQ:'Iraq',
107
- IE:'Ireland',
108
- IM:'Isle of Man',
109
- IL:'Israel',
110
- IT:'Italy',
111
- JM:'Jamaica',
112
- JP:'Japan',
113
- JE:'Jersey',
114
- JO:'Jordan',
115
- KZ:'Kazakhstan',
116
- KE:'Kenya',
117
- KI:'Kiribati',
118
- KP:'Korea, Democratic People’s Republic of',
119
- KR:'Korea, Republic of',
120
- KW:'Kuwait',
121
- KG:'Kyrgyzstan',
122
- LA:'Lao People’s Democratic Republic',
123
- LV:'Latvia',
124
- LB:'Lebanon',
125
- LS:'Lesotho',
126
- LR:'Liberia',
127
- LY:'Libyan Arab Jamahiriya',
128
- LI:'Liechtenstein',
129
- LT:'Lithuania',
130
- LU:'Luxembourg',
131
- MO:'Macao',
132
- MK:'Macedonia, The Former Yugoslav Republic of',
133
- MG:'Madagascar',
134
- MW:'Malawi',
135
- MY:'Malaysia',
136
- MV:'Maldives',
137
- ML:'Mali',
138
- MT:'Malta',
139
- MH:'Marshall Islands',
140
- MQ:'Martinique',
141
- MR:'Mauritania',
142
- MU:'Mauritius',
143
- YT:'Mayotte',
144
- MX:'Mexico',
145
- FM:'Micronesia, Federated States of',
146
- MD:'Moldova, Republic of',
147
- MC:'Monaco',
148
- MN:'Mongolia',
149
- ME:'Montenegro',
150
- MS:'Montserrat',
151
- MA:'Morocco',
152
- MZ:'Mozambique',
153
- MM:'Myanmar',
154
- NA:'Namibia',
155
- NR:'Nauru',
156
- NP:'Nepal',
157
- NL:'Netherlands',
158
- AN:'Netherlands Antilles',
159
- NC:'New Caledonia',
160
- NZ:'New Zealand',
161
- NI:'Nicaragua',
162
- NE:'Niger',
163
- NG:'Nigeria',
164
- NU:'Niue',
165
- NF:'Norfolk Island',
166
- MP:'Northern Mariana Islands',
167
- NO:'Norway',
168
- OM:'Oman',
169
- PK:'Pakistan',
170
- PW:'Palau',
171
- PS:'Palestinian Territory, Occupied',
172
- PA:'Panama',
173
- PG:'Papua New Guinea',
174
- PY:'Paraguay',
175
- PE:'Peru',
176
- PH:'Philippines',
177
- PN:'Pitcairn',
178
- PL:'Poland',
179
- PT:'Portugal',
180
- PR:'Puerto Rico',
181
- QA:'Qatar',
182
- RE:'Reunion',
183
- RO:'Romania',
184
- RU:'Russian Federation',
185
- RW:'Rwanda',
186
- SH:'Saint Helena',
187
- KN:'Saint Kitts and Nevis',
188
- LC:'Saint Lucia',
189
- PM:'Saint Pierre and Miquelon',
190
- VC:'Saint Vincent and The Grenadines',
191
- WS:'Samoa',
192
- SM:'San Marino',
193
- ST:'Sao Tome and Principe',
194
- SA:'Saudi Arabia',
195
- SN:'Senegal',
196
- RS:'Serbia',
197
- SC:'Seychelles',
198
- SL:'Sierra Leone',
199
- SG:'Singapore',
200
- SK:'Slovakia',
201
- SI:'Slovenia',
202
- SB:'Solomon Islands',
203
- SO:'Somalia',
204
- ZA:'South Africa',
205
- GS:'South Georgia and The South Sandwich Islands',
206
- ES:'Spain',
207
- LK:'Sri Lanka',
208
- SD:'Sudan',
209
- SR:'Suriname',
210
- SJ:'Svalbard and Jan Mayen',
211
- SZ:'Swaziland',
212
- SE:'Sweden',
213
- CH:'Switzerland',
214
- SY:'Syrian Arab Republic',
215
- TW:'Taiwan, Province of China',
216
- TJ:'Tajikistan',
217
- TZ:'Tanzania, United Republic of',
218
- TH:'Thailand',
219
- TL:'Timor-leste',
220
- TG:'Togo',
221
- TK:'Tokelau',
222
- TO:'Tonga',
223
- TT:'Trinidad and Tobago',
224
- TN:'Tunisia',
225
- TR:'Turkey',
226
- TM:'Turkmenistan',
227
- TC:'Turks and Caicos Islands',
228
- TV:'Tuvalu',
229
- UG:'Uganda',
230
- UA:'Ukraine',
231
- AE:'United Arab Emirates',
232
- GB:'United Kingdom',
233
- US:'United States',
234
- UM:'United States Minor Outlying Islands',
235
- UY:'Uruguay',
236
- UZ:'Uzbekistan',
237
- VU:'Vanuatu',
238
- VE:'Venezuela',
239
- VN:'Viet Nam',
240
- VG:'Virgin Islands, British',
241
- VI:'Virgin Islands, U.S.',
242
- WF:'Wallis and Futuna',
243
- EH:'Western Sahara',
244
- YE:'Yemen',
245
- ZM:'Zambia',
246
- ZW:'Zimbabwe',
247
- };
248
-
249
2
  class Country {
250
3
  static getFlagPath(countryCode) {
251
4
  return flagsPath+countryCode.toLowerCase()+'.png';
@@ -262,13 +15,258 @@ class Country {
262
15
  select.selectpicker('refresh');
263
16
  }
264
17
  static getCountryName(countryCode) {
265
- if (COUNTRIES_LIST.hasOwnProperty(countryCode)) {
266
- return COUNTRIES_LIST[countryCode];
18
+ if (Country.getCountryList().hasOwnProperty(countryCode)) {
19
+ return Country.getCountryList()[countryCode];
267
20
  }
268
21
  return countryCode;
269
22
  }
270
23
  static getCountryList() {
271
- return COUNTRIES_LIST;
24
+ return {
25
+ AF:'Afghanistan',
26
+ AX:'Åland Islands',
27
+ AL:'Albania',
28
+ DZ:'Algeria',
29
+ AS:'American Samoa',
30
+ AD:'Andorra',
31
+ AO:'Angola',
32
+ AI:'Anguilla',
33
+ AQ:'Antarctica',
34
+ AG:'Antigua and Barbuda',
35
+ AR:'Argentina',
36
+ AM:'Armenia',
37
+ AW:'Aruba',
38
+ AU:'Australia',
39
+ AT:'Austria',
40
+ AZ:'Azerbaijan',
41
+ BS:'Bahamas',
42
+ BH:'Bahrain',
43
+ BD:'Bangladesh',
44
+ BB:'Barbados',
45
+ BY:'Belarus',
46
+ BE:'Belgium',
47
+ BZ:'Belize',
48
+ BJ:'Benin',
49
+ BM:'Bermuda',
50
+ BT:'Bhutan',
51
+ BO:'Bolivia',
52
+ BA:'Bosnia and Herzegovina',
53
+ BW:'Botswana',
54
+ BV:'Bouvet Island',
55
+ BR:'Brazil',
56
+ IO:'British Indian Ocean Territory',
57
+ BN:'Brunei Darussalam',
58
+ BG:'Bulgaria',
59
+ BF:'Burkina Faso',
60
+ BI:'Burundi',
61
+ KH:'Cambodia',
62
+ CM:'Cameroon',
63
+ CA:'Canada',
64
+ CV:'Cape Verde',
65
+ KY:'Cayman Islands',
66
+ CF:'Central African Republic',
67
+ TD:'Chad',
68
+ CL:'Chile',
69
+ CN:'China',
70
+ CX:'Christmas Island',
71
+ CC:'Cocos (Keeling) Islands',
72
+ CO:'Colombia',
73
+ KM:'Comoros',
74
+ CG:'Congo',
75
+ CD:'Congo, The Democratic Republic of The',
76
+ CK:'Cook Islands',
77
+ CR:'Costa Rica',
78
+ CI:'Cote d’Ivoire',
79
+ HR:'Croatia',
80
+ CU:'Cuba',
81
+ CY:'Cyprus',
82
+ CZ:'Czechia',
83
+ DK:'Denmark',
84
+ DJ:'Djibouti',
85
+ DM:'Dominica',
86
+ DO:'Dominican Republic',
87
+ EC:'Ecuador',
88
+ EG:'Egypt',
89
+ SV:'El Salvador',
90
+ GQ:'Equatorial Guinea',
91
+ ER:'Eritrea',
92
+ EE:'Estonia',
93
+ ET:'Ethiopia',
94
+ FK:'Falkland Islands (Malvinas)',
95
+ FO:'Faroe Islands',
96
+ FJ:'Fiji',
97
+ FI:'Finland',
98
+ FR:'France',
99
+ GF:'French Guiana',
100
+ PF:'French Polynesia',
101
+ TF:'French Southern Territories',
102
+ GA:'Gabon',
103
+ GM:'Gambia',
104
+ GE:'Georgia',
105
+ DE:'Germany',
106
+ GH:'Ghana',
107
+ GI:'Gibraltar',
108
+ GR:'Greece',
109
+ GL:'Greenland',
110
+ GD:'Grenada',
111
+ GP:'Guadeloupe',
112
+ GU:'Guam',
113
+ GT:'Guatemala',
114
+ GG:'Guernsey',
115
+ GN:'Guinea',
116
+ GW:'Guinea-bissau',
117
+ GY:'Guyana',
118
+ HT:'Haiti',
119
+ HM:'Heard Island and Mcdonald Islands',
120
+ VA:'Holy See (Vatican City State)',
121
+ HN:'Honduras',
122
+ HK:'Hong Kong',
123
+ HU:'Hungary',
124
+ IS:'Iceland',
125
+ IN:'India',
126
+ ID:'Indonesia',
127
+ IR:'Iran, Islamic Republic of',
128
+ IQ:'Iraq',
129
+ IE:'Ireland',
130
+ IM:'Isle of Man',
131
+ IL:'Israel',
132
+ IT:'Italy',
133
+ JM:'Jamaica',
134
+ JP:'Japan',
135
+ JE:'Jersey',
136
+ JO:'Jordan',
137
+ KZ:'Kazakhstan',
138
+ KE:'Kenya',
139
+ KI:'Kiribati',
140
+ KP:'Korea, Democratic People’s Republic of',
141
+ KR:'Korea, Republic of',
142
+ KW:'Kuwait',
143
+ KG:'Kyrgyzstan',
144
+ LA:'Lao People’s Democratic Republic',
145
+ LV:'Latvia',
146
+ LB:'Lebanon',
147
+ LS:'Lesotho',
148
+ LR:'Liberia',
149
+ LY:'Libyan Arab Jamahiriya',
150
+ LI:'Liechtenstein',
151
+ LT:'Lithuania',
152
+ LU:'Luxembourg',
153
+ MO:'Macao',
154
+ MK:'Macedonia, The Former Yugoslav Republic of',
155
+ MG:'Madagascar',
156
+ MW:'Malawi',
157
+ MY:'Malaysia',
158
+ MV:'Maldives',
159
+ ML:'Mali',
160
+ MT:'Malta',
161
+ MH:'Marshall Islands',
162
+ MQ:'Martinique',
163
+ MR:'Mauritania',
164
+ MU:'Mauritius',
165
+ YT:'Mayotte',
166
+ MX:'Mexico',
167
+ FM:'Micronesia, Federated States of',
168
+ MD:'Moldova, Republic of',
169
+ MC:'Monaco',
170
+ MN:'Mongolia',
171
+ ME:'Montenegro',
172
+ MS:'Montserrat',
173
+ MA:'Morocco',
174
+ MZ:'Mozambique',
175
+ MM:'Myanmar',
176
+ NA:'Namibia',
177
+ NR:'Nauru',
178
+ NP:'Nepal',
179
+ NL:'Netherlands',
180
+ AN:'Netherlands Antilles',
181
+ NC:'New Caledonia',
182
+ NZ:'New Zealand',
183
+ NI:'Nicaragua',
184
+ NE:'Niger',
185
+ NG:'Nigeria',
186
+ NU:'Niue',
187
+ NF:'Norfolk Island',
188
+ MP:'Northern Mariana Islands',
189
+ NO:'Norway',
190
+ OM:'Oman',
191
+ PK:'Pakistan',
192
+ PW:'Palau',
193
+ PS:'Palestinian Territory, Occupied',
194
+ PA:'Panama',
195
+ PG:'Papua New Guinea',
196
+ PY:'Paraguay',
197
+ PE:'Peru',
198
+ PH:'Philippines',
199
+ PN:'Pitcairn',
200
+ PL:'Poland',
201
+ PT:'Portugal',
202
+ PR:'Puerto Rico',
203
+ QA:'Qatar',
204
+ RE:'Reunion',
205
+ RO:'Romania',
206
+ RU:'Russian Federation',
207
+ RW:'Rwanda',
208
+ SH:'Saint Helena',
209
+ KN:'Saint Kitts and Nevis',
210
+ LC:'Saint Lucia',
211
+ PM:'Saint Pierre and Miquelon',
212
+ VC:'Saint Vincent and The Grenadines',
213
+ WS:'Samoa',
214
+ SM:'San Marino',
215
+ ST:'Sao Tome and Principe',
216
+ SA:'Saudi Arabia',
217
+ SN:'Senegal',
218
+ RS:'Serbia',
219
+ SC:'Seychelles',
220
+ SL:'Sierra Leone',
221
+ SG:'Singapore',
222
+ SK:'Slovakia',
223
+ SI:'Slovenia',
224
+ SB:'Solomon Islands',
225
+ SO:'Somalia',
226
+ ZA:'South Africa',
227
+ GS:'South Georgia and The South Sandwich Islands',
228
+ ES:'Spain',
229
+ LK:'Sri Lanka',
230
+ SD:'Sudan',
231
+ SR:'Suriname',
232
+ SJ:'Svalbard and Jan Mayen',
233
+ SZ:'Swaziland',
234
+ SE:'Sweden',
235
+ CH:'Switzerland',
236
+ SY:'Syrian Arab Republic',
237
+ TW:'Taiwan, Province of China',
238
+ TJ:'Tajikistan',
239
+ TZ:'Tanzania, United Republic of',
240
+ TH:'Thailand',
241
+ TL:'Timor-leste',
242
+ TG:'Togo',
243
+ TK:'Tokelau',
244
+ TO:'Tonga',
245
+ TT:'Trinidad and Tobago',
246
+ TN:'Tunisia',
247
+ TR:'Turkey',
248
+ TM:'Turkmenistan',
249
+ TC:'Turks and Caicos Islands',
250
+ TV:'Tuvalu',
251
+ UG:'Uganda',
252
+ UA:'Ukraine',
253
+ AE:'United Arab Emirates',
254
+ GB:'United Kingdom',
255
+ US:'United States',
256
+ UM:'United States Minor Outlying Islands',
257
+ UY:'Uruguay',
258
+ UZ:'Uzbekistan',
259
+ VU:'Vanuatu',
260
+ VE:'Venezuela',
261
+ VN:'Viet Nam',
262
+ VG:'Virgin Islands, British',
263
+ VI:'Virgin Islands, U.S.',
264
+ WF:'Wallis and Futuna',
265
+ EH:'Western Sahara',
266
+ YE:'Yemen',
267
+ ZM:'Zambia',
268
+ ZW:'Zimbabwe',
269
+ };
272
270
  }
273
271
  }
274
272
 
@@ -385,4 +383,4 @@ class Location {
385
383
  }
386
384
  }
387
385
 
388
- module.exports = { COUNTRIES_LIST, Country, PostalAddress, Location };
386
+ module.exports = { Country, PostalAddress, Location };
package/network.js CHANGED
@@ -540,3 +540,5 @@ class UrlAndQueryString {
540
540
  }
541
541
 
542
542
  }
543
+
544
+ module.exports = { HTTPRequest, Cookie, UrlAndQueryString };
package/number.js CHANGED
@@ -1,5 +1,7 @@
1
1
 
2
+ /** @deprecated */
2
3
  class NumberValue {
4
+ /** @deprecated */
3
5
  static isNumeric(sText) {
4
6
  var ValidChars = "0123456789.";
5
7
  var IsNumber=true;
@@ -13,6 +15,7 @@ class NumberValue {
13
15
  return IsNumber;
14
16
  }
15
17
 
18
+ /** @deprecated */
16
19
  static format(number, nbDecimal, locale) {
17
20
  nbDecimal = (typeof nbDecimal != 'undefined'?nbDecimal:2);
18
21
  return new Intl.NumberFormat(locale, {
@@ -21,6 +24,7 @@ class NumberValue {
21
24
  }).format(number);
22
25
  }
23
26
 
27
+ /** @deprecated */
24
28
  static formatCurrency(montant, currency, nbDecimal, locale) {
25
29
  nbDecimal = (typeof nbDecimal != 'undefined'?nbDecimal:2);
26
30
  return new Intl.NumberFormat(locale, {
@@ -31,6 +35,7 @@ class NumberValue {
31
35
  }).format(montant);
32
36
  }
33
37
 
38
+ /** @deprecated */
34
39
  static formatPercent(number, nbDecimal, locale) {
35
40
  nbDecimal = (typeof nbDecimal != 'undefined'?nbDecimal:2);
36
41
  return new Intl.NumberFormat(locale, {
@@ -40,14 +45,17 @@ class NumberValue {
40
45
  }).format(number);
41
46
  }
42
47
 
48
+ /** @deprecated */
43
49
  static random(min, max) {
44
50
  return Math.floor(Math.random() * (max - min + 1)) + min;
45
51
  }
46
52
 
53
+ /** @deprecated */
47
54
  static padLeft2(n) {
48
55
  return n > 9 ? "" + n: "0" + n;
49
56
  }
50
57
 
58
+ /** @deprecated */
51
59
  static roundDecimal(nombre, precision) {
52
60
  precision = precision || 2;
53
61
  var tmp = Math.pow(10, precision);
@@ -55,25 +63,69 @@ class NumberValue {
55
63
  }
56
64
  }
57
65
 
66
+ Number.prototype.format = Number.prototype.format || function(nbDecimal, locale) {
67
+ nbDecimal = (typeof nbDecimal != 'undefined'?nbDecimal:2);
68
+ return new Intl.NumberFormat(locale, {
69
+ minimumFractionDigits: nbDecimal,
70
+ maximumFractionDigits: nbDecimal
71
+ }).format(this);
72
+ }
73
+
58
74
  /**
59
75
  * Number.prototype.format(n, x, s, c)
60
- *
76
+ *
61
77
  * @param integer n: length of decimal
62
78
  * @param mixed s: sections delimiter
63
79
  * @param mixed c: decimal delimiter
64
80
  * @param integer x: length of sections
65
81
  */
66
- Number.prototype.formatForDisplay = function(n, s, c, x) {
67
- var re = '\\d(?=(\\d{' + (x || 3) + '})+' + (n > 0 ? '\\D' : '$') + ')',
68
- num = this.toFixed(Math.max(0, ~~n));
69
- return (c ? num.replace('.', c) : num).replace(new RegExp(re, 'g'), '$&' + (s || ','));
82
+ Number.prototype.formatForDisplay = Number.prototype.formatForDisplay || function(n, s, c, x) {
83
+ var re = '\\d(?=(\\d{' + (x || 3) + '})+' + (n > 0 ? '\\D' : '$') + ')',
84
+ num = this.toFixed(Math.max(0, ~~n));
85
+ return (c ? num.replace('.', c) : num).replace(new RegExp(re, 'g'), '$&' + (s || ','));
70
86
  };
71
87
 
88
+ Number.prototype.formatCurrency = Number.prototype.formatCurrency || function(currency, nbDecimal, locale) {
89
+ nbDecimal = (typeof nbDecimal != 'undefined'?nbDecimal:2);
90
+ return new Intl.NumberFormat(locale, {
91
+ style: 'currency',
92
+ currency: currency,
93
+ minimumFractionDigits: nbDecimal,
94
+ maximumFractionDigits: nbDecimal
95
+ }).format(this);
96
+ }
97
+
98
+ Number.prototype.formatPercent = Number.prototype.formatPercent || function(nbDecimal, locale) {
99
+ nbDecimal = (typeof nbDecimal != 'undefined'?nbDecimal:2);
100
+ return new Intl.NumberFormat(locale, {
101
+ style: 'percent',
102
+ minimumFractionDigits: nbDecimal,
103
+ maximumFractionDigits: nbDecimal
104
+ }).format(this);
105
+ }
106
+
107
+ Number.prototype.padLeft2 = Number.prototype.padLeft2 || function(n) {
108
+ return this > 9 ? "" + this : "0" + this;
109
+ }
110
+
111
+ Number.prototype.roundDecimal = Number.prototype.roundDecimal || function(precision) {
112
+ precision = precision || 2;
113
+ var tmp = Math.pow(10, precision);
114
+ return Math.round(this*tmp) / tmp;
115
+ }
116
+
117
+ if (!Number.random) {
118
+ Number.random = function(min, max) {
119
+ return Math.floor(Math.random() * (max - min + 1)) + min;
120
+ };
121
+ }
122
+
123
+ /** @deprecated */
72
124
  Number.prototype.formatAsString = function(locale, minimumFractionDigits) {
73
125
  minimumFractionDigits = (typeof minimumFractionDigits != 'undefined'?minimumFractionDigits:0);
74
126
  return new Intl.NumberFormat(locale, {minimumFractionDigits: minimumFractionDigits}).format(this);
75
127
  };
76
-
128
+ /** @deprecated */
77
129
  Number.prototype.formatAsCurrency = function(locale, currency, nbFractionDigits) {
78
130
  nbFractionDigits = (typeof nbFractionDigits != 'undefined'?nbFractionDigits:2);
79
131
  return new Intl.NumberFormat(locale, {
@@ -83,7 +135,7 @@ Number.prototype.formatAsCurrency = function(locale, currency, nbFractionDigits)
83
135
  maximumFractionDigits: nbFractionDigits
84
136
  }).format(this);
85
137
  };
86
-
138
+ /** @deprecated */
87
139
  Number.prototype.formatAsPercent = function(locale, minimumFractionDigits) {
88
140
  minimumFractionDigits = (typeof minimumFractionDigits != 'undefined'?minimumFractionDigits:0);
89
141
  return new Intl.NumberFormat(locale, {style: 'percent', minimumFractionDigits:minimumFractionDigits}).format(this);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osimatic/helpers-js",
3
- "version": "1.0.6",
3
+ "version": "1.0.9",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"