( envVar: string, fory: Fory, expected: T, assertFn: AssertFn<T>, )
| 162 | } |
| 163 | |
| 164 | function 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 | |
| 184 | function normalizeAcyclic(value: unknown): unknown { |
| 185 | if (value instanceof Decimal) { |
no test coverage detected