@thumbmarkjs/thumbmarkjs 1.7.1 → 1.7.2

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.
@@ -51,6 +51,7 @@ describe('raceAllPerformance', () => {
51
51
  expect(results).toHaveLength(1);
52
52
  expect(results[0].value).toBe('ok');
53
53
  expect(typeof results[0].elapsed).toBe('number');
54
+ expect(results[0].error).toBeUndefined();
54
55
  });
55
56
 
56
57
  test('returns timeout fallback when promise does not settle in time', async () => {
@@ -63,6 +64,7 @@ describe('raceAllPerformance', () => {
63
64
 
64
65
  expect(results).toHaveLength(1);
65
66
  expect(results[0].value).toBe('timeout');
67
+ expect(results[0].error).toBe('timeout');
66
68
  });
67
69
 
68
70
  test('does not reject the whole batch when one promise rejects', async () => {
@@ -77,6 +79,8 @@ describe('raceAllPerformance', () => {
77
79
 
78
80
  expect(results).toHaveLength(2);
79
81
  expect(results[0].value).toBe('timeout');
82
+ expect(results[0].error).toBe('component failed');
80
83
  expect(results[1].value).toBe('ok');
84
+ expect(results[1].error).toBeUndefined();
81
85
  });
82
86
  });
@@ -10,6 +10,7 @@ export function delay<T>(t: number, val: T): DelayedPromise<T> {
10
10
  export interface RaceResult<T> {
11
11
  value: T;
12
12
  elapsed?: number;
13
+ error?: string;
13
14
  }
14
15
 
15
16
  export function raceAllPerformance<T>(
@@ -24,15 +25,15 @@ export function raceAllPerformance<T>(
24
25
  p.then((value) => ({
25
26
  value,
26
27
  elapsed: performance.now() - startTime,
27
- })).catch(() => ({
28
- // Keep behavior aligned with timeout: a failed component falls back
29
- // to timeoutVal instead of rejecting the entire Promise.all.
28
+ })).catch((err: unknown) => ({
30
29
  value: timeoutVal,
31
30
  elapsed: performance.now() - startTime,
31
+ error: err instanceof Error ? err.message : String(err),
32
32
  })),
33
33
  delay(timeoutTime, timeoutVal).then((value) => ({
34
34
  value,
35
35
  elapsed: performance.now() - startTime,
36
+ error: 'timeout' as string,
36
37
  })),
37
38
  ]);
38
39
  })