MCPcopy Create free account
hub / github.com/DeepNotesApp/DeepNotes / makeSlim

Function makeSlim

apps/client/src/code/pages/slim.ts:16–32  ·  view source on GitHub ↗
(root: T, defaults: T)

Source from the content-addressed store, hash-verified

14}
15
16export function makeSlim<T extends object>(root: T, defaults: T): T {
17 for (const [key, value] of Object.entries(root)) {
18 const defaultValue = (defaults as any)?.[key];
19
20 if (value === defaultValue) {
21 delete (root as any)[key];
22 } else if (_isSlimmableObject(key, value, defaults)) {
23 makeSlim(value, defaultValue);
24
25 if (Object.keys(value).length === 0) {
26 delete (root as any)[key];
27 }
28 }
29 }
30
31 return root as any;
32}
33
34type WrapSlimAux = {
35 prev?: WrapSlimAux;

Callers 5

_serializeNoteMethod · 0.90
_serializeArrowMethod · 0.90
_deserializeNoteMethod · 0.90
_deserializeArrowMethod · 0.90
finishMethod · 0.90

Calls 1

_isSlimmableObjectFunction · 0.85

Tested by

no test coverage detected