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

Function normalizeForyValue

benchmarks/javascript/benchmark.js:748–790  ·  view source on GitHub ↗
(datasetKey, value)

Source from the content-addressed store, hash-verified

746}
747
748function normalizeForyValue(datasetKey, value) {
749 switch (datasetKey) {
750 case "sample":
751 return {
752 ...value,
753 long_value: BigInt(value.long_value),
754 long_value_boxed: BigInt(value.long_value_boxed),
755 float_value: toFloat32(value.float_value),
756 float_value_boxed: toFloat32(value.float_value_boxed),
757 int_array: Int32Array.from(value.int_array),
758 long_array: BigInt64Array.from(value.long_array, (item) => BigInt(item)),
759 float_array: Float32Array.from(value.float_array, toFloat32),
760 double_array: Float64Array.from(value.double_array),
761 short_array: Int32Array.from(value.short_array),
762 char_array: Int32Array.from(value.char_array),
763 };
764 case "mediacontent":
765 return {
766 media: {
767 ...value.media,
768 duration: BigInt(value.media.duration),
769 size: BigInt(value.media.size),
770 },
771 images: value.images.map((image) => ({ ...image })),
772 };
773 case "structlist":
774 return {
775 struct_list: value.struct_list.map((item) => ({ ...item })),
776 };
777 case "samplelist":
778 return {
779 sample_list: value.sample_list.map((item) => normalizeForyValue("sample", item)),
780 };
781 case "mediacontentlist":
782 return {
783 media_content_list: value.media_content_list.map((item) =>
784 normalizeForyValue("mediacontent", item)
785 ),
786 };
787 default:
788 return value;
789 }
790}
791
792function normalizeForyRoundTripValue(datasetKey, value) {
793 switch (datasetKey) {

Callers 4

ensureSerializationWorksFunction · 0.85
verifySchemaMismatchFunction · 0.85
serializeBytesFunction · 0.85
createBenchmarkCaseFunction · 0.85

Calls 3

toFloat32Function · 0.85
fromMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected