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

Function integerToIntegerExpr

javascript/packages/core/lib/gen/struct.ts:413–429  ·  view source on GitHub ↗
(
  remoteTypeId: number,
  localTypeId: number,
  value: string,
  converter: string,
)

Source from the content-addressed store, hash-verified

411}
412
413function integerToIntegerExpr(
414 remoteTypeId: number,
415 localTypeId: number,
416 value: string,
417 converter: string,
418): string {
419 if (remoteTypeId === localTypeId) {
420 return value;
421 }
422 if (integerRangeFits(remoteTypeId, localTypeId)) {
423 if (localTypeId === TypeId.INT64 || localTypeId === TypeId.UINT64) {
424 return `BigInt(${value})`;
425 }
426 return value;
427 }
428 return `${converter}.${checkedIntegerMethod(localTypeId)}(${value})`;
429}
430
431function checkedIntegerMethod(localTypeId: number): string | null {
432 switch (localTypeId) {

Callers 1

scalarToIntegerExprFunction · 0.85

Calls 2

integerRangeFitsFunction · 0.85
checkedIntegerMethodFunction · 0.85

Tested by

no test coverage detected