@lage-run/format-hrtime 0.1.2 → 0.1.4
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.d.ts +1 -1
- package/lib/formatDuration.js +34 -21
- package/lib/index.d.ts +1 -1
- package/lib/index.js +15 -7
- package/package.json +3 -2
- package/lib/formatDuration.js.map +0 -1
- package/lib/index.js.map +0 -1
package/lib/formatDuration.d.ts
CHANGED
|
@@ -6,4 +6,4 @@ export declare function hrToSeconds(hrtime: [number, number]): string;
|
|
|
6
6
|
* @param end
|
|
7
7
|
* @returns
|
|
8
8
|
*/
|
|
9
|
-
export declare function hrtimeDiff(start
|
|
9
|
+
export declare function hrtimeDiff(start?: [number, number], end?: [number, number]): [number, number];
|
package/lib/formatDuration.js
CHANGED
|
@@ -1,37 +1,50 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
formatDuration: ()=>formatDuration,
|
|
13
|
+
hrToSeconds: ()=>hrToSeconds,
|
|
14
|
+
hrtimeDiff: ()=>hrtimeDiff
|
|
15
|
+
});
|
|
4
16
|
function formatDuration(seconds) {
|
|
5
17
|
const raw = parseFloat(seconds);
|
|
6
18
|
if (raw > 60) {
|
|
7
19
|
const minutes = Math.floor(raw / 60);
|
|
8
|
-
const
|
|
9
|
-
return `${minutes}m ${
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return `${seconds}s`;
|
|
20
|
+
const seconds1 = (raw - minutes * 60).toFixed(2);
|
|
21
|
+
return `${minutes}m ${seconds1}s`;
|
|
22
|
+
} else {
|
|
23
|
+
const seconds2 = raw.toFixed(2);
|
|
24
|
+
return `${seconds2}s`;
|
|
14
25
|
}
|
|
15
26
|
}
|
|
16
|
-
exports.formatDuration = formatDuration;
|
|
17
27
|
function hrToSeconds(hrtime) {
|
|
18
28
|
const raw = hrtime[0] + hrtime[1] / 1e9;
|
|
19
29
|
return raw.toFixed(2);
|
|
20
30
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
function hrtimeDiff(start, end) {
|
|
31
|
+
function hrtimeDiff(start = [
|
|
32
|
+
0,
|
|
33
|
+
0
|
|
34
|
+
], end = [
|
|
35
|
+
0,
|
|
36
|
+
0
|
|
37
|
+
]) {
|
|
29
38
|
const sec = end[0] - start[0];
|
|
30
39
|
const nsec = end[1] - start[1];
|
|
31
40
|
if (nsec < 0) {
|
|
32
|
-
return [
|
|
41
|
+
return [
|
|
42
|
+
sec - 1,
|
|
43
|
+
1e9 + nsec
|
|
44
|
+
];
|
|
33
45
|
}
|
|
34
|
-
return [
|
|
46
|
+
return [
|
|
47
|
+
sec,
|
|
48
|
+
nsec
|
|
49
|
+
];
|
|
35
50
|
}
|
|
36
|
-
exports.hrtimeDiff = hrtimeDiff;
|
|
37
|
-
//# sourceMappingURL=formatDuration.js.map
|
package/lib/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { formatDuration, hrToSeconds, hrtimeDiff } from "./formatDuration";
|
|
1
|
+
export { formatDuration, hrToSeconds, hrtimeDiff } from "./formatDuration.js";
|
package/lib/index.js
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
Object.defineProperty(
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
formatDuration: ()=>_formatDurationJs.formatDuration,
|
|
13
|
+
hrToSeconds: ()=>_formatDurationJs.hrToSeconds,
|
|
14
|
+
hrtimeDiff: ()=>_formatDurationJs.hrtimeDiff
|
|
15
|
+
});
|
|
16
|
+
const _formatDurationJs = 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.4",
|
|
4
4
|
"description": "hrtime formatter for Lage",
|
|
5
5
|
"repository": {
|
|
6
6
|
"url": "https://github.com/microsoft/lage"
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
"scripts": {
|
|
12
12
|
"build": "tsc",
|
|
13
13
|
"start": "tsc -w --preserveWatchOutput",
|
|
14
|
-
"test": "jest"
|
|
14
|
+
"test": "jest",
|
|
15
|
+
"lint": "monorepo-scripts lint"
|
|
15
16
|
},
|
|
16
17
|
"devDependencies": {},
|
|
17
18
|
"publishConfig": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"formatDuration.js","sourceRoot":"","sources":["../src/formatDuration.ts"],"names":[],"mappings":";;;AAAA,SAAgB,cAAc,CAAC,OAAe;IAC5C,MAAM,GAAG,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IAChC,IAAI,GAAG,GAAG,EAAE,EAAE;QACZ,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC;QACrC,MAAM,OAAO,GAAG,CAAC,GAAG,GAAG,OAAO,GAAG,EAAE,CAAC,CAAC,OAA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