6 Matching Annotations
  1. Dec 2023
  2. Oct 2021
    1. QueueStore
    2. export interface QueueInterface {   count(): number;   dequeue?(): any;   enqueue(...args: any): void;   flush(): any[];   reset(): void;   setFifo(fifo: boolean): void;   setLifo(lifo: boolean): void;   truncate(length: number): void; } export class queue {   protected elements: any[];   protected fifo = true;   constructor(…args: any) {     this.elements = […args];   }   count() {     return this.elements.length;   }   dequeue?(): any {     if (this.fifo) {       return this.elements.shift();     }     return this.elements.pop();   }   enqueue(…args: any) {     return this.elements.push(…args);   }   // Like dequeue but will flush all queued elements   flush(): any[] {     let elms = [];     while (this.count()) {       elms.push(this.dequeue());     }     return elms;   }   setFifo(fifo = true) {     this.fifo = fifo;   }   setLifo(lifo = true) {     this.fifo = !lifo;   }   reset(): void {     this.truncate(0);   }   truncate(length: number) {     if (Number.isInteger(length) && length > -1) {       this.elements.length = length;     }   } } export default queue;
  3. Feb 2021
  4. Apr 2020