Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksandr Bunin committed Sep 16, 2024
1 parent 92cdf63 commit e927425
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/core/hydration-store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,11 @@ export default class HydrationStore {
return sanitize(`{"store":${shallowStringify(store)},"data":${shallowStringify(data)}}`);

function shallowStringify(obj: Dictionary<string>): string {
const lastIndex = Object.size(obj) - 1;

const res = Object.entries(obj).reduce((res, [key, value], index) => {
const separator = index < lastIndex ? ',' : '';
res[index] = `"${key}":${value != null ? value : null}${separator}`;
res[index] = `"${key}":${value != null ? value : null}`;

return res;
}, <string[]>[]).join('');
}, <string[]>[]).join(',');

return `{${res}}`;
}
Expand Down

0 comments on commit e927425

Please sign in to comment.