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

Method writeRefOrNull

javascript/packages/core/lib/context.ts:382–400  ·  view source on GitHub ↗
(object: any)

Source from the content-addressed store, hash-verified

380 }
381
382 writeRefOrNull(object: any) {
383 if (object === null || object === undefined) {
384 this.writer.writeInt8(RefFlags.NullFlag);
385 return true;
386 }
387 if (this.typeResolver.trackingRef) {
388 const refId = this.refWriter.getWrittenRefId(object);
389 if (typeof refId === "number") {
390 this.writer.writeInt8(RefFlags.RefFlag);
391 this.writer.writeVarUInt32(refId);
392 return true;
393 }
394 this.writer.writeInt8(RefFlags.RefValueFlag);
395 this.refWriter.writeRef(object);
396 return false;
397 }
398 this.writer.writeInt8(RefFlags.NotNullValueFlag);
399 return false;
400 }
401
402 writeTypeMeta(typeInfo: TypeInfo, bytes: Uint8Array) {
403 if (typeInfo.dynamicTypeId !== -1) {

Callers

nothing calls this directly

Calls 4

writeRefMethod · 0.65
writeInt8Method · 0.45
getWrittenRefIdMethod · 0.45
writeVarUInt32Method · 0.45

Tested by

no test coverage detected