--- /dev/null
+class SlotIndexer{
+ constructor(_updates,_buffer){
+ // updates is an array of slot objects
+ // buffer is an instanceof slotbuffer constructor object in slotbuffer.js
+ this.updates = _updates;
+ if(_buffer && _buffer instanceof SlotBuffer){
+ this.buffer = _buffer;
+ }else{
+ throw new Error("Argument error Buffer should be an instance of SlotBuffer");
+ }
+ this.firstslotseqnum = this.updates[0].getSequenceNumber();
+ }
+
+ getSlot(seqnum){
+ if(seqnum >= this.firstslotseqnum){
+ var offset = seqnum - this.firstslotseqnum;
+ if(offset >= this.updates.length){
+ throw new Error('Invalid Slot Sequence Number Reference');
+ }else{
+ return this.updates[offset];
+ }
+ }else{
+ return this.buffer.getSlot(seqnum);
+ }
+ }
+
+}
\ No newline at end of file