MCPcopy Create free account
hub / github.com/callstack/react-native-material-palette / serialize

Function serialize

src/createPalette.tsx:16–33  ·  view source on GitHub ↗
(obj: any)

Source from the content-addressed store, hash-verified

14 const uri = Image.resolveAssetSource(source)?.uri ?? '';
15
16 function serialize(obj: any): string {
17 if (obj == null) {
18 return '';
19 }
20
21 if (typeof obj !== 'object') {
22 return String(obj);
23 }
24
25 if (Array.isArray(obj)) {
26 return obj.map(serialize).join(',');
27 }
28
29 return Object.entries(obj)
30 .sort(([a], [b]) => a.localeCompare(b))
31 .map(([k, v]) => `${k}:${serialize(v)}`)
32 .join(',');
33 }
34
35 const optionsStr = serialize(options);
36

Callers 1

getCacheKeyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected