PageSourceSearch

https://www.shatura.com/local/app/js/utils/classes/queue.js

js shatura.com collected 2026-10-02 04:59:03 UTC 1,876 bytes, 73 lines download raw bytes

1class __queue {
2    counter
3    name;
4    queue;
5    finish_callback;
6    heap;
7
8    constructor(name = 'QUEUE') {
9        this.heap = {};
10        this.name = name;
11        __app.log('creating new __queue object with name <' + this.name + '>');
12        this.queue = [];
13    };
14
15    setFinishCallback(callback) {
16        this.finish_callback = callback;
17    };
18
19    addToQueue(action, params = {}) {
20        this.queue.push({
21            action: action,
22            params: params
23        });
24    };
25
26    addToQueueWithoutOverlapping(code, action, params = {}) {
27
28        if (!this.heap[code]) {
29
30            this.queue.push({
31                action: action,
32                params: params,
33                code: code
34            });
35
36            this.heap[code] = true;
37        } else {
38            __app.log('<' + this.name + ' | ' + code + '> ' + ' already exists in queue');
39        }
40    };
41
42    runQueue() {
43
44        this.counter = 0;
45
46        __app.log('<' + this.name + '> ' + 'queue running...');
47
48        this.queue.reverse();
49        this.nextQueueItem();
50    };
51
52    nextQueueItem() {
53        if (this.queue.length > 0) {
54            __app.log('<' + this.name + '> ' + 'next queue item');
55            __app.log('<' + this.name + '> ' + 'queue size = ' + this.queue.length);
56            var queue_item = this.queue.pop();
57
58            if (queue_item.code) {
59                __app.log('<' + this.name + ' | ' + queue_item.code + '> ' + 'queue size = ' + this.queue.length);
60                this.heap[queue_item.code] = false;
61            }
62
63            queue_item.action.apply(this, [queue_item.params]);
64            this.counter++;
65
66        } else this.finishQueue();
67    };
68
69    finishQueue() {
70        if (typeof this.finish_callback === "function" && this.counter > 0) this.finish_callback();
71        __app.log('<' + this.name + '> ' + 'queue finished');
72    }
73}

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.