PageSourceSearch

https://www.big-foot-dumpsters.com/cp/resources/views/test_slot/slot/SlotGroup.js

js big-foot-dumpsters.com collected 2026-10-04 09:01:58 UTC 1,926 bytes, 71 lines download raw bytes

1import { forever } from "./utils.js";
2
3export default function SlotGroup() {
4
5    // <${Slot} group=${grp} flow=... />
6
7    const slots = [];
8    const ress = [];
9    const prms = [];
10    const done = new Set();
11
12    this.size = 0;
13    /// add is called by the slot when a group is specified:
14    this.add = slot => {
15        if (slots.includes(slot)) {
16            throw new Error("slot already in group - cannot add again");
17        }
18        slots.push(slot);
19        return this.size++;
20    };
21
22    this.onCapture = slot_id => {
23        if (typeof ress[slot_id] === "function") {
24            ress[slot_id]();
25        }
26    };
27    this.onEnd = slot_id => {
28        this.onCapture(slot_id);
29        const slot = slots[slot_id];
30        if (!slot.running) {
31            done.add(slot_id);
32        }
33    };
34
35    /// register a promise for the next capture call:
36    this.nextCapture = slot_id => {
37        prms[slot_id] = new Promise(
38            resolve =>
39                ress[slot_id] = () =>
40                    resolve(slot_id));
41        return prms[slot_id];
42    };
43
44    const flow_exited = slot_id => {
45        return done.has(slot_id);
46    };
47
48    this.answer = async (message) => {
49        console.log("broadcasting ", message);
50        for (let slot_id = 0; slot_id < slots.length; slot_id++) {
51            await slots[slot_id].answer(message);
52            if (!flow_exited(slot_id)) {
53                await this.nextCapture(slot_id);
54            }
55        }
56    };
57
58    this.answerAsync = async (message) => {
59        console.log("broadcasting ", message);
60        const promises = [];
61        for (let slot_id = 0; slot_id < slots.length; slot_id++) {
62            promises.push(slots[slot_id].answer(message).then(() => {
63                if (!flow_exited(slot_id)) {
64                    return this.nextCapture(slot_id);
65                }
66            }));
67        }
68        await Promise.all(promises);
69    };
70
71};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.