MCPcopy Create free account
hub / github.com/ngrx/platform / merge

Function merge

modules/entity/src/sorted_state_adapter.ts:210–242  ·  view source on GitHub ↗
(models: any[], state: any)

Source from the content-addressed store, hash-verified

208
209 function merge(models: T[], state: R): void;
210 function merge(models: any[], state: any): void {
211 models.sort(sort);
212
213 const ids: any[] = [];
214
215 let i = 0;
216 let j = 0;
217
218 while (i < models.length && j < state.ids.length) {
219 const model = models[i];
220 const modelId = selectIdValue(model, selectId);
221 const entityId = state.ids[j];
222 const entity = state.entities[entityId];
223
224 if (sort(model, entity) <= 0) {
225 ids.push(modelId);
226 i++;
227 } else {
228 ids.push(entityId);
229 j++;
230 }
231 }
232
233 if (i < models.length) {
234 state.ids = ids.concat(models.slice(i).map(selectId));
235 } else {
236 state.ids = ids.concat(state.ids.slice(j));
237 }
238
239 models.forEach((model, i) => {
240 state.entities[selectId(model)] = model;
241 });
242 }
243
244 return {
245 removeOne,

Callers 12

manager.spec.tsFile · 0.85
toActionsMethod · 0.85
mergeEffectsFunction · 0.85
onInitFunction · 0.85
constructorFunction · 0.85
constructorMethod · 0.85
addManyMutablyFunction · 0.85
setOneMutablyFunction · 0.85
updateManyMutablyFunction · 0.85
UserEffectsClass · 0.85

Calls 3

selectIdValueFunction · 0.90
mapMethod · 0.80
selectIdFunction · 0.50

Tested by

no test coverage detected