Skip to content
This repository has been archived by the owner on Oct 25, 2022. It is now read-only.

Commit

Permalink
Avoid maximum stack size exceeded errors
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanoverna committed May 4, 2022
1 parent 3258ff0 commit 6cf9d50
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/local/EntitiesRepo.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ import JsonApiEntity from './JsonApiEntity';
const entitiesToStorePerCacheKey = 5000;

function payloadEntities(payload) {
const accumulator = [];
let accumulator = [];

if (payload.data) {
if (Array.isArray(payload.data)) {
accumulator.push(...payload.data);
accumulator = [...accumulator, ...payload.data];
} else {
accumulator.push(payload.data);
}
}

if (payload.included) {
accumulator.push(...payload.included);
accumulator = [...accumulator, ...payload.included];
}

return accumulator;
Expand Down

0 comments on commit 6cf9d50

Please sign in to comment.