complete-common 2.30.0 → 2.31.1

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,7 +6,8 @@
6
6
  /**
7
7
  * Helper function to get the number of elapsed seconds since a starting time.
8
8
  *
9
- * This function always returns a whole number (using `Math.floor` on the result).
9
+ * By default, this function will return a whole number (using `Math.floor` on the result), but this
10
+ * can be disabled with the "roundToInteger" parameter.
10
11
  *
11
12
  * For example:
12
13
  *
@@ -16,5 +17,5 @@
16
17
  * const elapsedSeconds = getElapsedSeconds(startTime);
17
18
  * ```
18
19
  */
19
- export declare function getElapsedSeconds(startTime: number): number;
20
+ export declare function getElapsedSeconds(startTime: number, roundToInteger?: boolean): number;
20
21
  //# sourceMappingURL=time.d.ts.map
@@ -6,7 +6,8 @@
6
6
  /**
7
7
  * Helper function to get the number of elapsed seconds since a starting time.
8
8
  *
9
- * This function always returns a whole number (using `Math.floor` on the result).
9
+ * By default, this function will return a whole number (using `Math.floor` on the result), but this
10
+ * can be disabled with the "roundToInteger" parameter.
10
11
  *
11
12
  * For example:
12
13
  *
@@ -16,5 +17,5 @@
16
17
  * const elapsedSeconds = getElapsedSeconds(startTime);
17
18
  * ```
18
19
  */
19
- export declare function getElapsedSeconds(startTime: number): number;
20
+ export declare function getElapsedSeconds(startTime: number, roundToInteger?: boolean): number;
20
21
  //# sourceMappingURL=time.d.ts.map
@@ -6,7 +6,8 @@
6
6
  /**
7
7
  * Helper function to get the number of elapsed seconds since a starting time.
8
8
  *
9
- * This function always returns a whole number (using `Math.floor` on the result).
9
+ * By default, this function will return a whole number (using `Math.floor` on the result), but this
10
+ * can be disabled with the "roundToInteger" parameter.
10
11
  *
11
12
  * For example:
12
13
  *
@@ -16,5 +17,5 @@
16
17
  * const elapsedSeconds = getElapsedSeconds(startTime);
17
18
  * ```
18
19
  */
19
- export declare function getElapsedSeconds(startTime: number): number;
20
+ export declare function getElapsedSeconds(startTime: number, roundToInteger?: boolean): number;
20
21
  //# sourceMappingURL=time.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../src/functions/time.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAM3D"}
1
+ {"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../src/functions/time.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,EACjB,cAAc,UAAO,GACpB,MAAM,CAMR"}
package/dist/index.cjs CHANGED
@@ -666,11 +666,11 @@ function truncateString(string, maxLength) {
666
666
  return string.slice(0, maxLength);
667
667
  }
668
668
 
669
- function getElapsedSeconds(startTime) {
669
+ function getElapsedSeconds(startTime, roundToInteger = true) {
670
670
  const endTime = Date.now();
671
671
  const elapsedMilliseconds = endTime - startTime;
672
672
  const elapsedSeconds = elapsedMilliseconds / 1e3;
673
- return Math.floor(elapsedSeconds);
673
+ return roundToInteger ? Math.floor(elapsedSeconds) : elapsedSeconds;
674
674
  }
675
675
 
676
676
  function* tupleEntries(tuple) {
package/dist/index.mjs CHANGED
@@ -664,11 +664,11 @@ function truncateString(string, maxLength) {
664
664
  return string.slice(0, maxLength);
665
665
  }
666
666
 
667
- function getElapsedSeconds(startTime) {
667
+ function getElapsedSeconds(startTime, roundToInteger = true) {
668
668
  const endTime = Date.now();
669
669
  const elapsedMilliseconds = endTime - startTime;
670
670
  const elapsedSeconds = elapsedMilliseconds / 1e3;
671
- return Math.floor(elapsedSeconds);
671
+ return roundToInteger ? Math.floor(elapsedSeconds) : elapsedSeconds;
672
672
  }
673
673
 
674
674
  function* tupleEntries(tuple) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "complete-common",
3
- "version": "2.30.0",
3
+ "version": "2.31.1",
4
4
  "description": "Helper functions for TypeScript projects.",
5
5
  "homepage": "https://complete-ts.github.io/",
6
6
  "bugs": {
@@ -32,7 +32,7 @@
32
32
  "test": "bun test ./tests"
33
33
  },
34
34
  "devDependencies": {
35
- "@types/node": "26.0.1",
35
+ "@types/node": "26.1.0",
36
36
  "complete-node": "18.0.0",
37
37
  "typedoc": "0.28.19",
38
38
  "typedoc-plugin-markdown": "4.12.0",
@@ -7,7 +7,8 @@
7
7
  /**
8
8
  * Helper function to get the number of elapsed seconds since a starting time.
9
9
  *
10
- * This function always returns a whole number (using `Math.floor` on the result).
10
+ * By default, this function will return a whole number (using `Math.floor` on the result), but this
11
+ * can be disabled with the "roundToInteger" parameter.
11
12
  *
12
13
  * For example:
13
14
  *
@@ -17,10 +18,13 @@
17
18
  * const elapsedSeconds = getElapsedSeconds(startTime);
18
19
  * ```
19
20
  */
20
- export function getElapsedSeconds(startTime: number): number {
21
+ export function getElapsedSeconds(
22
+ startTime: number,
23
+ roundToInteger = true,
24
+ ): number {
21
25
  const endTime = Date.now();
22
26
  const elapsedMilliseconds = endTime - startTime;
23
27
  const elapsedSeconds = elapsedMilliseconds / 1000;
24
28
 
25
- return Math.floor(elapsedSeconds);
29
+ return roundToInteger ? Math.floor(elapsedSeconds) : elapsedSeconds;
26
30
  }