Skip to content

Commit 4192645

Browse files
livthomasMikeRyanDev
authored andcommitted
fix(Entity): Avoid for..in iteration in sorted state adapter (#805)
1 parent 779d689 commit 4192645

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

modules/entity/spec/sorted_state_adapter.spec.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,20 @@ describe('Sorted State Adapter', () => {
1111
let adapter: EntityStateAdapter<BookModel>;
1212
let state: EntityState<BookModel>;
1313

14+
beforeAll(() => {
15+
Object.defineProperty(Array.prototype, 'unwantedField', {
16+
enumerable: true,
17+
configurable: true,
18+
value: 'This should not appear anywhere',
19+
});
20+
});
21+
22+
afterAll(() => {
23+
Object.defineProperty(Array.prototype, 'unwantedField', {
24+
value: undefined,
25+
});
26+
});
27+
1428
beforeEach(() => {
1529
adapter = createEntityAdapter({
1630
selectId: (book: BookModel) => book.id,

modules/entity/src/sorted_state_adapter.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,7 @@ export function createSortedStateAdapter<T>(selectId: any, sort: any): any {
116116
const added: T[] = [];
117117
const updated: Update<T>[] = [];
118118

119-
for (let index in updates) {
120-
const update = updates[index];
119+
for (const update of updates) {
121120
if (update.id in state.entities) {
122121
updated.push(update);
123122
} else {

0 commit comments

Comments
 (0)