zmdms-utils 0.0.64 → 0.0.66

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,71 +1,203 @@
1
- import dayjs$1 from 'dayjs';
1
+ import '../node_modules/decimal.js/decimal2.js';
2
+ import { exports as decimalExports } from '../_virtual/decimal.js';
2
3
 
3
- function unescapeString(input) {
4
- if (!input) {
5
- return "";
6
- }
4
+ // function unescapeString(input) {
5
+ // if (!input) {
6
+ // return "";
7
+ // }
7
8
 
8
- const escapedChars = {
9
- "&": "&",
10
- "&lt;": "<",
11
- "&gt;": ">",
12
- "&quot;": '"',
13
- "&#039;": "'",
14
- };
15
-
16
- return input.replace(/&(amp|lt|gt|quot|#039);/g, (match) => {
17
- return escapedChars[match] || match;
18
- });
19
- }
9
+ // const escapedChars = {
10
+ // "&amp;": "&",
11
+ // "&lt;": "<",
12
+ // "&gt;": ">",
13
+ // "&quot;": '"',
14
+ // "&#039;": "'",
15
+ // };
16
+
17
+ // return input.replace(/&(amp|lt|gt|quot|#039);/g, (match) => {
18
+ // return escapedChars[match] || match;
19
+ // });
20
+ // }
21
+
22
+ // function dangerouslySetXss(input) {
23
+ // if (!input) {
24
+ // return "";
25
+ // }
26
+ // const escapedChars = {
27
+ // "&lt;": "<",
28
+ // "&gt;": ">",
29
+ // "&nbsp;": " ",
30
+ // "&amp;": "&",
31
+ // "&quot;": '"',
32
+ // };
33
+
34
+ // return input.replace(/&(amp|lt|gt|quot|nbsp);/g, (match) => {
35
+ // return escapedChars[match] || match;
36
+ // });
37
+ // }
38
+
39
+ // function dangerouslySetXss1(input) {
40
+ // if (!input) {
41
+ // return "";
42
+ // }
43
+ // const escapedChars = {
44
+ // lt: "<",
45
+ // gt: ">",
46
+ // nbsp: " ",
47
+ // amp: "&",
48
+ // quot: '"',
49
+ // };
50
+
51
+ // return input.replace(/&(amp|lt|gt|quot|nbsp);/gi, (match, t) => {
52
+ // return escapedChars[t] || match;
53
+ // });
54
+ // }
55
+
56
+ // console.log(unescapeString("&amp;&amp;&amp;啊你"));
57
+
58
+ // console.log(dangerouslySetXss("&amp;&amp;&amp;啊你"));
59
+
60
+ // console.log(dangerouslySetXss1("&amp;&amp;&amp;啊你"));
61
+ // console.log(unescapeString("1、aa&gt;80%\n2、&gt;&lt;\n3、ss&lt;80%"));
62
+ // console.log(dangerouslySetXss("1、aa&gt;80%\n2、&gt;&lt;\n3、ss&lt;80%"));
63
+ // console.log(dangerouslySetXss1("1、aa&gt;80%\n2、&gt;&lt;\n3、ss&lt;80%"));
64
+
65
+ // const dayjs = require("dayjs");
66
+
67
+ // const a = dayjs("2023-01-01 11:11").startOf("day");
68
+ // const formattedDate = a.format("YYYY-MM-DD HH:mm:ss");
69
+
70
+ // const b = dayjs("2023-01-01").endOf("day");
71
+ // const formattedDate1 = b.format("YYYY-MM-DD HH:mm:ss");
72
+ // console.log(formattedDate, formattedDate1);
73
+
74
+ // functions and constants
75
+ // console.log("functions and constants");
76
+ // print(math.round(math.e, 3)); // 2.718
77
+ // print(math.atan2(3, -3) / math.pi); // 0.75
78
+ // print(math.log(10000, 10)); // 4
79
+ // print(math.sqrt(-4)); // 2i
80
+ // print(
81
+ // math.pow(
82
+ // [
83
+ // [-1, 2],
84
+ // [3, 1],
85
+ // ],
86
+ // 2
87
+ // )
88
+ // ); // [[7, 0], [0, 7]]
89
+ // print(math.derivative("x^2 + x", "x")); // 2 * x + 1
90
+ // console.log();
20
91
 
