@blocklet/launcher-util 2.1.17 → 2.1.18
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/lib/util.js +0 -15
- package/package.json +2 -2
package/lib/util.js
CHANGED
|
@@ -3,22 +3,8 @@ require('moment/locale/zh-cn');
|
|
|
3
3
|
const moment = require('moment');
|
|
4
4
|
const joinURL = require('url-join');
|
|
5
5
|
const get = require('lodash.get');
|
|
6
|
-
const { BN, fromUnitToToken, fromTokenToUnit } = require('@ocap/util');
|
|
7
6
|
const { TIME_LOCALE } = require('./constant');
|
|
8
7
|
|
|
9
|
-
const calculatePrice = (duration, unitPrice, from) => {
|
|
10
|
-
// eslint-disable-next-line no-param-reassign
|
|
11
|
-
from = from || new Date();
|
|
12
|
-
|
|
13
|
-
const diffDays = moment(from).add(duration.value, duration.unit).diff(moment(from), 'days');
|
|
14
|
-
|
|
15
|
-
const unitPriceBN = new BN(fromTokenToUnit(unitPrice));
|
|
16
|
-
const diffDaysBN = new BN(diffDays);
|
|
17
|
-
const total = unitPriceBN.mul(diffDaysBN).toString();
|
|
18
|
-
|
|
19
|
-
return Number(fromUnitToToken(total).toString());
|
|
20
|
-
};
|
|
21
|
-
|
|
22
8
|
const formatPeriod = (duration) => {
|
|
23
9
|
const value = Number(duration.slice(0, duration.length - 1));
|
|
24
10
|
const unit = duration[duration.length - 1];
|
|
@@ -102,7 +88,6 @@ const isDateExpired = (expirationDate) => !!expirationDate && new Date(expiratio
|
|
|
102
88
|
|
|
103
89
|
module.exports = {
|
|
104
90
|
formatPeriod,
|
|
105
|
-
calculatePrice,
|
|
106
91
|
prettyDurationUnit,
|
|
107
92
|
prettyDuration,
|
|
108
93
|
formatDatetime,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/launcher-util",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.18",
|
|
4
4
|
"description": "Common constants",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"constant"
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"jest": "^27.5.1"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "841fd2762e81306ab33b042b3cf8fe89229acbc1"
|
|
50
50
|
}
|