@cobol-ts/time 0.0.14 → 0.0.16

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.
Files changed (2) hide show
  1. package/README.md +16 -10
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,18 +1,24 @@
1
1
  # @cobol-ts/time
2
2
 
3
- ## Purpose
3
+ Provide an injectable wall-clock millisecond function and a Promise-returning delay helper.
4
4
 
5
- A minimal abstraction over the current wall-clock timestamp plus an asynchronous delay helper. `TimeService` is a zero-argument function returning milliseconds, allowing code that needs the current time to accept a substitutable function rather than hard-code `Date.now()` calls.
5
+ This is wall-clock time, not a monotonic nanosecond benchmark timer.
6
6
 
7
- ## API
7
+ ## Example
8
8
 
9
- `dateTimeService` returns `new Date().getTime()`; `useTime()` provides a `TimeService` instance. `delay(ms)` returns a Promise resolved after the specified timeout.
9
+ ```typescript
10
+ import {dateTimeService, delay} from '@cobol-ts/time'
10
11
 
11
- ```ts
12
- import {dateTimeService, delay} from '@cobol-ts/time';
13
- const startedAt = dateTimeService();
14
- await delay(10);
15
- const elapsedMs = dateTimeService() - startedAt;
12
+ const startedAt = dateTimeService()
13
+ await delay(10)
16
14
  ```
17
15
 
18
- Wall-clock time is not a monotonic performance timer. For benchmarking, use the measurement facilities in [cursor-loader-benchmark](../../cursor-loader/cursor-loader-benchmark/README.md). Implementation: [`src/time.service.ts`](src/time.service.ts).
16
+ Inject `TimeService = () => number` when testing code that reads the current time. `dateTimeService()` returns epoch milliseconds, so do not use it to benchmark nanosecond-scale record operations.
17
+
18
+ ## Source and tests
19
+
20
+ **Public entry points:** [time.service.ts](./src/time.service.ts).
21
+
22
+ **Tests:** [time.service.spec.ts](src/time.service.spec.ts)
23
+
24
+ **Related:** [@cobol-ts/cursor-loader-benchmark](../../cursor-loader/cursor-loader-benchmark/README.md) · [@cobol-ts/metrics](../metrics/README.md).
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cobol-ts/time",
3
3
  "description": "A timeservice for the @cobol-ts project",
4
- "version": "0.0.14",
4
+ "version": "0.0.16",
5
5
  "main": "dist/index",
6
6
  "types": "dist/index",
7
7
  "browserslist": {