21
- function dangerouslySetXss(input) {
22
- if (!input) {
23
- return "";
92
+ // // expressions
93
+ // console.log("expressions");
94
+ // print(math.evaluate("1.2 * (2 + 4.5)")); // 7.8
95
+ // print(math.evaluate("12.7 cm to inch")); // 5 inch
96
+ // print(math.evaluate("sin(45 deg) ^ 2")); // 0.5
97
+ // print(math.evaluate("9 / 3 + 2i")); // 3 + 2i
98
+ // print(math.evaluate("det([-1, 2; 3, 1])")); // -7
99
+ // print(math.evaluate("NaN + '0.2'")); // -7
100
+ // console.log();
101
+
102
+ // // chained operations
103
+ // console.log("chained operations");
104
+ // const a = math.chain(3).add(4).multiply(2).done();
105
+ // print(a); // 14
106
+ // console.log();
107
+
108
+ // // mixed use of different data types in functions
109
+ // console.log("mixed use of data types");
110
+ // print(math.add(4, [5, 6])); // number + Array, [9, 10]
111
+ // print(math.multiply(math.unit("5 mm"), 3)); // Unit * number, 15 mm
112
+ // print(math.subtract([2, 3, 4], 5)); // Array - number, [-3, -2, -1]
113
+ // print(math.add(math.matrix([2, 3]), [4, 5])); // Matrix + Array, [6, 8]
114
+ // console.log();
115
+
116
+ // /**
117
+ // * Helper function to output a value in the console. Value will be formatted.
118
+ // * @param {*} value
119
+ // */
120
+ // function print(value) {
121
+ // const precision = 14;
122
+ // console.log(math.format(value, precision));
123
+ // }
124
+
125
+ // const math = require("mathjs");
126
+ // function print(value) {
127
+ // const precision = 14;
128
+ // console.log(math.format(value, precision));
129
+ // }
130
+
131
+ // console.log(performance.now());
132
+ // console.log(math.add(0.1, 0.2));
133
+ // console.log(performance.now());
134
+ // console.log(performance.now());
135
+ // console.log(0.1 + 0.2);
136
+ // console.log(performance.now());
137
+ // const BigNumber = require("bignumber.js");
138
+ // console.log(performance.now());
139
+ // const num1 = new BigNumber(0.1);
140
+ // const num2 = new BigNumber(0.2);
141
+
142
+ // const result = num1.plus(num2);
143
+
144
+ // console.log(result.toString());
145
+
146
+ // console.log(performance.now());
147
+
148
+ const Decimal = decimalExports;
149
+
150
+ function initNum(num1, num2) {
151
+ // 如果两个数都是非数字 那么直接返回0
152
+ if (isNaN(num1) && isNaN(num2)) {
153
+ return 0;
154
+ }
155
+ if (isNaN(num1)) {
156
+ return num2;
157
+ }
158
+ if (isNaN(num2)) {
159
+ return num1;
24
160
  }
25
- const escapedChars = {
26
- "&lt;": "<",
27
- "&gt;": ">",
28
- "&nbsp;": " ",
29
- "&amp;": "&",
30
- "&quot;": '"',
31
- };
32
-
33
- return input.replace(/&(amp|lt|gt|quot|nbsp);/g, (match) => {
34
- return escapedChars[match] || match;
35
- });
36
161
  }
37
162
 
38
- function dangerouslySetXss1(input) {
39
- if (!input) {
40
- return "";
163
+ function times(num1, num2) {
164
+ try {
165
+ const _num1 = num1 == null ? NaN : Number(num1);
166
+ const _num2 = num2 == null ? NaN : Number(num2);
167
+ // 如果两个数都是非数字 那么直接返回0
168
+ const result = initNum(_num1, _num2);
169
+ if (typeof result === "number") {
170
+ return result;
171
+ }
172
+ return new Decimal(_num1).mul(_num2).toNumber();
173
+ // return (isNaN(_num1) ? 0 : _num1) * (isNaN(_num2) ? 0 : _num2);
174
+ } catch (err) {
175
+ console.error("计算乘法出错", err);
176
+ return 0;
41
177
  }
42
- const escapedChars = {
43
- lt: "<",
44
- gt: ">",
45
- nbsp: " ",
46
- amp: "&",
47
- quot: '"',
48
- };
49
-
50
- return input.replace(/&(amp|lt|gt|quot|nbsp);/gi, (match, t) => {
51
- return escapedChars[t] || match;
52
- });
53
178
  }
54
179
 
55
- console.log(unescapeString("&amp;&amp;&amp;啊你"));
56
-
57
- console.log(dangerouslySetXss("&amp;&amp;&amp;啊你"));
180
+ console.log(times(78.11, 0.77));
181
+ console.log(times(7777777.77, 1.1));
182
+ // 7777777.77 * 1.1
183
+ const num1 = new Decimal("78.11");
58
184
 
59
- console.log(dangerouslySetXss1("&amp;&amp;&amp;啊你"));
60
- console.log(unescapeString("1、aa&gt;80%\n2、&gt;&lt;\n3、ss&lt;80%"));
61
- console.log(dangerouslySetXss("1、aa&gt;80%\n2、&gt;&lt;\n3、ss&lt;80%"));
62
- console.log(dangerouslySetXss1("1、aa&gt;80%\n2、&gt;&lt;\n3、ss&lt;80%"));
185
+ // console.log(num1.add(0.21).toNumber(), typeof num1.add(0.21).toNumber());
63
186
 
64
- const dayjs = dayjs$1;
187
+ // console.log(num1.sub(0.21).toNumber(), typeof num1.sub(0.21).toNumber());
65
188
 
66
- const a = dayjs("2023-01-01 11:11").startOf("day");
67
- const formattedDate = a.format("YYYY-MM-DD HH:mm:ss");
189
+ console.log(num1.mul(0.77).toNumber(), typeof num1.mul(0.21).toNumber());
190
+ Decimal.set({ precision: 5 });
191
+ console.log(
192
+ new Decimal(1).div(1.1).toNumber(),
193
+ typeof new Decimal(1).div(1.1).toNumber()
194
+ );
195
+ console.log(
196
+ new Decimal(1).dividedBy(1.1).toNumber(),
197
+ typeof new Decimal(1).dividedBy(1.1).toNumber()
198
+ );
68
199
 
69
- const b = dayjs("2023-01-01").endOf("day");
70
- const formattedDate1 = b.format("YYYY-MM-DD HH:mm:ss");
71
- console.log(formattedDate, formattedDate1);
200
+ console.log(
201
+ Number(new Decimal(1.1).toFixed(2)),
202
+ typeof Number(new Decimal(1.1).toFixed(2)).toFixed(2)
203
+ );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zmdms-utils",
3
- "version": "0.0.64",
3
+ "version": "0.0.66",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
package/src/baseUrl.ts CHANGED
@@ -61,10 +61,10 @@ export function getBaseUrl(processObj: any, options?: IOptions) {
61
61
  // 退出登录地址
62
62
  const logoutUrl: any = {
63
63
  dev: processObj[`${logoutKey}_DEV`] || "/login",
64
- test: processObj[`${logoutKey}_DEV`] || "/login",
64
+ test: processObj[`${logoutKey}_TEST`] || "/login",
65
65
  stage:
66
- processObj[`${logoutKey}_DEV`] || "http://testportal.cncico.com:8099/",
67
- prod: processObj[`${logoutKey}_DEV`] || "http://newportal.cncico.com/",
66
+ processObj[`${logoutKey}_STAGE`] || "http://testportal.cncico.com:8099/",
67
+ prod: processObj[`${logoutKey}_PROD`] || "http://newportal.cncico.com/",
68
68
  };
69
69
 
70
70
  const currentKey = ENV.toLowerCase() || "prod";
package/src/constants.ts CHANGED
@@ -31,3 +31,6 @@ export const TOKEN_KEY = (window as any).__TOKEN_KEY__ || "Cicoms-Auth";
31
31
  // 基础前缀
32
32
  // export const BASIC_KEY = "zmdms";
33
33
  export const BASIC_KEY = (window as any).__BASIC_KEY__ || "cicoms";
34
+
35
+ // 附件相关服务
36
+ export const FILE_SERVICE = (window as any).__FILE_SERVICE__ || "cicoms";
package/src/file.ts CHANGED
@@ -8,9 +8,11 @@ import {
8
8
  getFileExtension,
9
9
  isImageExtension,
10
10
  } from "./common";
11
- import { TOKEN_KEY, BASIC_KEY } from "./constants";
11
+ import { TOKEN_KEY, BASIC_KEY, FILE_SERVICE } from "./constants";
12
12
  import { AxiosResponse } from "axios";
13
13
 
14
+ const isZmdmsFileService = FILE_SERVICE === "zmdms";
15
+
14
16
  /**
15
17
  * 附件下载方法
16
18
  * @param fileId 附件id
@@ -169,37 +171,40 @@ export function previewFile(
169
171
  // 所以将文件名 与 文件id组合来生成不同的文件名
170
172
  previewFileName = `${filePreName}-${fileId}.${fileExtension}`;
171
173
 
172
- // 2023-12-30 修改成数字中心预览
173
- window.open(
174
- `${apiBaseURL}/api/cicoms-cicohr-org/cicomscicohr/v1/common/filePreview?attachId=${fileId}&${TOKEN_KEY}=${token}`
175
- );
174
+ if (!isZmdmsFileService) {
175
+ // 2023-12-30 修改成数字中心预览
176
+ window.open(
177
+ `${apiBaseURL}/api/cicoms-cicohr-org/cicomscicohr/v1/common/filePreview?attachId=${fileId}&${TOKEN_KEY}=${token}`
178
+ );
179
+ return;
180
+ }
176
181
 
177
182
  // 如果是图片 走批量预览接口
178
- // const isImage = isImageExtension(fileExtension);
179
- // if (isImage) {
180
- // const imgFiles = fileList.filter((item) => {
181
- // const { attachName, attachId } = item;
182
- // const [, fileExtension] = getFileExtension(attachName);
183
- // if (isImageExtension(fileExtension) && attachId !== fileId) {
184
- // return true;
185
- // }
186
- // return false;
187
- // });
188
- // let attachIds = imgFiles.map((item) => item.attachId).join(",");
189
- // // 批量图片预览
190
- // window.open(
191
- // `${apiBaseURL}/picturesAttchPreview?attachIds=${
192
- // attachIds ? `${fileId},${attachIds}` : fileId
193
- // }&${TOKEN_KEY}=${token}` +
194
- // (fileName ? `&titleName=${encodeURIComponent(previewFileName)}` : "")
195
- // );
196
- // } else {
197
- // // 普通预览
198
- // window.open(
199
- // `${apiBaseURL}/attchPreview?attachId=${fileId}&${TOKEN_KEY}=${token}&officePreviewType=pdf` +
200
- // (fileName ? `&titleName=${encodeURIComponent(previewFileName)}` : "")
201
- // );
202
- // }
183
+ const isImage = isImageExtension(fileExtension);
184
+ if (isImage) {
185
+ const imgFiles = fileList.filter((item) => {
186
+ const { attachName, attachId } = item;
187
+ const [, fileExtension] = getFileExtension(attachName);
188
+ if (isImageExtension(fileExtension) && attachId !== fileId) {
189
+ return true;
190
+ }
191
+ return false;
192
+ });
193
+ let attachIds = imgFiles.map((item) => item.attachId).join(",");
194
+ // 批量图片预览
195
+ window.open(
196
+ `${apiBaseURL}/picturesAttchPreview?attachIds=${
197
+ attachIds ? `${fileId},${attachIds}` : fileId
198
+ }&${TOKEN_KEY}=${token}` +
199
+ (fileName ? `&titleName=${encodeURIComponent(previewFileName)}` : "")
200
+ );
201
+ } else {
202
+ // 普通预览
203
+ window.open(
204
+ `${apiBaseURL}/attchPreview?attachId=${fileId}&${TOKEN_KEY}=${token}&officePreviewType=pdf` +
205
+ (fileName ? `&titleName=${encodeURIComponent(previewFileName)}` : "")
206
+ );
207
+ }
203
208
  }
204
209
 
205
210
  /**
@@ -323,11 +328,13 @@ export function createOriginalLink(
323
328
  // 所以将文件名 与 文件id组合来生成不同的文件名
324
329
  previewFileName = `${filePreName}-${fileId}.${fileExtension}`;
325
330
  // 2023-12-30 替换成数字中心的 预览接口
326
- return `${apiBaseURL}/api/cicoms-cicohr-org/cicomscicohr/v1/common/filePreview?attachId=${fileId}&${TOKEN_KEY}=${token}`;
327
- // return (
328
- // `${apiBaseURL}/attchPreview?attachId=${fileId}&${TOKEN_KEY}=${token}&officePreviewType=pdf` +
329
- // (fileName ? `&titleName=${encodeURIComponent(previewFileName)}` : "")
330
- // );
331
+ if (!isZmdmsFileService) {
332
+ return `${apiBaseURL}/api/cicoms-cicohr-org/cicomscicohr/v1/common/filePreview?attachId=${fileId}&${TOKEN_KEY}=${token}`;
333
+ }
334
+ return (
335
+ `${apiBaseURL}/attchPreview?attachId=${fileId}&${TOKEN_KEY}=${token}&officePreviewType=pdf` +
336
+ (fileName ? `&titleName=${encodeURIComponent(previewFileName)}` : "")
337
+ );
331
338
  }
332
339
 
333
340
  /**
package/src/test.js CHANGED
@@ -1,72 +1,72 @@
1
- function unescapeString(input) {
2
- if (!input) {
3
- return "";
4
- }
5
-
6
- const escapedChars = {
7
- "&amp;": "&",
8
- "&lt;": "<",
9
- "&gt;": ">",
10
- "&quot;": '"',
11
- "&#039;": "'",
12
- };
13
-
14
- return input.replace(/&(amp|lt|gt|quot|#039);/g, (match) => {
15
- return escapedChars[match] || match;
16
- });
17
- }
1
+ // function unescapeString(input) {
2
+ // if (!input) {
3
+ // return "";
4
+ // }
5
+
6
+ // const escapedChars = {
7
+ // "&amp;": "&",
8
+ // "&lt;": "<",
9
+ // "&gt;": ">",
10
+ // "&quot;": '"',
11
+ // "&#039;": "'",
12
+ // };
13
+
14
+ // return input.replace(/&(amp|lt|gt|quot|#039);/g, (match) => {
15
+ // return escapedChars[match] || match;
16
+ // });
17
+ // }
18
18
 
19
- function dangerouslySetXss(input) {
20
- if (!input) {
21
- return "";
22
- }
23
- const escapedChars = {
24
- "&lt;": "<",
25
- "&gt;": ">",
26
- "&nbsp;": " ",
27
- "&amp;": "&",
28
- "&quot;": '"',
29
- };
30
-
31
- return input.replace(/&(amp|lt|gt|quot|nbsp);/g, (match) => {
32
- return escapedChars[match] || match;
33
- });
34
- }
19
+ // function dangerouslySetXss(input) {
20
+ // if (!input) {
21
+ // return "";
22
+ // }
23
+ // const escapedChars = {
24
+ // "&lt;": "<",
25
+ // "&gt;": ">",
26
+ // "&nbsp;": " ",
27
+ // "&amp;": "&",
28
+ // "&quot;": '"',
29
+ // };
30
+
31
+ // return input.replace(/&(amp|lt|gt|quot|nbsp);/g, (match) => {
32
+ // return escapedChars[match] || match;
33
+ // });
34
+ // }
35
35
 
36
- function dangerouslySetXss1(input) {
37
- if (!input) {
38
- return "";
39
- }
40
- const escapedChars = {
41
- lt: "<",
42
- gt: ">",
43
- nbsp: " ",
44
- amp: "&",
45
- quot: '"',
46
- };
47
-
48
- return input.replace(/&(amp|lt|gt|quot|nbsp);/gi, (match, t) => {
49
- return escapedChars[t] || match;
50
- });
51
- }
36
+ // function dangerouslySetXss1(input) {
37
+ // if (!input) {
38
+ // return "";
39
+ // }
40
+ // const escapedChars = {
41
+ // lt: "<",
42
+ // gt: ">",
43
+ // nbsp: " ",
44
+ // amp: "&",
45
+ // quot: '"',
46
+ // };
47
+
48
+ // return input.replace(/&(amp|lt|gt|quot|nbsp);/gi, (match, t) => {
49
+ // return escapedChars[t] || match;
50
+ // });
51
+ // }
52
52
 
53
- console.log(unescapeString("&amp;&amp;&amp;啊你"));
53
+ // console.log(unescapeString("&amp;&amp;&amp;啊你"));
54
54
 
55
- console.log(dangerouslySetXss("&amp;&amp;&amp;啊你"));
55
+ // console.log(dangerouslySetXss("&amp;&amp;&amp;啊你"));
56
56
 
57
- console.log(dangerouslySetXss1("&amp;&amp;&amp;啊你"));
58
- console.log(unescapeString("1、aa&gt;80%\n2、&gt;&lt;\n3、ss&lt;80%"));
59
- console.log(dangerouslySetXss("1、aa&gt;80%\n2、&gt;&lt;\n3、ss&lt;80%"));
60
- console.log(dangerouslySetXss1("1、aa&gt;80%\n2、&gt;&lt;\n3、ss&lt;80%"));
57
+ // console.log(dangerouslySetXss1("&amp;&amp;&amp;啊你"));
58
+ // console.log(unescapeString("1、aa&gt;80%\n2、&gt;&lt;\n3、ss&lt;80%"));
59
+ // console.log(dangerouslySetXss("1、aa&gt;80%\n2、&gt;&lt;\n3、ss&lt;80%"));
60
+ // console.log(dangerouslySetXss1("1、aa&gt;80%\n2、&gt;&lt;\n3、ss&lt;80%"));
61
61
 
62
- const dayjs = require("dayjs");
62
+ // const dayjs = require("dayjs");
63
63
 
64
- const a = dayjs("2023-01-01 11:11").startOf("day");
65
- const formattedDate = a.format("YYYY-MM-DD HH:mm:ss");
64
+ // const a = dayjs("2023-01-01 11:11").startOf("day");
65
+ // const formattedDate = a.format("YYYY-MM-DD HH:mm:ss");
66
66
 
67
- const b = dayjs("2023-01-01").endOf("day");
68
- const formattedDate1 = b.format("YYYY-MM-DD HH:mm:ss");
69
- console.log(formattedDate, formattedDate1);
67
+ // const b = dayjs("2023-01-01").endOf("day");
68
+ // const formattedDate1 = b.format("YYYY-MM-DD HH:mm:ss");
69
+ // console.log(formattedDate, formattedDate1);
70
70
 
71
71
  // functions and constants
72
72
  // console.log("functions and constants");
@@ -142,26 +142,59 @@ console.log(formattedDate, formattedDate1);
142
142
 
143
143
  // console.log(performance.now());
144
144
 
145
- // const Decimal = require("decimal.js");
145
+ const Decimal = require("decimal.js");
146
+
147
+ function initNum(num1, num2) {
148
+ // 如果两个数都是非数字 那么直接返回0
149
+ if (isNaN(num1) && isNaN(num2)) {
150
+ return 0;
151
+ }
152
+ if (isNaN(num1)) {
153
+ return num2;
154
+ }
155
+ if (isNaN(num2)) {
156
+ return num1;
157
+ }
158
+ }
159
+
160
+ function times(num1, num2) {
161
+ try {
162
+ const _num1 = num1 == null ? NaN : Number(num1);
163
+ const _num2 = num2 == null ? NaN : Number(num2);
164
+ // 如果两个数都是非数字 那么直接返回0
165
+ const result = initNum(_num1, _num2);
166
+ if (typeof result === "number") {
167
+ return result;
168
+ }
169
+ return new Decimal(_num1).mul(_num2).toNumber();
170
+ // return (isNaN(_num1) ? 0 : _num1) * (isNaN(_num2) ? 0 : _num2);
171
+ } catch (err) {
172
+ console.error("计算乘法出错", err);
173
+ return 0;
174
+ }
175
+ }
146
176
 
147
- // const num1 = new Decimal("0.1");
177
+ console.log(times(78.11, 0.77));
178
+ console.log(times(7777777.77, 1.1));
179
+ // 7777777.77 * 1.1
180
+ const num1 = new Decimal("78.11");
148
181
 
149
182
  // console.log(num1.add(0.21).toNumber(), typeof num1.add(0.21).toNumber());
150
183
 
151
184
  // console.log(num1.sub(0.21).toNumber(), typeof num1.sub(0.21).toNumber());
152
185
 
153
- // console.log(num1.mul(0.21).toNumber(), typeof num1.mul(0.21).toNumber());
154
- // Decimal.set({ precision: 5 });
155
- // console.log(
156
- // new Decimal(1).div(1.1).toNumber(),
157
- // typeof new Decimal(1).div(1.1).toNumber()
158
- // );
159
- // console.log(
160
- // new Decimal(1).dividedBy(1.1).toNumber(),
161
- // typeof new Decimal(1).dividedBy(1.1).toNumber()
162
- // );
163
-
164
- // console.log(
165
- // Number(new Decimal(1.1).toFixed(2)),
166
- // typeof Number(new Decimal(1.1).toFixed(2)).toFixed(2)
167
- // );
186
+ console.log(num1.mul(0.77).toNumber(), typeof num1.mul(0.21).toNumber());
187
+ Decimal.set({ precision: 5 });
188
+ console.log(
189
+ new Decimal(1).div(1.1).toNumber(),
190
+ typeof new Decimal(1).div(1.1).toNumber()
191
+ );
192
+ console.log(
193
+ new Decimal(1).dividedBy(1.1).toNumber(),
194
+ typeof new Decimal(1).dividedBy(1.1).toNumber()
195
+ );
196
+
197
+ console.log(
198
+ Number(new Decimal(1.1).toFixed(2)),
199
+ typeof Number(new Decimal(1.1).toFixed(2)).toFixed(2)
200
+ );