@@ -69,9 +69,7 @@ export function createSortedStateAdapter<T, Id extends EntityId>(
69
69
) : void {
70
70
newEntities = ensureEntitiesArray ( newEntities )
71
71
72
- const existingKeys = new Set < Id > (
73
- existingIds ?? ( getCurrent ( state . ids ) as Id [ ] ) ,
74
- )
72
+ const existingKeys = new Set < Id > ( existingIds ?? getCurrent ( state . ids ) )
75
73
76
74
const models = newEntities . filter (
77
75
( model ) => ! existingKeys . has ( selectIdValue ( model , selectId ) ) ,
@@ -175,7 +173,7 @@ export function createSortedStateAdapter<T, Id extends EntityId>(
175
173
return false
176
174
}
177
175
178
- for ( let i = 0 ; i < a . length && i < b . length ; i ++ ) {
176
+ for ( let i = 0 ; i < a . length ; i ++ ) {
179
177
if ( a [ i ] === b [ i ] ) {
180
178
continue
181
179
}
@@ -191,20 +189,20 @@ export function createSortedStateAdapter<T, Id extends EntityId>(
191
189
replacedIds ?: boolean ,
192
190
) => void
193
191
194
- const mergeInsertion : MergeFunction = (
192
+ const mergeFunction : MergeFunction = (
195
193
state ,
196
194
addedItems ,
197
195
appliedUpdates ,
198
196
replacedIds ,
199
197
) => {
200
- const currentEntities = getCurrent ( state . entities ) as Record < Id , T >
201
- const currentIds = getCurrent ( state . ids ) as Id [ ]
198
+ const currentEntities = getCurrent ( state . entities )
199
+ const currentIds = getCurrent ( state . ids )
202
200
203
201
const stateEntities = state . entities as Record < Id , T >
204
202
205
- let ids = currentIds
203
+ let ids : Iterable < Id > = currentIds
206
204
if ( replacedIds ) {
207
- ids = Array . from ( new Set ( currentIds ) )
205
+ ids = new Set ( currentIds )
208
206
}
209
207
210
208
let sortedEntities : T [ ] = [ ]
@@ -241,8 +239,6 @@ export function createSortedStateAdapter<T, Id extends EntityId>(
241
239
}
242
240
}
243
241
244
- const mergeFunction : MergeFunction = mergeInsertion
245
-
246
242
return {
247
243
removeOne,
248
244
removeMany,
0 commit comments