MCPcopy Create free account
hub / github.com/FlashpointProject/launcher / push

Method push

src/back/util/EventQueue.ts:31–43  ·  view source on GitHub ↗

* Add en event to the end of the queue. * * @param event Event function to add. * @param returnPromise If a promise should be returned. * @returns Nothing or a promise that resolves after the event is executed, * or rejects if it rejects or throws an error.

(event: EventFunction, returnPromise?: boolean)

Source from the content-addressed store, hash-verified

29 * or rejects if it rejects or throws an error.
30 */
31 push(event: EventFunction, returnPromise?: boolean): Promise<void> | void {
32 // Wrap the event, and create a promise, if a promise should be returned
33 const [wrappedEvent, promise] = returnPromise ? wrapEvent(event) : [undefined, undefined];
34 // Push end off early if max size is reached
35 if (this.queue.length === this.maxSize) {
36 this.queue.shift();
37 }
38 // Add event to the end of the queue
39 this.queue.push(wrappedEvent || event);
40 this.update();
41 // Return promise (if any)
42 return promise;
43 }
44
45 private update() {
46 if (!this.isExecuting && this.queue.length > 0) {

Callers

nothing calls this directly

Calls 3

updateMethod · 0.95
wrapEventFunction · 0.85
pushMethod · 0.65

Tested by

no test coverage detected