apf-node-common 1.0.109 → 1.0.111
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/ApplicationContextService.js +103 -103
- package/CoreUtils.js +59 -59
- package/Logger/index.js +93 -93
- package/Logger/loggerTransports.js +137 -137
- package/SSMConfig.js +44 -44
- package/ScheduleCalculationService.js +0 -0
- package/auditlog/AuditLogger.js +58 -58
- package/auditlog/AuditLoggerRepository.js +38 -38
- package/auditlog/AuditLoggerService.js +37 -37
- package/config/SSMParameters.js +16 -16
- package/constants/CommonMessages.js +14 -14
- package/constants/Frequency.js +8 -8
- package/constants/TimeZone.js +11 -11
- package/constants/UserType.js +9 -9
- package/exception/CustomException.js +36 -36
- package/exception/SendResponse.js +139 -139
- package/index.js +187 -187
- package/package.json +29 -29
- package/test/AWSUtilityIntegrationTest.js +94 -94
- package/test/FrequencyValidatorTest.js +0 -0
- package/test/LambdaCommunicationServiceTest.js +83 -83
- package/test/ScheduleCalculationServiceTest.js +0 -0
- package/utils/HashIds.js +139 -139
- package/utils/NumberFormatter.js +253 -253
- package/utils/aws/AESEncryptionUsingKMS.js +106 -106
- package/utils/aws/AWSAPIKeyGenerator.js +307 -307
- package/utils/aws/AWSS3Utils.js +128 -128
- package/utils/aws/AWSSMSUtils.js +63 -63
- package/utils/aws/AWSSNSBasedEmailDispatcher.js +37 -37
- package/utils/aws/AWSSNSBasedSMSDispatcher.js +37 -37
- package/utils/aws/AWSSNSUtils.js +35 -38
- package/utils/aws/LambdaCommunicationService.js +232 -232
- package/utils/enumHelper.js +7 -7
- package/utils/thirdparty/URLShorteningService.js +25 -25
- package/validation/CoreValidations.js +45 -45
- package/validation/FrequencyValidator.js +0 -0
- package/validation/SchemaValidation.js +106 -106
package/utils/NumberFormatter.js
CHANGED
|
@@ -1,254 +1,254 @@
|
|
|
1
|
-
|
|
2
|
-
// This class used to PhoneNumber formate eg.console.log (format("{0:###-#-##-####}", 1234567898));
|
|
3
|
-
|
|
4
|
-
function format(formatString) {
|
|
5
|
-
var result = '';
|
|
6
|
-
for (var i = 0; i < formatString.length;) {
|
|
7
|
-
if (formatString[i] == '}') {
|
|
8
|
-
i++;
|
|
9
|
-
if (formatString[i] == '}') {
|
|
10
|
-
result += '}';
|
|
11
|
-
i++;
|
|
12
|
-
continue;
|
|
13
|
-
}
|
|
14
|
-
throw new Error("Unescaped substitution");
|
|
15
|
-
}
|
|
16
|
-
if (formatString[i] == '{') {
|
|
17
|
-
var spec = '';
|
|
18
|
-
i++;
|
|
19
|
-
if (formatString[i] == '{') {
|
|
20
|
-
result += '{';
|
|
21
|
-
i++;
|
|
22
|
-
continue;
|
|
23
|
-
}
|
|
24
|
-
for (; i < formatString.length;) {
|
|
25
|
-
if (formatString[i] == '}') {
|
|
26
|
-
break;
|
|
27
|
-
}
|
|
28
|
-
spec += formatString[i++];
|
|
29
|
-
}
|
|
30
|
-
if (i == formatString.length) {
|
|
31
|
-
throw new Error("Unterminated substitution");
|
|
32
|
-
}
|
|
33
|
-
i++;
|
|
34
|
-
var alignTokenLoc = spec.indexOf(',');
|
|
35
|
-
var specTokenLoc;
|
|
36
|
-
var alignVal = 0;
|
|
37
|
-
if (alignTokenLoc > 0) {
|
|
38
|
-
specTokenLoc = spec.indexOf(':');
|
|
39
|
-
if (specTokenLoc > 0) {
|
|
40
|
-
if (alignTokenLoc < specTokenLoc) {
|
|
41
|
-
alignVal = spec.substr(alignTokenLoc + 1, specTokenLoc - alignTokenLoc - 1);
|
|
42
|
-
spec = spec.substr(0, alignTokenLoc) + spec.substr(specTokenLoc);
|
|
43
|
-
}
|
|
44
|
-
} else {
|
|
45
|
-
alignVal = spec.substr(alignTokenLoc + 1);
|
|
46
|
-
spec = spec.substr(0, alignTokenLoc);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
specTokenLoc = spec.indexOf(':');
|
|
51
|
-
var fieldName, formatSpec;
|
|
52
|
-
if (specTokenLoc > 0) {
|
|
53
|
-
fieldName = spec.substr(0, specTokenLoc);
|
|
54
|
-
formatSpec = spec.substr(specTokenLoc + 1);
|
|
55
|
-
} else {
|
|
56
|
-
fieldName = spec;
|
|
57
|
-
formatSpec = null;
|
|
58
|
-
}
|
|
59
|
-
var val = getValue(arguments, fieldName);
|
|
60
|
-
|
|
61
|
-
if (typeof (val) === 'number') {
|
|
62
|
-
result += align(formatNumber(val, formatSpec), alignVal);
|
|
63
|
-
}
|
|
64
|
-
} else {
|
|
65
|
-
result += formatString[i++];
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return result;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function align(str, val) {
|
|
72
|
-
str = str || '';
|
|
73
|
-
if (val < 0) {
|
|
74
|
-
return padRight(str, ' ', Math.abs(val));
|
|
75
|
-
} else if (val > 0) {
|
|
76
|
-
return padLeft(str, ' ', val);
|
|
77
|
-
}
|
|
78
|
-
return str;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function padRight(str, char, totalWidth) {
|
|
82
|
-
while (str.length < totalWidth) {
|
|
83
|
-
str = str + char;
|
|
84
|
-
}
|
|
85
|
-
return str;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function padLeft(str, char, totalWidth) {
|
|
89
|
-
while (str.length < totalWidth) {
|
|
90
|
-
str = char + str;
|
|
91
|
-
}
|
|
92
|
-
return str;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function getValue(args, fieldName) {
|
|
96
|
-
var fieldIndex = parseInt(fieldName);
|
|
97
|
-
if (fieldIndex.toString() === fieldName) {
|
|
98
|
-
return args[fieldIndex + 1];
|
|
99
|
-
} else {
|
|
100
|
-
var parts = splitFieldName(fieldName);
|
|
101
|
-
var root = args[1];
|
|
102
|
-
for (var i = 0; i < parts.length; i++) {
|
|
103
|
-
var part = parts[i];
|
|
104
|
-
|
|
105
|
-
if (part.length >= 1 && part[0] == '?') {
|
|
106
|
-
if (typeof (root) == 'undefined') {
|
|
107
|
-
return undefined;
|
|
108
|
-
} else {
|
|
109
|
-
part = part.substr(1);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (part.length >= 1 && part[0] == '[') {
|
|
114
|
-
part = part.substr(1, part.length - 2);
|
|
115
|
-
var strMatch = part.match(/^['"](.*)['"]$/);
|
|
116
|
-
if (strMatch) {
|
|
117
|
-
root = root[strMatch[1]];
|
|
118
|
-
}
|
|
119
|
-
else if (part < 0) {
|
|
120
|
-
part = -part;
|
|
121
|
-
root = root[root.length - part];
|
|
122
|
-
} else {
|
|
123
|
-
root = root[part];
|
|
124
|
-
}
|
|
125
|
-
continue;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
root = root[part];
|
|
129
|
-
}
|
|
130
|
-
return root;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
function splitFieldName(fieldName) {
|
|
136
|
-
var results = [];
|
|
137
|
-
var part = '';
|
|
138
|
-
for (var i = 0; i < fieldName.length;) {
|
|
139
|
-
if (fieldName[i] == '.') {
|
|
140
|
-
results.push(part);
|
|
141
|
-
part = '';
|
|
142
|
-
i++;
|
|
143
|
-
continue;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
if (fieldName[i] == '[') {
|
|
147
|
-
results.push(part);
|
|
148
|
-
part = '[';
|
|
149
|
-
i++;
|
|
150
|
-
continue;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
part += fieldName[i++];
|
|
154
|
-
}
|
|
155
|
-
results.push(part);
|
|
156
|
-
return results;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
function formatNumber(num, format) {
|
|
160
|
-
format = format || "0";
|
|
161
|
-
|
|
162
|
-
var hex = format.match(/^([xX])([0-9]*)$/);
|
|
163
|
-
if (hex) {
|
|
164
|
-
var str = num.toString(16);
|
|
165
|
-
if (hex[1] == 'x') {
|
|
166
|
-
str = str.toLowerCase();
|
|
167
|
-
} else {
|
|
168
|
-
str = str.toUpperCase();
|
|
169
|
-
}
|
|
170
|
-
var width = parseInt(hex[2]);
|
|
171
|
-
str = padLeft(str, '0', width);
|
|
172
|
-
return str;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
var negative = false;
|
|
176
|
-
if (num < 0) {
|
|
177
|
-
num = -num;
|
|
178
|
-
negative = true;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
var addPositiveSign = false;
|
|
182
|
-
if (format.match(/^\+/)) {
|
|
183
|
-
format = format.substr(1);
|
|
184
|
-
addPositiveSign = true;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
var formatParts = format.split('.');
|
|
188
|
-
var formatBeforeDecimal = formatParts[0];
|
|
189
|
-
var wholeNumber = Math.floor(num);
|
|
190
|
-
var decimalVal = num - wholeNumber;
|
|
191
|
-
var result = '';
|
|
192
|
-
var wholeNumberStr = wholeNumber.toString();
|
|
193
|
-
var formatIdx, numberIdx;
|
|
194
|
-
|
|
195
|
-
// format whole number part
|
|
196
|
-
for (formatIdx = formatBeforeDecimal.length - 1, numberIdx = wholeNumberStr.length - 1; numberIdx >= 0 || formatIdx >= 0; formatIdx--) {
|
|
197
|
-
if (formatIdx < 0 && numberIdx >= 0) {
|
|
198
|
-
result = wholeNumberStr[numberIdx--] + result;
|
|
199
|
-
continue;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
if (formatBeforeDecimal[formatIdx] == '0' || formatBeforeDecimal[formatIdx] == '#') {
|
|
203
|
-
if (numberIdx >= 0) {
|
|
204
|
-
result = wholeNumberStr[numberIdx--] + result;
|
|
205
|
-
} else {
|
|
206
|
-
if (formatBeforeDecimal[formatIdx] == '#') {
|
|
207
|
-
break;
|
|
208
|
-
}
|
|
209
|
-
result = '0' + result;
|
|
210
|
-
}
|
|
211
|
-
continue;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
result = formatBeforeDecimal[formatIdx] + result;
|
|
215
|
-
}
|
|
216
|
-
result = result.replace(/^[^0-9]+/, '');
|
|
217
|
-
|
|
218
|
-
// format decimal part
|
|
219
|
-
if (formatParts.length > 1) {
|
|
220
|
-
var formatAfterDecimal = formatParts[1];
|
|
221
|
-
var decimalValStr = decimalVal.toString().substr(2);
|
|
222
|
-
|
|
223
|
-
result += '.';
|
|
224
|
-
for (formatIdx = 0, numberIdx = 0; formatIdx < formatAfterDecimal.length; formatIdx++) {
|
|
225
|
-
if (formatAfterDecimal[formatIdx] == '0' || formatAfterDecimal[formatIdx] == '#') {
|
|
226
|
-
if (numberIdx < decimalValStr.length) {
|
|
227
|
-
result += decimalValStr[numberIdx++];
|
|
228
|
-
} else {
|
|
229
|
-
if (formatAfterDecimal[formatIdx] == '#') {
|
|
230
|
-
break;
|
|
231
|
-
}
|
|
232
|
-
result += '0';
|
|
233
|
-
}
|
|
234
|
-
} else {
|
|
235
|
-
result += formatAfterDecimal[formatIdx];
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
if (result[result.length - 1] == '.') {
|
|
241
|
-
result = result.substr(0, result.length - 1);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
if (negative) {
|
|
245
|
-
result = '-' + result;
|
|
246
|
-
}
|
|
247
|
-
if (!negative && addPositiveSign) {
|
|
248
|
-
result = '+' + result;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
return result;
|
|
252
|
-
}
|
|
253
|
-
|
|
1
|
+
|
|
2
|
+
// This class used to PhoneNumber formate eg.console.log (format("{0:###-#-##-####}", 1234567898));
|
|
3
|
+
|
|
4
|
+
function format(formatString) {
|
|
5
|
+
var result = '';
|
|
6
|
+
for (var i = 0; i < formatString.length;) {
|
|
7
|
+
if (formatString[i] == '}') {
|
|
8
|
+
i++;
|
|
9
|
+
if (formatString[i] == '}') {
|
|
10
|
+
result += '}';
|
|
11
|
+
i++;
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
14
|
+
throw new Error("Unescaped substitution");
|
|
15
|
+
}
|
|
16
|
+
if (formatString[i] == '{') {
|
|
17
|
+
var spec = '';
|
|
18
|
+
i++;
|
|
19
|
+
if (formatString[i] == '{') {
|
|
20
|
+
result += '{';
|
|
21
|
+
i++;
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
for (; i < formatString.length;) {
|
|
25
|
+
if (formatString[i] == '}') {
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
spec += formatString[i++];
|
|
29
|
+
}
|
|
30
|
+
if (i == formatString.length) {
|
|
31
|
+
throw new Error("Unterminated substitution");
|
|
32
|
+
}
|
|
33
|
+
i++;
|
|
34
|
+
var alignTokenLoc = spec.indexOf(',');
|
|
35
|
+
var specTokenLoc;
|
|
36
|
+
var alignVal = 0;
|
|
37
|
+
if (alignTokenLoc > 0) {
|
|
38
|
+
specTokenLoc = spec.indexOf(':');
|
|
39
|
+
if (specTokenLoc > 0) {
|
|
40
|
+
if (alignTokenLoc < specTokenLoc) {
|
|
41
|
+
alignVal = spec.substr(alignTokenLoc + 1, specTokenLoc - alignTokenLoc - 1);
|
|
42
|
+
spec = spec.substr(0, alignTokenLoc) + spec.substr(specTokenLoc);
|
|
43
|
+
}
|
|
44
|
+
} else {
|
|
45
|
+
alignVal = spec.substr(alignTokenLoc + 1);
|
|
46
|
+
spec = spec.substr(0, alignTokenLoc);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
specTokenLoc = spec.indexOf(':');
|
|
51
|
+
var fieldName, formatSpec;
|
|
52
|
+
if (specTokenLoc > 0) {
|
|
53
|
+
fieldName = spec.substr(0, specTokenLoc);
|
|
54
|
+
formatSpec = spec.substr(specTokenLoc + 1);
|
|
55
|
+
} else {
|
|
56
|
+
fieldName = spec;
|
|
57
|
+
formatSpec = null;
|
|
58
|
+
}
|
|
59
|
+
var val = getValue(arguments, fieldName);
|
|
60
|
+
|
|
61
|
+
if (typeof (val) === 'number') {
|
|
62
|
+
result += align(formatNumber(val, formatSpec), alignVal);
|
|
63
|
+
}
|
|
64
|
+
} else {
|
|
65
|
+
result += formatString[i++];
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function align(str, val) {
|
|
72
|
+
str = str || '';
|
|
73
|
+
if (val < 0) {
|
|
74
|
+
return padRight(str, ' ', Math.abs(val));
|
|
75
|
+
} else if (val > 0) {
|
|
76
|
+
return padLeft(str, ' ', val);
|
|
77
|
+
}
|
|
78
|
+
return str;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function padRight(str, char, totalWidth) {
|
|
82
|
+
while (str.length < totalWidth) {
|
|
83
|
+
str = str + char;
|
|
84
|
+
}
|
|
85
|
+
return str;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function padLeft(str, char, totalWidth) {
|
|
89
|
+
while (str.length < totalWidth) {
|
|
90
|
+
str = char + str;
|
|
91
|
+
}
|
|
92
|
+
return str;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function getValue(args, fieldName) {
|
|
96
|
+
var fieldIndex = parseInt(fieldName);
|
|
97
|
+
if (fieldIndex.toString() === fieldName) {
|
|
98
|
+
return args[fieldIndex + 1];
|
|
99
|
+
} else {
|
|
100
|
+
var parts = splitFieldName(fieldName);
|
|
101
|
+
var root = args[1];
|
|
102
|
+
for (var i = 0; i < parts.length; i++) {
|
|
103
|
+
var part = parts[i];
|
|
104
|
+
|
|
105
|
+
if (part.length >= 1 && part[0] == '?') {
|
|
106
|
+
if (typeof (root) == 'undefined') {
|
|
107
|
+
return undefined;
|
|
108
|
+
} else {
|
|
109
|
+
part = part.substr(1);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (part.length >= 1 && part[0] == '[') {
|
|
114
|
+
part = part.substr(1, part.length - 2);
|
|
115
|
+
var strMatch = part.match(/^['"](.*)['"]$/);
|
|
116
|
+
if (strMatch) {
|
|
117
|
+
root = root[strMatch[1]];
|
|
118
|
+
}
|
|
119
|
+
else if (part < 0) {
|
|
120
|
+
part = -part;
|
|
121
|
+
root = root[root.length - part];
|
|
122
|
+
} else {
|
|
123
|
+
root = root[part];
|
|
124
|
+
}
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
root = root[part];
|
|
129
|
+
}
|
|
130
|
+
return root;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
function splitFieldName(fieldName) {
|
|
136
|
+
var results = [];
|
|
137
|
+
var part = '';
|
|
138
|
+
for (var i = 0; i < fieldName.length;) {
|
|
139
|
+
if (fieldName[i] == '.') {
|
|
140
|
+
results.push(part);
|
|
141
|
+
part = '';
|
|
142
|
+
i++;
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (fieldName[i] == '[') {
|
|
147
|
+
results.push(part);
|
|
148
|
+
part = '[';
|
|
149
|
+
i++;
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
part += fieldName[i++];
|
|
154
|
+
}
|
|
155
|
+
results.push(part);
|
|
156
|
+
return results;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function formatNumber(num, format) {
|
|
160
|
+
format = format || "0";
|
|
161
|
+
|
|
162
|
+
var hex = format.match(/^([xX])([0-9]*)$/);
|
|
163
|
+
if (hex) {
|
|
164
|
+
var str = num.toString(16);
|
|
165
|
+
if (hex[1] == 'x') {
|
|
166
|
+
str = str.toLowerCase();
|
|
167
|
+
} else {
|
|
168
|
+
str = str.toUpperCase();
|
|
169
|
+
}
|
|
170
|
+
var width = parseInt(hex[2]);
|
|
171
|
+
str = padLeft(str, '0', width);
|
|
172
|
+
return str;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
var negative = false;
|
|
176
|
+
if (num < 0) {
|
|
177
|
+
num = -num;
|
|
178
|
+
negative = true;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
var addPositiveSign = false;
|
|
182
|
+
if (format.match(/^\+/)) {
|
|
183
|
+
format = format.substr(1);
|
|
184
|
+
addPositiveSign = true;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
var formatParts = format.split('.');
|
|
188
|
+
var formatBeforeDecimal = formatParts[0];
|
|
189
|
+
var wholeNumber = Math.floor(num);
|
|
190
|
+
var decimalVal = num - wholeNumber;
|
|
191
|
+
var result = '';
|
|
192
|
+
var wholeNumberStr = wholeNumber.toString();
|
|
193
|
+
var formatIdx, numberIdx;
|
|
194
|
+
|
|
195
|
+
// format whole number part
|
|
196
|
+
for (formatIdx = formatBeforeDecimal.length - 1, numberIdx = wholeNumberStr.length - 1; numberIdx >= 0 || formatIdx >= 0; formatIdx--) {
|
|
197
|
+
if (formatIdx < 0 && numberIdx >= 0) {
|
|
198
|
+
result = wholeNumberStr[numberIdx--] + result;
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (formatBeforeDecimal[formatIdx] == '0' || formatBeforeDecimal[formatIdx] == '#') {
|
|
203
|
+
if (numberIdx >= 0) {
|
|
204
|
+
result = wholeNumberStr[numberIdx--] + result;
|
|
205
|
+
} else {
|
|
206
|
+
if (formatBeforeDecimal[formatIdx] == '#') {
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
209
|
+
result = '0' + result;
|
|
210
|
+
}
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
result = formatBeforeDecimal[formatIdx] + result;
|
|
215
|
+
}
|
|
216
|
+
result = result.replace(/^[^0-9]+/, '');
|
|
217
|
+
|
|
218
|
+
// format decimal part
|
|
219
|
+
if (formatParts.length > 1) {
|
|
220
|
+
var formatAfterDecimal = formatParts[1];
|
|
221
|
+
var decimalValStr = decimalVal.toString().substr(2);
|
|
222
|
+
|
|
223
|
+
result += '.';
|
|
224
|
+
for (formatIdx = 0, numberIdx = 0; formatIdx < formatAfterDecimal.length; formatIdx++) {
|
|
225
|
+
if (formatAfterDecimal[formatIdx] == '0' || formatAfterDecimal[formatIdx] == '#') {
|
|
226
|
+
if (numberIdx < decimalValStr.length) {
|
|
227
|
+
result += decimalValStr[numberIdx++];
|
|
228
|
+
} else {
|
|
229
|
+
if (formatAfterDecimal[formatIdx] == '#') {
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
result += '0';
|
|
233
|
+
}
|
|
234
|
+
} else {
|
|
235
|
+
result += formatAfterDecimal[formatIdx];
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
if (result[result.length - 1] == '.') {
|
|
241
|
+
result = result.substr(0, result.length - 1);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (negative) {
|
|
245
|
+
result = '-' + result;
|
|
246
|
+
}
|
|
247
|
+
if (!negative && addPositiveSign) {
|
|
248
|
+
result = '+' + result;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
return result;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
254
|
exports.format = format;
|