@lage-run/format-hrtime 0.1.8 → 0.1.9
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
CHANGED
|
@@ -2,8 +2,5 @@ export declare function formatDuration(seconds: string): string;
|
|
|
2
2
|
export declare function hrToSeconds(hrtime: [number, number]): string;
|
|
3
3
|
/**
|
|
4
4
|
* calculates the difference of two hrtime values
|
|
5
|
-
* @param start
|
|
6
|
-
* @param end
|
|
7
|
-
* @returns
|
|
8
5
|
*/
|
|
9
6
|
export declare function hrtimeDiff(start?: [number, number], end?: [number, number]): [number, number];
|
package/lib/formatDuration.js
CHANGED
|
@@ -23,12 +23,11 @@ function formatDuration(seconds) {
|
|
|
23
23
|
const raw = parseFloat(seconds);
|
|
24
24
|
if (raw > 60) {
|
|
25
25
|
const minutes = Math.floor(raw / 60);
|
|
26
|
-
const
|
|
27
|
-
return `${minutes}m ${
|
|
28
|
-
} else {
|
|
29
|
-
const seconds = raw.toFixed(2);
|
|
30
|
-
return `${seconds}s`;
|
|
26
|
+
const sec = (raw - minutes * 60).toFixed(2);
|
|
27
|
+
return `${minutes}m ${sec}s`;
|
|
31
28
|
}
|
|
29
|
+
const sec = raw.toFixed(2);
|
|
30
|
+
return `${sec}s`;
|
|
32
31
|
}
|
|
33
32
|
function hrToSeconds(hrtime) {
|
|
34
33
|
const raw = hrtime[0] + hrtime[1] / 1e9;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/formatDuration.ts"],"sourcesContent":["export function formatDuration(seconds: string): string {\n const raw = parseFloat(seconds);\n if (raw > 60) {\n const minutes = Math.floor(raw / 60);\n const
|
|
1
|
+
{"version":3,"sources":["../src/formatDuration.ts"],"sourcesContent":["export function formatDuration(seconds: string): string {\n const raw = parseFloat(seconds);\n if (raw > 60) {\n const minutes = Math.floor(raw / 60);\n const sec = (raw - minutes * 60).toFixed(2);\n return `${minutes}m ${sec}s`;\n }\n const sec = raw.toFixed(2);\n return `${sec}s`;\n}\n\nexport function hrToSeconds(hrtime: [number, number]): string {\n const raw = hrtime[0] + hrtime[1] / 1e9;\n return raw.toFixed(2);\n}\n\n/**\n * calculates the difference of two hrtime values\n */\nexport function hrtimeDiff(start: [number, number] = [0, 0], end: [number, number] = [0, 0]): [number, number] {\n const sec = end[0] - start[0];\n const nsec = end[1] - start[1];\n\n if (nsec < 0) {\n return [Math.max(0, sec - 1), 1e9 + nsec];\n }\n\n return [sec, nsec];\n}\n"],"names":["formatDuration","hrToSeconds","hrtimeDiff","seconds","raw","parseFloat","minutes","Math","floor","sec","toFixed","hrtime","start","end","nsec","max"],"mappings":";;;;;;;;;;;QAAgBA;eAAAA;;QAWAC;eAAAA;;QAQAC;eAAAA;;;AAnBT,SAASF,eAAeG,OAAe;IAC5C,MAAMC,MAAMC,WAAWF;IACvB,IAAIC,MAAM,IAAI;QACZ,MAAME,UAAUC,KAAKC,KAAK,CAACJ,MAAM;QACjC,MAAMK,MAAM,AAACL,CAAAA,MAAME,UAAU,EAAC,EAAGI,OAAO,CAAC;QACzC,OAAO,GAAGJ,QAAQ,EAAE,EAAEG,IAAI,CAAC,CAAC;IAC9B;IACA,MAAMA,MAAML,IAAIM,OAAO,CAAC;IACxB,OAAO,GAAGD,IAAI,CAAC,CAAC;AAClB;AAEO,SAASR,YAAYU,MAAwB;IAClD,MAAMP,MAAMO,MAAM,CAAC,EAAE,GAAGA,MAAM,CAAC,EAAE,GAAG;IACpC,OAAOP,IAAIM,OAAO,CAAC;AACrB;AAKO,SAASR,WAAWU,QAA0B;IAAC;IAAG;CAAE,EAAEC,MAAwB;IAAC;IAAG;CAAE;IACzF,MAAMJ,MAAMI,GAAG,CAAC,EAAE,GAAGD,KAAK,CAAC,EAAE;IAC7B,MAAME,OAAOD,GAAG,CAAC,EAAE,GAAGD,KAAK,CAAC,EAAE;IAE9B,IAAIE,OAAO,GAAG;QACZ,OAAO;YAACP,KAAKQ,GAAG,CAAC,GAAGN,MAAM;YAAI,MAAMK;SAAK;IAC3C;IAEA,OAAO;QAACL;QAAKK;KAAK;AACpB"}
|