([graph, zapSpeed]: [Dagre.Graph, ZapSpeed])
| 198 | } |
| 199 | |
| 200 | function setupZapping([graph, zapSpeed]: [Dagre.Graph, ZapSpeed]): Diagram { |
| 201 | const registry: ZapRegistry = new ZapRegistry(); |
| 202 | const sourceNodes: Array<string> = graph['sources'](); |
| 203 | sourceNodes.forEach(id => { |
| 204 | zapVisit(id, 0, graph, registry); |
| 205 | }); |
| 206 | |
| 207 | const rawZap$ = xs.create<Zap>({ |
| 208 | start(listener: Listener<Zap>) { |
| 209 | for (let i = 0, N = registry.records.length; i < N; i++) { |
| 210 | const record = registry.records[i]; |
| 211 | const id = record.id; |
| 212 | record.stream.setDebugListener({ |
| 213 | next: (value) => listener.next({ id, type: 'next', value } as Zap), |
| 214 | error: (err) => listener.next({ id, type: 'error', value: err } as Zap), |
| 215 | complete: () => listener.next({ id, type: 'complete' } as Zap), |
| 216 | }); |
| 217 | } |
| 218 | }, |
| 219 | stop() {}, |
| 220 | }); |
| 221 | |
| 222 | const actualZaps$ = rawZap$ |
| 223 | .compose(timeSpread(zapSpeedToMilliseconds(zapSpeed))); |
| 224 | |
| 225 | const stopZaps$ = actualZaps$ |
| 226 | .mapTo([]).compose(debounce<Array<Zap>>(200)) |
| 227 | .startWith([]); |
| 228 | |
| 229 | const zaps$ = xs.merge(actualZaps$, stopZaps$); |
| 230 | |
| 231 | return { graph, zaps$ }; |
| 232 | } |
| 233 | |
| 234 | function zapVisit(nodeId: string, depth: number, graph: Dagre.Graph, registry: ZapRegistry) { |
| 235 | if (registry.has(nodeId)) { |
nothing calls this directly
no test coverage detected