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

Method write

javascript/packages/core/lib/gen/datetime.ts:67–78  ·  view source on GitHub ↗
(accessor: string)

Source from the content-addressed store, hash-verified

65 }
66
67 write(accessor: string): string {
68 const msVar = this.scope.uniqueName("ts_ms");
69 const secondsVar = this.scope.uniqueName("ts_sec");
70 const nanosVar = this.scope.uniqueName("ts_nanos");
71 return `
72 const ${msVar} = ${accessor};
73 const ${secondsVar} = Math.floor(${msVar} / 1000);
74 const ${nanosVar} = Math.round((${msVar} - ${secondsVar} * 1000) * 1000000);
75 ${this.builder.writer.writeVarInt64(`${secondsVar}`)}
76 ${this.builder.writer.writeInt32(`${nanosVar}`)}
77 `;
78 }
79
80 read(accessor: (expr: string) => string): string {
81 const seconds = this.builder.reader.readVarInt64();

Callers

nothing calls this directly

Calls 3

uniqueNameMethod · 0.80
writeVarInt64Method · 0.45
writeInt32Method · 0.45

Tested by

no test coverage detected