better integration and experimentalPushRecycling option
This commit is contained in:
@@ -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++;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user