Browse Source

Fixes mru history truncation

main
Eric Amodio 1 year ago
parent
commit
bdbab69ab9
1 changed files with 4 additions and 4 deletions
  1. +4
    -4
      src/system/mru.ts

+ 4
- 4
src/system/mru.ts View File

@ -1,7 +1,7 @@
export class MRU<T> {
private stack: T[] = [];
constructor(public readonly maxSize: number = 10, private readonly compare?: (a: T, b: T) => boolean) {}
constructor(public readonly maxSize: number = 10, private readonly comparator?: (a: T, b: T) => boolean) {}
get count(): number {
return this.stack.length;
@ -14,10 +14,10 @@ export class MRU {
add(item: T): void {
const index =
this.compare != null ? this.stack.findIndex(i => this.compare!(item, i)) : this.stack.indexOf(item);
this.comparator != null ? this.stack.findIndex(i => this.comparator!(item, i)) : this.stack.indexOf(item);
if (this._position != null && this._position > 0) {
this.stack = this.stackpan>.slice(0, this._position + 1);
if (this._position > 0) {
this.stack.splice(0, this._position);
this._position = 0;
}

Loading…
Cancel
Save