import { IFluidDataStoreRuntime , IChannelAttributes , IChannelFactory , } from "@fluidframework/datastore-definitions" ; import { ConsensusOrderedCollection } from "./consensusOrderedCollection" ; import { ConsensusQueueFactory } from "./consensusOrderedCollectionFactory" ; import { IOrderedCollection } from "./interfaces" ; import { SnapshotableArray } from "./snapshotableArray" ; /**
 * An JS array based queue implementation that is the backing data structure for ConsensusQueue
 */ class SnapshotableQueue < T > extends SnapshotableArray < T > implements IOrderedCollection < T > { public add ( value ) { this . data . push ( value ) ; } public remove ( ) { if ( this . size ( ) === 0 ) { throw new Error ( "SnapshotableQueue is empty" ) ; } return this . data . shift ( ) as T ; } } /**
 * Implementation of a consensus stack
 *
 * An derived type of ConsensusOrderedCollection with a queue as the backing data and order.
 */ export class ConsensusQueue < T = any > extends ConsensusOrderedCollection < T > { param runtime param id returns public static create < T = any > ( runtime , id ? ) { return runtime . createChannel ( id , ConsensusQueueFactory . Type ) as ConsensusQueue < T > ; } returns public static getFactory ( ) { return new ConsensusQueueFactory ( ) ; } /**
     * Constructs a new consensus queue. If the object is non-local an id and service interfaces will
     * be provided
     */ public constructor ( id , runtime , attributes ) { super ( id , runtime , attributes , new SnapshotableQueue < T > ( ) ) ; } }