param next export type QueueCallback = ( next : ( ) => void ) => void ; /**
 * Queues callbacks to be run.
 */ export class Queue { /**
     * Callbacks waiting to be run.
     */ private readonly queuedCallbacks : QueueCallback [ ] = [ ] ; param callback public add ( callback ? ) { if ( callback !== undefined ) { this . queuedCallbacks . push ( callback ) ; } } param onComplete public run ( onComplete ) { const callback = this . queuedCallbacks . shift ( ) ; if ( callback !== undefined ) { callback ( ( ) : void => { this . run ( onComplete ) ; } ) ; } else { onComplete ( ) ; } } /**
     * Removes any pending queued callbacks.
     */ public clear ( ) { this . queuedCallbacks . length = 0 ; } }