@lage-run/format-hrtime 0.1.4 → 0.1.6
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/formatDuration.js +14 -8
- package/lib/index.js +10 -4
- package/package.json +1 -2
package/lib/formatDuration.js
CHANGED
|
@@ -9,19 +9,25 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
formatDuration: ()
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
formatDuration: function() {
|
|
13
|
+
return formatDuration;
|
|
14
|
+
},
|
|
15
|
+
hrToSeconds: function() {
|
|
16
|
+
return hrToSeconds;
|
|
17
|
+
},
|
|
18
|
+
hrtimeDiff: function() {
|
|
19
|
+
return hrtimeDiff;
|
|
20
|
+
}
|
|
15
21
|
});
|
|
16
22
|
function formatDuration(seconds) {
|
|
17
23
|
const raw = parseFloat(seconds);
|
|
18
24
|
if (raw > 60) {
|
|
19
25
|
const minutes = Math.floor(raw / 60);
|
|
20
|
-
const
|
|
21
|
-
return `${minutes}m ${
|
|
26
|
+
const seconds = (raw - minutes * 60).toFixed(2);
|
|
27
|
+
return `${minutes}m ${seconds}s`;
|
|
22
28
|
} else {
|
|
23
|
-
const
|
|
24
|
-
return `${
|
|
29
|
+
const seconds = raw.toFixed(2);
|
|
30
|
+
return `${seconds}s`;
|
|
25
31
|
}
|
|
26
32
|
}
|
|
27
33
|
function hrToSeconds(hrtime) {
|
|
@@ -39,7 +45,7 @@ function hrtimeDiff(start = [
|
|
|
39
45
|
const nsec = end[1] - start[1];
|
|
40
46
|
if (nsec < 0) {
|
|
41
47
|
return [
|
|
42
|
-
sec - 1,
|
|
48
|
+
Math.max(0, sec - 1),
|
|
43
49
|
1e9 + nsec
|
|
44
50
|
];
|
|
45
51
|
}
|
package/lib/index.js
CHANGED
|
@@ -9,8 +9,14 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
formatDuration: ()
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
formatDuration: function() {
|
|
13
|
+
return _formatDuration.formatDuration;
|
|
14
|
+
},
|
|
15
|
+
hrToSeconds: function() {
|
|
16
|
+
return _formatDuration.hrToSeconds;
|
|
17
|
+
},
|
|
18
|
+
hrtimeDiff: function() {
|
|
19
|
+
return _formatDuration.hrtimeDiff;
|
|
20
|
+
}
|
|
15
21
|
});
|
|
16
|
-
const
|
|
22
|
+
const _formatDuration = require("./formatDuration.js");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lage-run/format-hrtime",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "hrtime formatter for Lage",
|
|
5
5
|
"repository": {
|
|
6
6
|
"url": "https://github.com/microsoft/lage"
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
"test": "jest",
|
|
15
15
|
"lint": "monorepo-scripts lint"
|
|
16
16
|
},
|
|
17
|
-
"devDependencies": {},
|
|
18
17
|
"publishConfig": {
|
|
19
18
|
"access": "public"
|
|
20
19
|
},
|