MCPcopy Create free account
hub / github.com/esengine/esengine / deserialize

Function deserialize

packages/core/src/ECS/Serialization/ValueSerializer.ts:77–97  ·  view source on GitHub ↗
(value: SerializableValue)

Source from the content-addressed store, hash-verified

75}
76
77function deserialize(value: SerializableValue): unknown {
78 if (value == null) return value;
79
80 const t = typeof value;
81 if (t === 'string' || t === 'number' || t === 'boolean') return value;
82
83 if (isTypedValue(value)) {
84 const def = types.get(value.__type);
85 return def ? def.deserialize(value) : value;
86 }
87
88 if (Array.isArray(value)) {
89 return value.map(deserialize);
90 }
91
92 const result: Record<string, unknown> = {};
93 for (const k of Object.keys(value)) {
94 result[k] = deserialize((value as Record<string, SerializableValue>)[k]);
95 }
96 return result;
97}
98
99function isTypedValue(v: unknown): v is { __type: string; value: unknown } {
100 if (v === null || typeof v !== 'object') {

Callers

nothing calls this directly

Calls 6

isTypedValueFunction · 0.85
isArrayMethod · 0.80
keysMethod · 0.80
getMethod · 0.65
deserializeMethod · 0.65
mapMethod · 0.45

Tested by

no test coverage detected