@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.
@@ -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: [number, number], end: [number, number]): [number, number];
9
+ export declare function hrtimeDiff(start?: [number, number], end?: [number, number]): [number, number];
@@ -1,37 +1,50 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hrtimeDiff = exports.hrToSeconds = exports.formatDuration = void 0;
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 seconds = (raw - minutes * 60).toFixed(2);
9
- return `${minutes}m ${seconds}s`;
10
- }
11
- else {
12
- const seconds = raw.toFixed(2);
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
- exports.hrToSeconds = hrToSeconds;
22
- /**
23
- * calculates the difference of two hrtime values
24
- * @param start
25
- * @param end
26
- * @returns
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 [sec - 1, 1e9 + nsec];
41
+ return [
42
+ sec - 1,
43
+ 1e9 + nsec
44
+ ];
33
45
  }
34
- return [sec, nsec];
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", { value: true });
3
- exports.hrtimeDiff = exports.hrToSeconds = exports.formatDuration = void 0;
4
- var formatDuration_1 = require("./formatDuration");
5
- Object.defineProperty(exports, "formatDuration", { enumerable: true, get: function () { return formatDuration_1.formatDuration; } });
6
- Object.defineProperty(exports, "hrToSeconds", { enumerable: true, get: function () { return formatDuration_1.hrToSeconds; } });
7
- Object.defineProperty(exports, "hrtimeDiff", { enumerable: true, get: function () { return formatDuration_1.hrtimeDiff; } });
8
- //# sourceMappingURL=index.js.map
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.2",
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,OAAO,CAAC,CAAC,CAAC,CAAC;QAChD,OAAO,GAAG,OAAO,KAAK,OAAO,GAAG,CAAC;KAClC;SAAM;QACL,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAC/B,OAAO,GAAG,OAAO,GAAG,CAAC;KACtB;AACH,CAAC;AAVD,wCAUC;AAED,SAAgB,WAAW,CAAC,MAAwB;IAClD,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;IACxC,OAAO,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACxB,CAAC;AAHD,kCAGC;AAED;;;;;GAKG;AACH,SAAgB,UAAU,CAAC,KAAuB,EAAE,GAAqB;IACvE,MAAM,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAC9B,MAAM,IAAI,GAAG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