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

Function readCompatibleScalar

javascript/test/typemeta.test.ts:51–71  ·  view source on GitHub ↗
(
  typeId: number,
  writerField: TypeInfo,
  readerField: TypeInfo,
  value: unknown,
)

Source from the content-addressed store, hash-verified

49}
50
51function readCompatibleScalar(
52 typeId: number,
53 writerField: TypeInfo,
54 readerField: TypeInfo,
55 value: unknown,
56): any {
57 const writerFory = new Fory({ compatible: true });
58 const readerFory = new Fory({ compatible: true });
59 const writer = writerFory.register(
60 Type.struct(typeId, {
61 value: writerField,
62 }),
63 );
64 const reader = readerFory.register(
65 Type.struct(typeId, {
66 value: readerField,
67 }),
68 );
69
70 return reader.deserialize(writer.serialize({ value }));
71}
72
73function typeMetaRecord(typeMeta: TypeMeta): Uint8Array {
74 const writer = new BinaryWriter({});

Callers 1

typemeta.test.tsFile · 0.85

Calls 4

registerMethod · 0.95
structMethod · 0.80
deserializeMethod · 0.65
serializeMethod · 0.65

Tested by

no test coverage detected