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

Method write

javascript/packages/core/lib/gen/map.ts:464–491  ·  view source on GitHub ↗
(accessor: string)

Source from the content-addressed store, hash-verified

462 }
463
464 write(accessor: string): string {
465 const anySerializer = this.builder.getExternal(MapAnySerializer.name);
466 if (!this.isAny()) {
467 return this.writeSpecificType(accessor);
468 }
469 const innerSerializer = (innerTypeInfo: TypeInfo) => {
470 return this.scope.declare(
471 "map_inner_ser",
472 TypeId.isNamedType(innerTypeInfo.typeId)
473 ? this.builder.typeResolver.getSerializerByName(
474 CodecBuilder.replaceBackslashAndQuote(innerTypeInfo.named!),
475 )
476 : this.builder.typeResolver.getSerializerById(
477 innerTypeInfo.typeId,
478 innerTypeInfo.userTypeId,
479 ),
480 );
481 };
482 return `new (${anySerializer})(${this.builder.getWriteContextName()}, ${this.builder.getReadContextName()}, ${
483 this.typeInfo.options!.key!.typeId !== TypeId.UNKNOWN
484 ? innerSerializer(this.typeInfo.options!.key!)
485 : null
486 }, ${
487 this.typeInfo.options!.value!.typeId !== TypeId.UNKNOWN
488 ? innerSerializer(this.typeInfo.options!.value!)
489 : null
490 }).write(${accessor})`;
491 }
492
493 private readSpecificType(
494 accessor: (expr: string) => string,

Callers

nothing calls this directly

Calls 5

isAnyMethod · 0.95
writeSpecificTypeMethod · 0.95
getWriteContextNameMethod · 0.80
getReadContextNameMethod · 0.80
getExternalMethod · 0.45

Tested by

no test coverage detected