@injectivelabs/utils 0.0.52 → 0.0.53
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/dist/time.d.ts +0 -5
- package/dist/time.d.ts.map +1 -1
- package/dist/time.js +1 -55
- package/dist/time.js.map +1 -1
- package/package.json +2 -3
package/dist/time.d.ts
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import { BigNumberInBase, BigNumber } from './classes';
|
|
2
2
|
export declare const SECONDS_IN_A_DAY: BigNumber;
|
|
3
|
-
export declare const formatDurationFromSecondsToString: (seconds: number) => string;
|
|
4
|
-
export declare const formatDurationFromSeconds: ({ duration, fullSuffix, }: {
|
|
5
|
-
duration: number;
|
|
6
|
-
fullSuffix?: boolean | undefined;
|
|
7
|
-
}) => string;
|
|
8
3
|
export declare const convertTimestampToMilliseconds: (timestamp: number) => number;
|
|
9
4
|
export declare const getUTCDateFromTimestamp: (timestamp: number) => string;
|
|
10
5
|
export declare const tomorrow: () => BigNumber;
|
package/dist/time.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAEtD,eAAO,MAAM,gBAAgB,EAAE,SAAuC,CAAA;AAEtE,eAAO,MAAM,8BAA8B,cAAe,MAAM,WAa/D,CAAA;AAED,eAAO,MAAM,uBAAuB,cAAe,MAAM,WAMxD,CAAA;AAED,eAAO,MAAM,QAAQ,QAAO,SAC8C,CAAA;AAE1E,eAAO,MAAM,cAAc,QAAO,MAAuC,CAAA;AAEzE,eAAO,MAAM,WAAW,QAAO,MAC2C,CAAA;AAE1E,eAAO,MAAM,QAAQ,oBAAc,MAGpB,CAAA;AAEf,eAAO,MAAM,iCAAiC,kBAC7B,eAAe,KAC7B,MAIF,CAAA"}
|
package/dist/time.js
CHANGED
|
@@ -1,62 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getEndDateStringFromTimeInSeconds = exports.pastDays = exports.past24Hours = exports.todayInSeconds = exports.tomorrow = exports.getUTCDateFromTimestamp = exports.convertTimestampToMilliseconds = exports.
|
|
4
|
-
const date_fns_1 = require("date-fns");
|
|
3
|
+
exports.getEndDateStringFromTimeInSeconds = exports.pastDays = exports.past24Hours = exports.todayInSeconds = exports.tomorrow = exports.getUTCDateFromTimestamp = exports.convertTimestampToMilliseconds = exports.SECONDS_IN_A_DAY = void 0;
|
|
5
4
|
const classes_1 = require("./classes");
|
|
6
5
|
exports.SECONDS_IN_A_DAY = new classes_1.BigNumber(60 * 60 * 24);
|
|
7
|
-
const formatDurationFromSecondsToString = (seconds) => {
|
|
8
|
-
const duration = (0, date_fns_1.intervalToDuration)({ start: 0, end: seconds * 1000 });
|
|
9
|
-
const countDownDisplaySuffix = {
|
|
10
|
-
xDays: 'd',
|
|
11
|
-
xHours: 'h',
|
|
12
|
-
xMinutes: 'm',
|
|
13
|
-
xSeconds: 's',
|
|
14
|
-
};
|
|
15
|
-
return (0, date_fns_1.formatDuration)(duration, {
|
|
16
|
-
format: ['days', 'hours', 'minutes', 'seconds'],
|
|
17
|
-
locale: {
|
|
18
|
-
formatDistance: (type, count) => {
|
|
19
|
-
const formattedCount = count < 10 ? `0${count}` : count;
|
|
20
|
-
return `${formattedCount}${countDownDisplaySuffix[type]}`;
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
exports.formatDurationFromSecondsToString = formatDurationFromSecondsToString;
|
|
26
|
-
const formatDurationFromSeconds = ({ duration, fullSuffix, }) => {
|
|
27
|
-
const { days, hours, minutes, seconds } = (0, date_fns_1.intervalToDuration)({
|
|
28
|
-
start: 0,
|
|
29
|
-
end: duration * 1000,
|
|
30
|
-
});
|
|
31
|
-
const suffix = fullSuffix
|
|
32
|
-
? ['day', 'hour', 'min', 'sec']
|
|
33
|
-
: ['d', 'h', 'm', 's'];
|
|
34
|
-
let removeLeadingZeroDuration = true;
|
|
35
|
-
return ([days, hours, minutes, seconds]
|
|
36
|
-
.map((duration, index) => {
|
|
37
|
-
if (duration !== 0) {
|
|
38
|
-
removeLeadingZeroDuration = false;
|
|
39
|
-
}
|
|
40
|
-
if (fullSuffix) {
|
|
41
|
-
const durationSuffix = duration && duration > 1 ? 's' : '';
|
|
42
|
-
return removeLeadingZeroDuration && duration === 0
|
|
43
|
-
? undefined
|
|
44
|
-
: `${duration} ${suffix[index]}${durationSuffix}`;
|
|
45
|
-
}
|
|
46
|
-
return removeLeadingZeroDuration && duration === 0
|
|
47
|
-
? undefined
|
|
48
|
-
: `${duration}${suffix[index]}`;
|
|
49
|
-
})
|
|
50
|
-
.filter((duration) => duration)
|
|
51
|
-
.join(' ')
|
|
52
|
-
.replace(' 0h 0m 0s', '')
|
|
53
|
-
.replace(' 0m 0s', '')
|
|
54
|
-
.replace(' 0s', '')
|
|
55
|
-
.replace(' 0 hour 0 minute 0 second', '')
|
|
56
|
-
.replace(' 0 minute 0 second', '')
|
|
57
|
-
.replace(' 0 second', ''));
|
|
58
|
-
};
|
|
59
|
-
exports.formatDurationFromSeconds = formatDurationFromSeconds;
|
|
60
6
|
const convertTimestampToMilliseconds = (timestamp) => {
|
|
61
7
|
if (timestamp.toString().length > 13) {
|
|
62
8
|
return parseInt(timestamp.toString().slice(0, 13), 10);
|
package/dist/time.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time.js","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"time.js","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":";;;AAAA,uCAAsD;AAEzC,QAAA,gBAA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,CAAA;AAA5D,QAAA,cAAc,kBAA8C;AAElE,MAAM,WAAW,GAAG,GAAW,EAAE,CACtC,IAAI,yBAAe,CAAC,IAAA,sBAAc,GAAE,CAAC,CAAC,KAAK,CAAC,wBAAgB,CAAC,CAAC,QAAQ,EAAE,CAAA;AAD7D,QAAA,WAAW,eACkD;AAEnE,MAAM,QAAQ,GAAG,CAAC,GAAG,GAAG,CAAC,EAAU,EAAE,CAC1C,IAAI,yBAAe,CAAC,IAAA,sBAAc,GAAE,CAAC;KAClC,KAAK,CAAC,wBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;KAClC,QAAQ,EAAE,CAAA;AAHF,QAAA,QAAQ,YAGN;AAER,MAAM,iCAAiC,GAAG,CAC/C,aAA8B,EACtB,EAAE;IACV,MAAM,WAAW,GAAG,IAAI,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,CAAA;IAE7D,OAAO,WAAW,CAAC,cAAc,CAAC,OAAO,CAAC,CAAA;AAC5C,CAAC,CAAA;AANY,QAAA,iCAAiC,qCAM7C"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@injectivelabs/utils",
|
|
3
3
|
"description": "List of utils and helper functions that can be reused throughout Injective's projects.",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.53",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -31,10 +31,9 @@
|
|
|
31
31
|
"@injectivelabs/ts-types": "^0.0.38",
|
|
32
32
|
"axios": "^0.21.1",
|
|
33
33
|
"bignumber.js": "^9.0.1",
|
|
34
|
-
"date-fns": "^2.28.0",
|
|
35
34
|
"link-module-alias": "^1.2.0",
|
|
36
35
|
"shx": "^0.3.2",
|
|
37
36
|
"store2": "^2.12.0"
|
|
38
37
|
},
|
|
39
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "4f85ee58cb72f6f908ed45cb2cdcf9501efe7629"
|
|
40
39
|
}
|