const DEFAULT_CIRCULAR_ARRAY_SIZE = 1024
/**
- * Array with a maximum length shifting items when full.
+ * Array with a maximum length and shifting items when full.
*/
export class CircularArray<T> extends Array<T> {
public size: number
}
}
+ /** @inheritdoc */
public push (...items: T[]): number {
const length = super.push(...items)
if (length > this.size) {
return this.length
}
+ /** @inheritdoc */
public unshift (...items: T[]): number {
const length = super.unshift(...items)
if (length > this.size) {
return this.length
}
+ /** @inheritdoc */
public concat (...items: Array<T | ConcatArray<T>>): CircularArray<T> {
const concatenatedCircularArray = super.concat(
items as T[]
return concatenatedCircularArray
}
+ /** @inheritdoc */
public splice (start: number, deleteCount?: number, ...items: T[]): T[] {
let itemsRemoved: T[]
if (arguments.length >= 3 && deleteCount !== undefined) {