6 Matching Annotations
- Dec 2023
- Oct 2021
-
www.kylehq.com www.kylehq.com
-
QueueStore
-
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;
-
- Feb 2021
-
github.com github.com
-
It's an implementation of the command pattern in Ruby.
-
- Apr 2020
-
github.com github.com
-
The aim of this list is to document all Markdown syntax variations (rather than implementations).
-