TrinetraLabs/Placebo_AI
0
1// Type definitions for Queue 4.5.12// Project: https://github.com/jessetane/queue3// Definitions by: Alex Miller <https://github.com/codex->4 5import { EventEmitter } from "events";6 7export interface Options {8 /**9 * Max number of jobs the queue should process concurrently.10 *11 * @default Infinity12 */13 concurrency?: number;14 15 /**16 * Milliseconds to wait for a job to execute its callback.17 *18 * @default 019 */20 timeout?: number;21 22 /**23 * Ensures the queue is always running if jobs are available. Useful in situations where you are using a queue only for concurrency control.24 *25 * @default false26 */27 autostart?: boolean;28 29 /**30 * An array to set job callback arguments on.31 *32 * @default null33 */34 results?: any[];35}36 37interface Queue extends EventEmitter {38 /**39 * Max number of jobs the queue should process concurrently.40 */41 concurrency: number;42 43 /**44 * Milliseconds to wait for a job to execute its callback.45 */46 timeout: number;47 48 /**49 * Ensures the queue is always running if jobs are available.50 */51 autostart: boolean;52 53 /**54 * An array to set job callback arguments on.55 */56 results: any[] | null;57 58 /**59 * Jobs pending + jobs to process.60 */61 readonly length: number;62 63 /**64 * Adds one or more elements to the end of the Queue and returns the new length of the Queue.65 *66 * @param workers New workers of the Queue.67 */68 push(...workers: QueueWorker[]): number;69 70 /**71 * Adds one or more elements to the front of the Queue and returns the new length of the Queue.72 *73 * @param workers Workers to insert at the start of the Queue.74 */75 unshift(...workers: QueueWorker[]): number;76 77 /**78 * Adds and/or removes elements from the queue.79 *80 * @param start The zero-based location in the Queue from which to start removing elements.81 * @param deleteCount The number of elements to remove.82 */83 splice(start: number, deleteCount?: number): Queue;84 85 /**86 * Adds and/or removes elements from the queue.87 *88 * @param start The zero-based location in the Queue from which to start removing elements.89 * @param deleteCount The number of elements to remove.90 * @param workers Workers to insert into the Queue in place of the deleted elements.91 */92 splice(start: number, deleteCount: number, ...workers: QueueWorker[]): Queue;93 94 /**95 * Removes the last element from the Queue and returns that element.96 */97 pop(): QueueWorker | undefined;98 99 /**100 * Removes the first element from the Queue and returns that element.101 */102 shift(): QueueWorker | undefined;103 104 /**105 * Extracts a section of the Queue and returns Queue.106 *107 * @param start The beginning of the specified portion of the Queue.108 * @param end The end of the specified portion of the Queue.109 */110 slice(start?: number, end?: number): Queue;111 112 /**113 * Reverses the order of the elements of the Queue in place.114 */115 reverse(): Queue;116 117 /**118 * Returns the first (least) index of an element within the Queue equal to the specified value, or -1 if none is found.119 *120 * @param searchElement The value to locate in the Queue.121 * @param fromIndex The Queue index at which to begin the search. If omitted, the search starts at index 0.122 */123 indexOf(searchElement: QueueWorker, fromIndex?: number): number;124 125 /**126 * Returns the last (greatest) index of an element within the Queue equal to the specified value, or -1 if none is found.127 *128 * @param searchElement The value to locate in the Queue.129 * @param fromIndex The Queue index at which to begin the search. If omitted, the search starts at the last index in the Queue.130 */131 lastIndexOf(searchElement: QueueWorker, fromIndex?: number): number;132 133 /**134 * Starts the queue.135 *136 * @param callback Callback to be called when the queue empties or when an error occurs.137 */138 start(callback?: (error?: Error) => void): void;139 140 /**141 * Stops the queue.142 */143 stop(): void;144 145 /**146 * Stop and empty the queue immediately.147 *148 * @param error error of why the stop has occurred, to be passed to start callback if supplied.149 */150 end(error?: Error): void;151}152 153interface QueueConstructor {154 (options?: Options): Queue;155 new (options?: Options): Queue;156}157 158declare const Queue: QueueConstructor;159 160export default Queue;161 162export interface QueueWorker {163 (callback?: QueueWorkerCallback): void;164 165 /**166 * Override queue timeout.167 */168 timeout?: number;169}170 171export interface QueueWorkerCallback {172 (error?: Error, data?: Object): void;173}174 