investira.sdk 2.4.28 → 2.4.30
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/CHANGELOG.md +8 -0
- package/jsconfig.json +1 -1
- package/lib/utils/formats.js +52 -2
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -641,3 +641,11 @@ O contrutor para a criação das mensagem foi alterado.
|
|
|
641
641
|
# 2.4.28
|
|
642
642
|
|
|
643
643
|
- [responses] serviceDataResponse com parametro de referencia a funcao
|
|
644
|
+
|
|
645
|
+
# 2.4.29
|
|
646
|
+
|
|
647
|
+
- Nodejs < 18.21.0
|
|
648
|
+
|
|
649
|
+
# 2.4.30
|
|
650
|
+
|
|
651
|
+
- [formats] toBytes para converter bytes em formato legível
|
package/jsconfig.json
CHANGED
package/lib/utils/formats.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
//@ts-ignore
|
|
1
2
|
const { round, trunc, toNumber } = require('./numbers');
|
|
3
|
+
//@ts-ignore
|
|
2
4
|
const { startOf, addDays, addMonths, addYears, toDate, daysBetween, monthsBetween, yearsBetween } = require('./dates');
|
|
5
|
+
//@ts-ignore
|
|
3
6
|
const { isEmpty, isNumber, isString } = require('./validators');
|
|
7
|
+
//@ts-ignore
|
|
4
8
|
const moment = require('moment/min/moment-with-locales');
|
|
5
9
|
// var l10nEN = new Intl.DateTimeFormat("en-US")
|
|
6
10
|
// var l10nDE = new Intl.DateTimeFormat("de-DE")
|
|
@@ -40,6 +44,7 @@ const formats = {
|
|
|
40
44
|
currencyDisplay: 'symbol',
|
|
41
45
|
currency: formats.CURRENCY
|
|
42
46
|
};
|
|
47
|
+
//@ts-ignore
|
|
43
48
|
return pValue.toLocaleString(formats.LOCALE, xOptions);
|
|
44
49
|
},
|
|
45
50
|
|
|
@@ -164,8 +169,8 @@ const formats = {
|
|
|
164
169
|
pMonth > 1
|
|
165
170
|
? formats.getRelativeTime(pMonth, 'MM')
|
|
166
171
|
: pMonth === 1
|
|
167
|
-
|
|
168
|
-
|
|
172
|
+
? formats.getRelativeTime(pMonth, 'M')
|
|
173
|
+
: '',
|
|
169
174
|
day: pDay > 1 ? formats.getRelativeTime(pDay, 'dd') : pDay === 1 ? formats.getRelativeTime(1, 'd') : ''
|
|
170
175
|
};
|
|
171
176
|
},
|
|
@@ -383,6 +388,51 @@ const formats = {
|
|
|
383
388
|
if (xPublicos.has(xHostParaCheck)) return null;
|
|
384
389
|
|
|
385
390
|
return xHostPath;
|
|
391
|
+
},
|
|
392
|
+
/**
|
|
393
|
+
* Função utilitária para converter valores de tamanho de arquivo para bytes.
|
|
394
|
+
*
|
|
395
|
+
* Aceita valores numéricos (já em bytes) ou strings formatadas com unidades
|
|
396
|
+
* como '100mb', '2gb', '500kb', '1024'. Caso não seja possível parsear,
|
|
397
|
+
* retorna o valor padrão de 100MB.
|
|
398
|
+
*
|
|
399
|
+
* Unidades suportadas (case insensitive):
|
|
400
|
+
* - b: bytes
|
|
401
|
+
* - kb: kilobytes (1024 bytes)
|
|
402
|
+
* - mb: megabytes (1024 * 1024 bytes)
|
|
403
|
+
* - gb: gigabytes (1024 * 1024 * 1024 bytes)
|
|
404
|
+
*
|
|
405
|
+
* @param {number|string} pValue Valor a ser convertido
|
|
406
|
+
* @returns {number} Valor em bytes
|
|
407
|
+
*
|
|
408
|
+
* @example
|
|
409
|
+
* pvToBytes(1024) // 1024
|
|
410
|
+
* pvToBytes('100mb') // 104857600
|
|
411
|
+
* pvToBytes('2GB') // 2147483648
|
|
412
|
+
* pvToBytes('500kb') // 512000
|
|
413
|
+
* pvToBytes('invalid') // 104857600 (padrão 100MB)
|
|
414
|
+
*/
|
|
415
|
+
toBytes: pValue => {
|
|
416
|
+
if (typeof pValue === 'number' && Number.isFinite(pValue)) {
|
|
417
|
+
return pValue;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
const xValue = String(pValue || '').trim().toLowerCase();
|
|
421
|
+
const xMatch = xValue.match(/^(\d+(?:\.\d+)?)\s*(b|kb|mb|gb)?$/);
|
|
422
|
+
if (!xMatch) {
|
|
423
|
+
return 100 * 1024 * 1024;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
const xAmount = Number(xMatch[1]);
|
|
427
|
+
const xUnit = xMatch[2] || 'b';
|
|
428
|
+
const xMultiplier = {
|
|
429
|
+
b: 1,
|
|
430
|
+
kb: 1024,
|
|
431
|
+
mb: 1024 * 1024,
|
|
432
|
+
gb: 1024 * 1024 * 1024
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
return Math.floor(xAmount * xMultiplier[xUnit]);
|
|
386
436
|
}
|
|
387
437
|
};
|
|
388
438
|
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "investira.sdk",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.30",
|
|
4
4
|
"author": "Investira",
|
|
5
5
|
"description": "Investira SDK",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"type": "commonjs",
|
|
8
8
|
"registry": true,
|
|
9
|
-
"raw": "investira.sdk@2.4.
|
|
9
|
+
"raw": "investira.sdk@2.4.30",
|
|
10
10
|
"escapedName": "investira.sdk",
|
|
11
|
-
"rawSpec": "2.4.
|
|
11
|
+
"rawSpec": "2.4.30",
|
|
12
12
|
"saveSpec": null,
|
|
13
|
-
"fetchSpec": "2.4.
|
|
13
|
+
"fetchSpec": "2.4.30",
|
|
14
14
|
"homepage": "https://investira.com.br/",
|
|
15
15
|
"engines": {
|
|
16
|
-
"node": ">=11.11.0 <=18.
|
|
16
|
+
"node": ">=11.11.0 <=18.21.0",
|
|
17
17
|
"npm": ">=6.0.0"
|
|
18
18
|
},
|
|
19
19
|
"keywords": [
|