MCPcopy Create free account
hub / github.com/apache/fory / runFileRoundTrip

Function runFileRoundTrip

integration_tests/idl_tests/javascript/roundtrip.ts:164–182  ·  view source on GitHub ↗
(
  envVar: string,
  fory: Fory,
  expected: T,
  assertFn: AssertFn<T>,
)

Source from the content-addressed store, hash-verified

162}
163
164function runFileRoundTrip<T>(
165 envVar: string,
166 fory: Fory,
167 expected: T,
168 assertFn: AssertFn<T>,
169): void {
170 const filePath = process.env[envVar];
171 if (!filePath) {
172 return;
173 }
174 console.log(`Processing ${envVar}: ${filePath}`);
175 const payload = new Uint8Array(fs.readFileSync(filePath));
176 const serializer = resolveRootSerializer(fory, payload);
177 const decoded = fory.deserialize(payload, serializer);
178 assertFn(expected, decoded);
179 const roundTripBytes = fory.serialize(decoded, serializer);
180 fs.writeFileSync(filePath, roundTripBytes);
181 console.log(` OK: roundtrip complete for ${envVar}`);
182}
183
184function normalizeAcyclic(value: unknown): unknown {
185 if (value instanceof Decimal) {

Callers 2

runStandardRoundTripFunction · 0.70
runRefRoundTripFunction · 0.70

Calls 4

resolveRootSerializerFunction · 0.85
logMethod · 0.80
deserializeMethod · 0.65
serializeMethod · 0.65

Tested by

no test coverage detected