@flighthq/clock 0.1.0 → 0.2.1-next.410.a23f189

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/package.json CHANGED
@@ -1,6 +1,11 @@
1
1
  {
2
2
  "name": "@flighthq/clock",
3
- "version": "0.1.0",
3
+ "version": "0.2.1-next.410.a23f189",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "https://github.com/flighthq/flight.git",
7
+ "directory": "packages/clock"
8
+ },
4
9
  "type": "module",
5
10
  "main": "dist/index.js",
6
11
  "types": "dist/index.d.ts",
@@ -27,8 +32,8 @@
27
32
  "clean:dist": "tsx ../../scripts/clean-package-dist.ts"
28
33
  },
29
34
  "dependencies": {
30
- "@flighthq/signals": "0.1.0",
31
- "@flighthq/types": "0.1.0"
35
+ "@flighthq/signals": "0.2.1-next.410.a23f189",
36
+ "@flighthq/types": "0.2.1-next.410.a23f189"
32
37
  },
33
38
  "devDependencies": {
34
39
  "typescript": "^5.3.0"
@@ -29,6 +29,17 @@ describe('advanceClock', () => {
29
29
  expect(clock.elapsed).toBe(0);
30
30
  });
31
31
 
32
+ it('composes scale down a 3-level hierarchy — grandparent to parent to child', () => {
33
+ const grandparent = createClock({ scale: 2 });
34
+ const parent = createChildClock(grandparent, { scale: 3 });
35
+ const child = createChildClock(parent, { scale: 0.5 });
36
+ advanceClock(grandparent, 1);
37
+ expect(grandparent.deltaTime).toBe(2); // 1 * 2
38
+ expect(parent.deltaTime).toBe(6); // 2 * 3
39
+ expect(child.deltaTime).toBe(3); // 6 * 0.5
40
+ expect(child.elapsed).toBe(3);
41
+ });
42
+
32
43
  it('composes scale down the hierarchy — a child rate is the product of the chain', () => {
33
44
  const parent = createClock({ scale: 2 });
34
45
  const child = createChildClock(parent, { scale: 0.5 });
@@ -56,6 +67,22 @@ describe('advanceClock', () => {
56
67
  expect(received).toEqual([1]); // 0.5 * 2
57
68
  });
58
69
 
70
+ it('applies a negative deltaTime, producing negative deltaTime and decreasing elapsed', () => {
71
+ const clock = createClock();
72
+ advanceClock(clock, 1);
73
+ expect(clock.elapsed).toBe(1);
74
+ advanceClock(clock, -0.5);
75
+ expect(clock.deltaTime).toBe(-0.5);
76
+ expect(clock.elapsed).toBe(0.5);
77
+ });
78
+
79
+ it('applies a negative scale, reversing the effective delta direction', () => {
80
+ const clock = createClock({ scale: -1 });
81
+ advanceClock(clock, 1);
82
+ expect(clock.deltaTime).toBe(-1);
83
+ expect(clock.elapsed).toBe(-1);
84
+ });
85
+
59
86
  it('does not emit or throw when signals are not enabled', () => {
60
87
  const clock = createClock();
61
88
  expect(() => advanceClock(clock, 1)).not.toThrow();