-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Overriding util.fetch to load files from zip bundle #684
Comments
Looks like your Also, make sure to either honor |
@dcodeIO Thanks! it worked perfectly, another question... is it posible that the decoded object use snake_case instead of camelCase? we have a lot of plugins that references properties using snake_case. Again, thank you for your help |
var root = new protobuf.Root();
root.load("myfile.proto", { keepCase: true }).then(...); |
@dcodeIO again, thank you for your help, Root.prototype.load = function load(filename, options, callback) {
if (typeof options === "function") {
callback = options;
options = undefined;
}
... So, I think there's a bug. I want to ask you another thing, I need to add a custom property to every object just for visualization (e.g namespace + type), but the message has its own toJSON methods. therefore, my custom property is not added. what should I do ? I don't wanna use |
Regarding your question: You could override the default toJSON implementation: protobuf.Message.prototype.toJSON = (function(toJSON_default) {
return function toJSON_ex() {
var res = toJSON_default.call(this);
res._ns = this.$type.fullName; // or any other custom property
return res;
};
})(protobuf.Message.prototype.toJSON); |
Hi @dcodeIO it's me again with another question. We have an index out of range error with some messages and I think it's because this : Thank you |
Yeah, that looks like something custom. I don't know how they handle it, but you could try to simply copy the fields of whatever it extends to the message with the option - basically join it, if that's what they do. If that's it, then this could oft course be done automatically by using reflection. |
Not sure if this issue has already been solved or not. Closing it for now. Feel free to reopen if there are any remaining issues! |
protobuf.js version: 6.3.3
Hi, This is a Question not an issue..., I'm trying to create a monkey patch to override util.fetch function because I need to load .proto files from a zip bundle. the thing is, I have a .proto with two imports (3 files to load in total) so.. When I check root object after load (promise way), the file's array contains all 3 files which means they are loaded correctly, but when I check all the way through nested objects I can figure out that last imported file wasn't processed. I'm using this function to override util.fetch
what am I missing or doing wrong?
I'm using nodeJs 4.6.0 btw.
The text was updated successfully, but these errors were encountered: