-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscreen-report.ts
More file actions
31 lines (26 loc) · 988 Bytes
/
screen-report.ts
File metadata and controls
31 lines (26 loc) · 988 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import type { CheckInput, FindingInput, SummaryInput } from '@/lib/format/types.js'
import type { Report } from '@/middleware/report/types.js'
import type { OutputStore } from './types.js'
// ---------------------------------------------------------------------------
// Exports
// ---------------------------------------------------------------------------
/**
* Create a {@link Report} instance that writes to an {@link OutputStore}
* for rendering by the `<Output />` component.
*
* @param store - The output store to push entries to.
* @returns A frozen Report instance compatible with `ctx.report`.
*/
export function createScreenReport(store: OutputStore): Report {
return Object.freeze({
check(input: CheckInput): void {
store.push({ kind: 'check', input })
},
finding(input: FindingInput): void {
store.push({ kind: 'finding', input })
},
summary(input: SummaryInput): void {
store.push({ kind: 'summary', input })
},
})
}