3 var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
7 var SlotIndexer = function () {
8 function SlotIndexer(_updates, _buffer) {
9 _classCallCheck(this, SlotIndexer);
11 // updates is an array of slot objects
12 // buffer is an instanceof slotbuffer constructor object in slotbuffer.js
13 this.updates = _updates;
14 if (_buffer && _buffer instanceof SlotBuffer) {
15 this.buffer = _buffer;
17 throw new Error("Argument error Buffer should be an instance of SlotBuffer");
19 this.firstslotseqnum = this.updates[0].getSequenceNumber();
22 _createClass(SlotIndexer, [{
24 value: function getSlot(seqnum) {
25 if (seqnum >= this.firstslotseqnum) {
26 var offset = seqnum - this.firstslotseqnum;
27 if (offset >= this.updates.length) {
28 throw new Error('Invalid Slot Sequence Number Reference');
30 return this.updates[offset];
33 return this.buffer.getSlot(seqnum);