diff --git a/demo/start.js b/demo/start.js index 78f1ff1d..278c572f 100644 --- a/demo/start.js +++ b/demo/start.js @@ -5,7 +5,6 @@ * This file is the entry point for browserify. */ -const cp = require('child_process'); const path = require('path'); const webpack = require('webpack'); const startServer = require('./server.js'); diff --git a/src/common/CircularList.ts b/src/common/CircularList.ts index af4d8af5..90891b72 100644 --- a/src/common/CircularList.ts +++ b/src/common/CircularList.ts @@ -154,24 +154,22 @@ export class CircularList extends EventEmitter implements ICircularList { this._length -= deleteCount; } - if (items && items.length) { - // Add items - for (let i = this._length - 1; i >= start; i--) { - this._array[this._getCyclicIndex(i + items.length)] = this._array[this._getCyclicIndex(i)]; - } - for (let i = 0; i < items.length; i++) { - this._array[this._getCyclicIndex(start + i)] = items[i]; - } + // Add items + for (let i = this._length - 1; i >= start; i--) { + this._array[this._getCyclicIndex(i + items.length)] = this._array[this._getCyclicIndex(i)]; + } + for (let i = 0; i < items.length; i++) { + this._array[this._getCyclicIndex(start + i)] = items[i]; + } - // Adjust length as needed - if (this._length + items.length > this._maxLength) { - const countToTrim = (this._length + items.length) - this._maxLength; - this._startIndex += countToTrim; - this._length = this._maxLength; - this.emitMayRemoveListeners('trim', countToTrim); - } else { - this._length += items.length; - } + // Adjust length as needed + if (this._length + items.length > this._maxLength) { + const countToTrim = (this._length + items.length) - this._maxLength; + this._startIndex += countToTrim; + this._length = this._maxLength; + this.emitMayRemoveListeners('trim', countToTrim); + } else { + this._length += items.length; } }