Skip to content

Commit 36dd36f

Browse files
committed
Iterate only own keys when clearing memoize cache
Replace a for..in loop over `this` with `Object.keys(this).forEach` to ensure only the object's own enumerable properties are inspected when clearing memoize caches. This avoids iterating inherited/prototype properties that could lead to unexpected behavior when resetting cached entries in workers/grouper/src/index.ts.
1 parent f5307d6 commit 36dd36f

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

workers/grouper/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,15 +159,15 @@ export default class GrouperWorker extends Worker {
159159
*/
160160
const memoizeCachePrefix = 'memoizeCache:';
161161

162-
for (const key in this) {
162+
Object.keys(this).forEach(key => {
163163
if (key.startsWith(memoizeCachePrefix)) {
164164
const cache = this[key] as any;
165165

166166
if (cache && typeof cache.reset === 'function') {
167167
cache.reset();
168168
}
169169
}
170-
}
170+
});
171171
}
172172

173173
/**

0 commit comments

Comments
 (0)