Skip to content

Commit

Permalink
Return key instead of value
Browse files Browse the repository at this point in the history
  • Loading branch information
chfoidl committed Sep 1, 2022
1 parent 040bd3d commit 5301932
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/map/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export abstract class LRUMap<
}
}

public set(key: K, item: I): I[] {
public set(key: K, item: I): K[] {
// Check if entry exists.
const existingEntry = this.keymap.get(key);
if (existingEntry) {
Expand Down Expand Up @@ -70,7 +70,7 @@ export abstract class LRUMap<
return this.evict();
}

protected shift(): I | null {
protected shift(): K | null {
const entry = this.oldest;

if (entry) {
Expand All @@ -91,7 +91,7 @@ export abstract class LRUMap<

this._length--;

return entry.item;
return entry.key;
}

return null;
Expand Down Expand Up @@ -129,7 +129,7 @@ export abstract class LRUMap<
this.newest = entry;
}

protected abstract evict(): I[];
protected abstract evict(): K[];

public [Symbol.iterator]() {
return new EntryIterator(this.oldest);
Expand Down
2 changes: 1 addition & 1 deletion src/map/limit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class LimitBasedLRUMap<K extends Key, V extends Value> extends LRUMap<
}
}

protected evict(): LRUItem<V>[] {
protected evict() {
if (this._length > this.limit) {
return [this.shift()];
}
Expand Down

0 comments on commit 5301932

Please sign in to comment.