@@ -69,9 +69,7 @@ export function createSortedStateAdapter<T, Id extends EntityId>(
6969 ) : void {
7070 newEntities = ensureEntitiesArray ( newEntities )
7171
72- const existingKeys = new Set < Id > (
73- existingIds ?? ( getCurrent ( state . ids ) as Id [ ] ) ,
74- )
72+ const existingKeys = new Set < Id > ( existingIds ?? getCurrent ( state . ids ) )
7573
7674 const models = newEntities . filter (
7775 ( model ) => ! existingKeys . has ( selectIdValue ( model , selectId ) ) ,
@@ -175,7 +173,7 @@ export function createSortedStateAdapter<T, Id extends EntityId>(
175173 return false
176174 }
177175
178- for ( let i = 0 ; i < a . length && i < b . length ; i ++ ) {
176+ for ( let i = 0 ; i < a . length ; i ++ ) {
179177 if ( a [ i ] === b [ i ] ) {
180178 continue
181179 }
@@ -191,20 +189,20 @@ export function createSortedStateAdapter<T, Id extends EntityId>(
191189 replacedIds ?: boolean ,
192190 ) => void
193191
194- const mergeInsertion : MergeFunction = (
192+ const mergeFunction : MergeFunction = (
195193 state ,
196194 addedItems ,
197195 appliedUpdates ,
198196 replacedIds ,
199197 ) => {
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 )
202200
203201 const stateEntities = state . entities as Record < Id , T >
204202
205- let ids = currentIds
203+ let ids : Iterable < Id > = currentIds
206204 if ( replacedIds ) {
207- ids = Array . from ( new Set ( currentIds ) )
205+ ids = new Set ( currentIds )
208206 }
209207
210208 let sortedEntities : T [ ] = [ ]
@@ -241,8 +239,6 @@ export function createSortedStateAdapter<T, Id extends EntityId>(
241239 }
242240 }
243241
244- const mergeFunction : MergeFunction = mergeInsertion
245-
246242 return {
247243 removeOne,
248244 removeMany,
0 commit comments