grpc-js reference Where write method has encoding as second argument
_write(chunk: RequestType, encoding: string, cb: WriteCallback) {
const context: MessageContext = {
callback: cb,
};
const flags = Number(encoding);
if (!Number.isNaN(flags)) {
context.flags = flags;
}
this.call?.sendMessageWithContext(context, chunk);
}
While grpc/node API reference has flags as second argument. Aren't these two should be same? This is my first time referring github for documentation please help if there is better documentation for the same.
Fair explanation, Link for documentations if available.
You can see that the implementation quoted in the question tries to interpret the encoding
argument as a number and use it as the flags. The actual declared types are constrained by the existing built in definition of the Writable
class, which ClientWritableStream
is a subclass of.