@hyper.software/common-helpers 1.0.23 → 1.0.24
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.
|
@@ -1,31 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
4
|
};
|
|
25
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
6
|
exports.DATE_FORMATS = exports.formatDate = exports.formatDouble = exports.findCurrencySymbol = exports.formatCurrency = void 0;
|
|
27
|
-
var
|
|
28
|
-
var
|
|
7
|
+
var currency_formatter_1 = __importDefault(require("currency-formatter"));
|
|
8
|
+
var numeral_1 = __importDefault(require("numeral"));
|
|
29
9
|
var languageService_1 = require("../services/languageService/languageService");
|
|
30
10
|
var validation_1 = require("./validation");
|
|
31
11
|
function formatCurrency(language, amount, currency, options) {
|
|
@@ -40,11 +20,11 @@ function findCurrencySymbol(code) {
|
|
|
40
20
|
if (code === 'CHF') {
|
|
41
21
|
return 'Fr';
|
|
42
22
|
}
|
|
43
|
-
return
|
|
23
|
+
return currency_formatter_1.default.findCurrency(code).symbol;
|
|
44
24
|
}
|
|
45
25
|
exports.findCurrencySymbol = findCurrencySymbol;
|
|
46
|
-
if (!
|
|
47
|
-
|
|
26
|
+
if (!numeral_1.default.locales.de) {
|
|
27
|
+
numeral_1.default.register('locale', 'de', {
|
|
48
28
|
delimiters: {
|
|
49
29
|
thousands: '.',
|
|
50
30
|
decimal: ',',
|
|
@@ -54,15 +34,15 @@ if (!numeral.locales.de) {
|
|
|
54
34
|
currency: {},
|
|
55
35
|
});
|
|
56
36
|
}
|
|
57
|
-
if (!
|
|
58
|
-
|
|
37
|
+
if (!numeral_1.default.locales.ch) {
|
|
38
|
+
numeral_1.default.register('locale', 'ch', {
|
|
59
39
|
abbreviations: {},
|
|
60
40
|
ordinal: function () { return ({}); },
|
|
61
41
|
currency: {},
|
|
62
42
|
});
|
|
63
43
|
}
|
|
64
|
-
if (!
|
|
65
|
-
|
|
44
|
+
if (!numeral_1.default.locales.es) {
|
|
45
|
+
numeral_1.default.register('locale', 'es', {
|
|
66
46
|
delimiters: {
|
|
67
47
|
thousands: ',',
|
|
68
48
|
decimal: '.',
|
|
@@ -72,8 +52,8 @@ if (!numeral.locales.es) {
|
|
|
72
52
|
currency: {},
|
|
73
53
|
});
|
|
74
54
|
}
|
|
75
|
-
if (!
|
|
76
|
-
|
|
55
|
+
if (!numeral_1.default.locales.fr) {
|
|
56
|
+
numeral_1.default.register('locale', 'fr', {
|
|
77
57
|
delimiters: {
|
|
78
58
|
thousands: ',',
|
|
79
59
|
decimal: '.',
|
|
@@ -83,8 +63,8 @@ if (!numeral.locales.fr) {
|
|
|
83
63
|
currency: {},
|
|
84
64
|
});
|
|
85
65
|
}
|
|
86
|
-
if (!
|
|
87
|
-
|
|
66
|
+
if (!numeral_1.default.locales.it) {
|
|
67
|
+
numeral_1.default.register('locale', 'it', {
|
|
88
68
|
delimiters: {
|
|
89
69
|
thousands: ',',
|
|
90
70
|
decimal: '.',
|
|
@@ -94,8 +74,8 @@ if (!numeral.locales.it) {
|
|
|
94
74
|
currency: {},
|
|
95
75
|
});
|
|
96
76
|
}
|
|
97
|
-
if (!
|
|
98
|
-
|
|
77
|
+
if (!numeral_1.default.locales.ro) {
|
|
78
|
+
numeral_1.default.register('locale', 'ro', {
|
|
99
79
|
delimiters: {
|
|
100
80
|
thousands: ',',
|
|
101
81
|
decimal: '.',
|
|
@@ -110,9 +90,9 @@ function formatDouble(value, options, locale) {
|
|
|
110
90
|
if ((0, validation_1.isEmpty)(value) || isNaN(value)) {
|
|
111
91
|
return null;
|
|
112
92
|
}
|
|
113
|
-
|
|
93
|
+
numeral_1.default.locale(locale);
|
|
114
94
|
if (Number.isInteger(value)) {
|
|
115
|
-
return
|
|
95
|
+
return (0, numeral_1.default)(value).format('0,0');
|
|
116
96
|
}
|
|
117
97
|
var maxDecimalsAfterComma = options && options.maxDecimalsAfterComma;
|
|
118
98
|
var exactDecimalsAfterComma = options && options.exactDecimalsAfterComma;
|
|
@@ -122,7 +102,7 @@ function formatDouble(value, options, locale) {
|
|
|
122
102
|
: decimalsAfterCommaInValue;
|
|
123
103
|
var finalNumberOfDecimalsAfterComma = exactDecimalsAfterComma || numberOfDecimalsAfterComma;
|
|
124
104
|
var decimals = '0'.repeat(finalNumberOfDecimalsAfterComma);
|
|
125
|
-
return
|
|
105
|
+
return (0, numeral_1.default)(value).format("0,0.".concat(decimals));
|
|
126
106
|
}
|
|
127
107
|
exports.formatDouble = formatDouble;
|
|
128
108
|
var moment_1 = require("./moment");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatters.js","sourceRoot":"","sources":["../../src/helpers/formatters.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"formatters.js","sourceRoot":"","sources":["../../src/helpers/formatters.ts"],"names":[],"mappings":";;;;;;AAAA,0EAAkD;AAClD,oDAA6B;AAE7B,+EAAmF;AAEnF,2CAAsC;AAMtC,SAAgB,cAAc,CAAC,QAAkB,EAAE,MAAc,EAAE,QAAgB,EAAE,OAAoC;IAAtD,yBAAA,EAAA,gBAAgB;IAAE,wBAAA,EAAA,YAAoC;IACvH,IAAM,YAAY,GAAW,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;IAE5E,OAAO,UAAG,kBAAkB,CAAC,QAAQ,CAAC,SAAG,YAAY,CACnD,YAAY,EACZ,EAAE,uBAAuB,EAAE,OAAO,CAAC,uBAAuB,IAAI,CAAC,EAAE,EACjE,IAAA,uCAAqB,EAAC,QAAQ,CAAC,CAChC,CAAE,CAAA;AACL,CAAC;AARD,wCAQC;AAED,SAAgB,kBAAkB,CAAC,IAAY;IAAZ,qBAAA,EAAA,YAAY;IAC7C,IAAI,IAAI,KAAK,KAAK,EAAE;QAClB,OAAO,IAAI,CAAA;KACZ;IAED,OAAO,4BAAiB,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,MAAM,CAAA;AACpD,CAAC;AAND,gDAMC;AAED,IAAI,CAAC,iBAAO,CAAC,OAAO,CAAC,EAAE,EAAE;IACvB,iBAAO,CAAC,QAAQ,CAAC,QAAQ,EAAE,IAAI,EAAE;QAC/B,UAAU,EAAE;YACV,SAAS,EAAE,GAAG;YACd,OAAO,EAAE,GAAG;SACb;QACD,aAAa,EAAE,EAAE;QACjB,OAAO,EAAE,cAAM,OAAA,CAAC,EAAE,CAAC,EAAJ,CAAI;QACnB,QAAQ,EAAE,EAAE;KACb,CAAC,CAAA;CACH;AAED,IAAI,CAAC,iBAAO,CAAC,OAAO,CAAC,EAAE,EAAE;IACvB,i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