mafintosh / mafintosh/protocol-buffers
Enum Translations
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 760
- Forks
- 75
- PR merge metrics
- No merged PRs in 30d
Description
I have a very simple enum, and when i decode a message the enum is the value rather than the key.
Is this on purpose? My initial thinking was that the enum gets translated to value, communicated, then translated back to the key when a message is decoded.
enum Carrier {
T_MOBILE = 0;
ATT = 1;
}
message Test {
Carrier carrier = 1;
}
var buf = messages.Test.encode({
carrier: messages.Carrier.ATT
});
var obj = messages.Test.decode(buf)
console.log(obj)
>> { carrier: 1 }
Expected (something like this):
var obj = messages.Test.decode(buf)
console.log(obj)
>> { carrier: 'ATT' }
I can get the key with additional step using lodash, but like i mentioned above, that feels contrary to what i was expecting.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no files or tests. Start by tracing the enum encode/decode behavior in protocol-buffers using the provided Carrier example, then inspect existing coverage for decoded enum values. Done means the project’s intended representation is decided and the behavior or documentation clearly matches that decision.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100