英文:
ClientWritableStream implementation in grpc-js node library is different from whats mentioned in grpc/node API reference
问题
grpc-js reference
write方法的第二个参数是编码(encoding)。
_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);
}
而grpc/node API reference中的flags是第二个参数。这两者应该是相同的吗?
这是我第一次查阅GitHub上的文档,请告诉我是否有更好的文档可供参考。
公平的解释,如果有的话,请提供文档链接。
英文:
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.
答案1
得分: 1
你可以看到问题中引用的实现尝试将encoding
参数解释为数字并将其用作标志。实际声明的类型受现有内置定义的限制,该定义位于Writable
类中,而ClientWritableStream
是其子类。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论