MCPcopy Create free account
hub / github.com/cyclejs/cyclejs / setupZapping

Function setupZapping

devtool/src/graphSerializer.ts:200–232  ·  view source on GitHub ↗
([graph, zapSpeed]: [Dagre.Graph, ZapSpeed])

Source from the content-addressed store, hash-verified

198}
199
200function 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
234function zapVisit(nodeId: string, depth: number, graph: Dagre.Graph, registry: ZapRegistry) {
235 if (registry.has(nodeId)) {

Callers

nothing calls this directly

Calls 4

zapVisitFunction · 0.85
timeSpreadFunction · 0.85
zapSpeedToMillisecondsFunction · 0.85
createMethod · 0.80

Tested by

no test coverage detected