Skip to content

Commit

Permalink
enhance(inmemory-lru): use for-loop instead of Array.from
Browse files Browse the repository at this point in the history
  • Loading branch information
ardatan committed Dec 12, 2024
1 parent 2b1d063 commit 354cdbd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/two-adults-vanish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-mesh/cache-inmemory-lru': patch
---

Use for-loop instead of `Array.from`
8 changes: 7 additions & 1 deletion packages/cache/inmemory-lru/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ export default class InMemoryLRUCache<V = any> implements KeyValueCache<V>, Disp
}

getKeysByPrefix(prefix: string) {
return Array.from(this.lru.keys()).filter(key => key.startsWith(prefix));
const keysWithPrefix = [];
for (const key of this.lru.keys()) {
if (key.startsWith(prefix)) {
keysWithPrefix.push(key);
}
}
return keysWithPrefix;
}

[DisposableSymbols.dispose]() {
Expand Down

0 comments on commit 354cdbd

Please sign in to comment.