better integration and experimentalPushRecycling option

This commit is contained in:
Jörg Breitbart
2018-10-10 15:00:38 +02:00
parent 33a358033c
commit 751e2efa75
5 changed files with 29 additions and 12 deletions
+1 -1
View File
@@ -105,7 +105,7 @@ export class CircularList<T> extends EventEmitter implements ICircularList<T> {
* The callback gets the value at the current position to be overwritten.
* Return the new value from the callback.
*/
public pushRecycling(callback: (el: T | undefined) => T): void {
public pushRecycling(callback: (item: T | undefined) => T): void {
this._array[this._getCyclicIndex(this._length)] = callback(this._array[this._getCyclicIndex(this._length)]);
if (this._length === this._maxLength) {
this._startIndex++;
+1
View File
@@ -28,6 +28,7 @@ export interface ICircularList<T> extends IEventEmitter {
get(index: number): T | undefined;
set(index: number, value: T): void;
push(value: T): void;
pushRecycling(callback: (item: T | undefined) => T): void;
pop(): T | undefined;
splice(start: number, deleteCount: number, ...items: T[]): void;
trimStart(count: number): void;